/**
 * RUNEKT Layout Styles
 * 3-column workspace layout with responsive breakpoints
 * Mobile-first, WCAG 2.1 AA compliant
 * @version 1.0.0
 */

/* ============================================================================
   3-Column Workspace Layout
   SPEC §7.5: Sidebar (260px) | Main (1fr) | Right Panel (320px)
   ============================================================================ */

.rk-workspace {
  display: grid;
  grid-template-columns: var(--rk-sidebar-width) 1fr var(--rk-right-panel-width);
  grid-template-rows: var(--rk-topbar-height) 1fr;
  height: 100dvh;
  width: 100%;
  overflow: hidden;
}

/* Workspace Areas */
.rk-workspace-sidebar {
  grid-row: 1 / -1;
  grid-column: 1;
  background-color: white;
  border-right: 1px solid var(--rk-border);
  overflow-y: auto;
  overflow-x: hidden;
}

.rk-workspace-topbar {
  grid-row: 1;
  grid-column: 2 / -1;
  background-color: white;
  border-bottom: 1px solid var(--rk-border);
  display: flex;
  align-items: center;
  padding: 0 var(--rk-space-4);
  gap: var(--rk-space-4);
}

.rk-workspace-main {
  grid-row: 2;
  grid-column: 2;
  background-color: var(--rk-bg-2);
  overflow-y: auto;
  overflow-x: hidden;
}

.rk-workspace-right {
  grid-row: 2 / -1;
  grid-column: 3;
  background-color: white;
  border-left: 1px solid var(--rk-border);
  overflow-y: auto;
  overflow-x: hidden;
}

/* ============================================================================
   Tablet Breakpoint (max-width: 1023px)
   Collapses right panel into drawer, sidebar becomes icon-only
   ============================================================================ */

@media (max-width: 1023px) {
  .rk-workspace {
    grid-template-columns: 60px 1fr;
    grid-template-rows: var(--rk-topbar-height) 1fr;
  }

  .rk-workspace-right {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    width: 320px;
    z-index: var(--rk-z-modal);
    transform: translateX(100%);
    transition: transform var(--rk-transition);
  }

  .rk-workspace-right.rk-panel-open {
    transform: translateX(0);
  }

  .rk-workspace-sidebar {
    width: 60px;
  }

  .rk-workspace-topbar {
    grid-column: 2 / -1;
  }

  .rk-workspace-main {
    grid-column: 2;
  }
}

/* ============================================================================
   Mobile Breakpoint (max-width: 767px)
   Full single-column layout with drawer navigation
   ============================================================================ */

@media (max-width: 767px) {
  .rk-workspace {
    grid-template-columns: 1fr;
    grid-template-rows: var(--rk-topbar-height) 1fr;
  }

  .rk-workspace-sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: 260px;
    max-width: 80vw;
    z-index: var(--rk-z-modal);
    transform: translateX(-100%);
    transition: transform var(--rk-transition);
  }

  .rk-workspace-sidebar.rk-panel-open {
    transform: translateX(0);
  }

  .rk-workspace-right {
    width: 100%;
    max-width: 100vw;
  }

  .rk-workspace-topbar {
    grid-column: 1 / -1;
    padding: 0 var(--rk-space-3);
  }

  .rk-workspace-main {
    grid-column: 1;
  }
}

/* ============================================================================
   Landscape Orientation (max-height: 500px)
   Compresses vertical spacing for landscape usage
   ============================================================================ */

@media (max-height: 500px) {
  .rk-workspace {
    grid-template-rows: 40px 1fr;
  }

  .rk-workspace-topbar {
    min-height: 40px;
  }
}

/* ============================================================================
   Wide Screens (1440px+)
   Centers content with max-width constraint
   ============================================================================ */

@media (min-width: 1440px) {
  .rk-workspace-main {
    max-width: 1600px;
    margin-left: auto;
    margin-right: auto;
    box-shadow: -1px 0 0 var(--rk-border), 1px 0 0 var(--rk-border);
  }
}

/* ============================================================================
   Sidebar Components
   ============================================================================ */

.rk-sidebar-section {
  padding: var(--rk-space-4);
}

.rk-sidebar-section-title {
  font-size: var(--rk-font-size-xs);
  font-weight: var(--rk-font-weight-semibold);
  color: var(--rk-text-3);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: var(--rk-space-2);
  padding: 0 var(--rk-space-4);
}

