/**
 * DSS Core CSS - Layer 0 (Structural Only)
 *
 * This file provides the structural foundation for DSS Admin UI.
 * It contains NO design decisions - only layout and structural CSS.
 * The UI should be functional (but unstyled) with only this file.
 */

/* ==========================================================================
   CSS Reset / Normalize
   ========================================================================== */

*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  line-height: 1.15;
  -webkit-text-size-adjust: 100%;
  font-size: 16px;
}

body {
  min-height: 100vh;
  text-rendering: optimizeSpeed;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
}

img, picture, video, canvas, svg {
  display: block;
  max-width: 100%;
}

input, button, textarea, select {
  font: inherit;
}

a {
  text-decoration: none;
  color: inherit;
}

ul, ol {
  list-style: none;
}

button {
  cursor: pointer;
  border: none;
  background: none;
}

/* ==========================================================================
   App Shell - CSS Grid Layout
   ========================================================================== */

.app-layout {
  display: grid;
  grid-template-columns: var(--app-sidebar-width, 240px) 1fr;
  grid-template-rows: var(--app-header-height, 60px) 1fr;
  min-height: 100vh;
  width: 100%;
  overflow: hidden;
}

.app-header {
  grid-column: 1 / -1;
  grid-row: 1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  z-index: 40;
}

.sidebar {
  grid-column: 1;
  grid-row: 2;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  overflow-x: hidden;
  z-index: 30;
}

.app-main {
  grid-column: 2;
  grid-row: 2;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  position: relative;
  z-index: 10;
}

/* ==========================================================================
   Flexbox Utilities
   ========================================================================== */

.flex { display: flex; }
.flex-col { flex-direction: column; }
.flex-row { flex-direction: row; }
.flex-wrap { flex-wrap: wrap; }
.flex-1 { flex: 1; }
.flex-auto { flex: auto; }
.flex-none { flex: none; }

.items-start { align-items: flex-start; }
.items-center { align-items: center; }
.items-end { align-items: flex-end; }
.items-stretch { align-items: stretch; }

.justify-start { justify-content: flex-start; }
.justify-center { justify-content: center; }
.justify-end { justify-content: flex-end; }
.justify-between { justify-content: space-between; }
.justify-around { justify-content: space-around; }

/* Gap utilities use hardcoded fallbacks since core loads before tokens */
.gap-1 { gap: 0.25rem; }
.gap-2 { gap: 0.5rem; }
.gap-3 { gap: 0.75rem; }
.gap-4 { gap: 1rem; }
.gap-5 { gap: 1.25rem; }
.gap-6 { gap: 1.5rem; }

/* ==========================================================================
   Grid Utilities
   ========================================================================== */

.grid { display: grid; }
.grid-cols-1 { grid-template-columns: repeat(1, minmax(0, 1fr)); }
.grid-cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid-auto-fill { grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); }

/* ==========================================================================
   Visibility & Display
   ========================================================================== */

.hidden { display: none !important; }
.block { display: block; }
.inline-block { display: inline-block; }
.inline { display: inline; }

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* ==========================================================================
   Overflow & Scroll
   ========================================================================== */

.overflow-hidden { overflow: hidden; }
.overflow-auto { overflow: auto; }
.overflow-x-auto { overflow-x: auto; }
.overflow-y-auto { overflow-y: auto; }
.overflow-scroll { overflow: scroll; }

/* ==========================================================================
   Position
   ========================================================================== */

.relative { position: relative; }
.absolute { position: absolute; }
.fixed { position: fixed; }
.sticky { position: sticky; }

.inset-0 { top: 0; right: 0; bottom: 0; left: 0; }
.top-0 { top: 0; }
.right-0 { right: 0; }
.bottom-0 { bottom: 0; }
.left-0 { left: 0; }

/* ==========================================================================
   Width & Height
   ========================================================================== */

.w-full { width: 100%; }
.w-auto { width: auto; }
.h-full { height: 100%; }
.h-auto { height: auto; }
.min-h-screen { min-height: 100vh; }

/* ==========================================================================
   Responsive Breakpoints
   ========================================================================== */

@media (max-width: 1024px) {
  .app-layout {
    grid-template-columns: var(--app-sidebar-width-tablet, 200px) 1fr;
  }
}

@media (max-width: 768px) {
  .app-layout {
    grid-template-columns: 1fr;
    grid-template-rows: var(--app-header-height, 60px) 1fr;
  }

  .sidebar {
    position: fixed;
    top: var(--app-header-height, 60px);
    left: 0;
    bottom: 0;
    width: var(--app-sidebar-width, 240px);
    transform: translateX(-100%);
    transition: transform 0.3s ease;
    z-index: 50;
  }

  .sidebar.open {
    transform: translateX(0);
  }

  .app-main {
    grid-column: 1;
  }
}