.rk-sidebar-nav {
  list-style: none;
  padding: 0;
  margin: 0;
}

.rk-sidebar-nav-item {
  display: flex;
  align-items: center;
  gap: var(--rk-space-3);
  padding: var(--rk-space-2) var(--rk-space-4);
  color: var(--rk-text-2);
  text-decoration: none;
  transition: background-color var(--rk-transition-fast),
              color var(--rk-transition-fast);
  cursor: pointer;
  border-left: 3px solid transparent;
  min-height: var(--rk-touch-min);
}

.rk-sidebar-nav-item:hover {
  background-color: var(--rk-bg-2);
  color: var(--rk-text);
}

.rk-sidebar-nav-item.active {
  background-color: var(--rk-bg-2);
  color: var(--rk-primary);
  border-left-color: var(--rk-primary);
}

.rk-sidebar-nav-icon {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
}

/* Icon-only sidebar (tablet) */
@media (max-width: 1023px) {
  .rk-sidebar-section-title {
    display: none;
  }

  .rk-sidebar-nav-item {
    justify-content: center;
    padding: var(--rk-space-3);
  }

  .rk-sidebar-nav-label {
    display: none;
  }
}

/* ============================================================================
   Topbar Components
   ============================================================================ */

.rk-topbar-left {
  display: flex;
  align-items: center;
  gap: var(--rk-space-3);
  flex: 1;
}

.rk-topbar-center {
  display: flex;
  align-items: center;
  justify-content: center;
  flex: 0 1 auto;
}

.rk-topbar-right {
  display: flex;
  align-items: center;
  gap: var(--rk-space-2);
}

.rk-topbar-title {
  font-size: var(--rk-font-size-md);
  font-weight: var(--rk-font-weight-semibold);
  color: var(--rk-text);
}

.rk-topbar-subtitle {
  font-size: var(--rk-font-size-sm);
  color: var(--rk-text-3);
}

/* ============================================================================
   Right Panel Components
   ============================================================================ */

.rk-right-panel-section {
  padding: var(--rk-space-4);
  border-bottom: 1px solid var(--rk-border);
}

.rk-right-panel-section:last-child {
  border-bottom: none;
}

.rk-right-panel-title {
  font-size: var(--rk-font-size-sm);
  font-weight: var(--rk-font-weight-semibold);
  color: var(--rk-text);
  margin-bottom: var(--rk-space-3);
}

/* ============================================================================
   Main Content Area
   ============================================================================ */

.rk-content-container {
  max-width: 900px;
  margin: 0 auto;
  padding: var(--rk-space-6);
}

@media (max-width: 767px) {
  .rk-content-container {
    padding: var(--rk-space-4);
  }
}

.rk-content-header {
  margin-bottom: var(--rk-space-6);
}

.rk-content-title {
  font-size: var(--rk-font-size-2xl);
  font-weight: var(--rk-font-weight-bold);
  color: var(--rk-text);
  margin-bottom: var(--rk-space-2);
}

.rk-content-subtitle {
  font-size: var(--rk-font-size-base);
  color: var(--rk-text-2);
}

.rk-content-body {
  line-height: var(--rk-line-height-relaxed);
  color: var(--rk-text);
}

.rk-content-body p {
  margin-bottom: var(--rk-space-4);
}

/* ============================================================================
   Chat Layout (specific to chat workspace)
   ============================================================================ */

.rk-chat-container {
  display: flex;
  flex-direction: column;
  height: 100%;
}

.rk-chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: var(--rk-space-4);
}

.rk-chat-composer-wrapper {
  flex-shrink: 0;
  padding: var(--rk-space-4);
  background-color: white;
  border-top: 1px solid var(--rk-border);
}

/* ============================================================================
   Overlay Utilities
   ============================================================================ */

.rk-overlay {
  position: fixed;
  inset: 0;
  background-color: rgba(0, 0, 0, 0.5);
  z-index: calc(var(--rk-z-modal) - 1);
  opacity: 0;
  transition: opacity var(--rk-transition);
  pointer-events: none;
}

.rk-overlay.rk-overlay-visible {
  opacity: 1;
  pointer-events: auto;
}

/* ============================================================================
   Responsive Spacing Adjustments
   ============================================================================ */

@media (max-width: 767px) {
  .rk-p-6 {
    padding: var(--rk-space-4);
  }

  .rk-gap-4 {
    gap: var(--rk-space-3);
  }
}
