/* =========================================================
   ALUMINIUMGLASS USER APP
   LAYOUT CSS
   File:
   /home/jqkmqvml/user_app/assets/css/layout.css

   Purpose:
   - Application shell
   - Header / sidebar / main layout
   - Containers
   - Page structure
   - Content sections
   - Responsive grids
   - Common layout utilities

   Load order:
   variables.css
   reset.css
   base.css
   layout.css
   header.css
   sidebar.css
   navigation.css
   ...
   ========================================================= */


/* =========================================================
   01. APPLICATION SHELL
   ========================================================= */

.app-shell {
  position: relative;

  display: flex;
  flex-direction: column;

  width: 100%;
  min-height: 100vh;

  background: var(--color-background);
  color: var(--color-text);
}


/* =========================================================
   02. APPLICATION BODY
   ========================================================= */

.app-body {
  display: flex;

  width: 100%;
  min-width: 0;
  min-height: 0;

  flex: 1 1 auto;
}


/* =========================================================
   03. MAIN APPLICATION AREA
   ========================================================= */

.app-main {
  position: relative;

  display: flex;
  flex-direction: column;

  flex: 1 1 auto;

  width: 100%;
  min-width: 0;
  min-height: 100vh;

  background: var(--color-background);
}


/* =========================================================
   04. MAIN CONTENT
   ========================================================= */

.main-content {
  position: relative;

  width: 100%;
  min-width: 0;

  flex: 1 1 auto;

  padding:
    var(--space-6)
    var(--space-6)
    var(--space-8);
}


/* =========================================================
   05. PAGE WRAPPER
   ========================================================= */

.page {
  width: 100%;
  min-width: 0;
}

.page-content {
  width: 100%;
  min-width: 0;
}

.page-section {
  width: 100%;
  margin-bottom: var(--space-8);
}

.page-section:last-child {
  margin-bottom: 0;
}


/* =========================================================
   06. CONTENT CONTAINERS
   ========================================================= */

.container {
  width: 100%;

  max-width: var(--container-xl);

  margin-left: auto;
  margin-right: auto;

  padding-left: var(--space-6);
  padding-right: var(--space-6);
}

.container--sm {
  max-width: var(--container-sm);
}

.container--md {
  max-width: var(--container-md);
}

.container--lg {
  max-width: var(--container-lg);
}

.container--xl {
  max-width: var(--container-xl);
}

.container--2xl {
  max-width: var(--container-2xl);
}

.container--fluid {
  max-width: none;
}


/* =========================================================
   07. NARROW CONTENT
   ========================================================= */

.content-narrow {
  width: 100%;
  max-width: 760px;

  margin-left: auto;
  margin-right: auto;
}

.content-medium {
  width: 100%;
  max-width: 960px;

  margin-left: auto;
  margin-right: auto;
}


/* =========================================================
   08. SIDEBAR + CONTENT LAYOUT
   ========================================================= */

.layout-with-sidebar {
  display: flex;

  width: 100%;
  min-width: 0;
  min-height: 100vh;
}

.layout-sidebar {
  flex: 0 0 var(--sidebar-width);

  width: var(--sidebar-width);
  min-width: var(--sidebar-width);
}

.layout-content {
  flex: 1 1 auto;

  width: 100%;
  min-width: 0;
}


/* =========================================================
   09. TWO COLUMN LAYOUT
   ========================================================= */

.two-column {
  display: grid;

  grid-template-columns:
    minmax(0, 1fr)
    minmax(280px, 360px);

  gap: var(--space-6);

  width: 100%;
}

.two-column--equal {
  grid-template-columns:
    repeat(2, minmax(0, 1fr));
}

.two-column--wide-sidebar {
  grid-template-columns:
    minmax(0, 1fr)
    minmax(320px, 420px);
}


/* =========================================================
   10. THREE COLUMN LAYOUT
   ========================================================= */

.three-column {
  display: grid;

  grid-template-columns:
    repeat(3, minmax(0, 1fr));

  gap: var(--space-6);

  width: 100%;
}


/* =========================================================
   11. FOUR COLUMN LAYOUT
   ========================================================= */

.four-column {
  display: grid;

  grid-template-columns:
    repeat(4, minmax(0, 1fr));

  gap: var(--space-5);

  width: 100%;
}


/* =========================================================
   12. RESPONSIVE GRID
   ========================================================= */

.grid {
  display: grid;

  width: 100%;
  min-width: 0;
}

.grid-1 {
  grid-template-columns:
    minmax(0, 1fr);
}

.grid-2 {
  grid-template-columns:
    repeat(2, minmax(0, 1fr));
}

.grid-3 {
  grid-template-columns:
    repeat(3, minmax(0, 1fr));
}

.grid-4 {
  grid-template-columns:
    repeat(4, minmax(0, 1fr));
}

.grid-auto {
  grid-template-columns:
    repeat(auto-fit, minmax(240px, 1fr));
}

.grid-auto-sm {
  grid-template-columns:
    repeat(auto-fit, minmax(180px, 1fr));
}

.grid-auto-lg {
  grid-template-columns:
    repeat(auto-fit, minmax(320px, 1fr));
}


/* =========================================================
   13. GRID GAPS
   ========================================================= */

.gap-0 {
  gap: 0 !important;
}

.gap-1 {
  gap: var(--space-1) !important;
}

.gap-2 {
  gap: var(--space-2) !important;
}

.gap-3 {
  gap: var(--space-3) !important;
}

.gap-4 {
  gap: var(--space-4) !important;
}

.gap-5 {
  gap: var(--space-5) !important;
}

.gap-6 {
  gap: var(--space-6) !important;
}

.gap-8 {
  gap: var(--space-8) !important;
}

.gap-10 {
  gap: var(--space-10) !important;
}

.gap-12 {
  gap: var(--space-12) !important;
}


/* =========================================================
   14. PAGE HEADER
   ========================================================= */

.page-header {
  display: flex;

  align-items: flex-start;
  justify-content: space-between;

  gap: var(--space-6);

  width: 100%;

  margin-bottom: var(--space-6);
}

.page-header__content {
  min-width: 0;
  flex: 1 1 auto;
}

.page-header__actions {
  display: flex;

  align-items: center;
  justify-content: flex-end;

  gap: var(--space-3);

  flex: 0 0 auto;
}


/* =========================================================
   15. PAGE TITLE
   ========================================================= */

.page-title {
  margin: 0;

  color: var(--color-text);

  font-size: var(--font-size-3xl);
  font-weight: var(--font-weight-bold);
  line-height: var(--line-height-tight);

  overflow-wrap: anywhere;
}

.page-description {
  max-width: 760px;

  margin-top: var(--space-2);

  color: var(--color-text-muted);

  font-size: var(--font-size-md);
  line-height: var(--line-height-relaxed);
}


/* =========================================================
   16. BREADCRUMB AREA
   ========================================================= */

.page-breadcrumb {
  width: 100%;

  margin-bottom: var(--space-4);
}


/* =========================================================
   17. TOOLBAR
   ========================================================= */

.toolbar {
  display: flex;

  align-items: center;
  justify-content: space-between;

  gap: var(--space-4);

  width: 100%;

  margin-bottom: var(--space-5);
}

.toolbar__left,
.toolbar__right {
  display: flex;

  align-items: center;

  gap: var(--space-3);

  min-width: 0;
}

.toolbar__left {
  justify-content: flex-start;
}

.toolbar__right {
  justify-content: flex-end;
}


/* =========================================================
   18. SECTION HEADER
   ========================================================= */

.section-header {
  display: flex;

  align-items: center;
  justify-content: space-between;

  gap: var(--space-4);

  width: 100%;

  margin-bottom: var(--space-5);
}

.section-header__content {
  min-width: 0;
}

.section-header__actions {
  display: flex;

  align-items: center;

  gap: var(--space-2);

  flex: 0 0 auto;
}

.section-title {
  margin: 0;

  color: var(--color-text);

  font-size: var(--font-size-xl);
  font-weight: var(--font-weight-semibold);
  line-height: var(--line-height-tight);
}

.section-description {
  margin-top: var(--space-1);

  color: var(--color-text-muted);

  font-size: var(--font-size-sm);
  line-height: var(--line-height-relaxed);
}


/* =========================================================
   19. CONTENT SECTION
   ========================================================= */

.content-section {
  width: 100%;

  margin-bottom: var(--space-8);
}

.content-section:last-child {
  margin-bottom: 0;
}


/* =========================================================
   20. STACK LAYOUT
   ========================================================= */

.stack {
  display: flex;
  flex-direction: column;

  min-width: 0;
}

.stack--1 {
  gap: var(--space-1);
}

.stack--2 {
  gap: var(--space-2);
}

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

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

.stack--5 {
  gap: var(--space-5);
}

.stack--6 {
  gap: var(--space-6);
}

.stack--8 {
  gap: var(--space-8);
}


/* =========================================================
   21. INLINE / ROW LAYOUT
   ========================================================= */

.inline-row {
  display: flex;

  flex-direction: row;
  align-items: center;

  min-width: 0;
}

.inline-row--start {
  justify-content: flex-start;
}

.inline-row--center {
  justify-content: center;
}

.inline-row--end {
  justify-content: flex-end;
}

.inline-row--between {
  justify-content: space-between;
}

.inline-row--wrap {
  flex-wrap: wrap;
}


/* =========================================================
   22. CENTERED CONTENT
   ========================================================= */

.center-content {
  display: flex;

  align-items: center;
  justify-content: center;

  width: 100%;
  min-height: 100%;
}

.center-page {
  display: flex;

  align-items: center;
  justify-content: center;

  width: 100%;
  min-height: 100vh;

  padding: var(--space-6);
}


/* =========================================================
   23. AUTH / SPECIAL PAGE LAYOUT
   ========================================================= */

.auth-layout {
  display: flex;

  align-items: center;
  justify-content: center;

  width: 100%;
  min-height: 100vh;

  padding:
    var(--space-8)
    var(--space-6);

  background: var(--color-background);
}

.auth-layout__container {
  width: 100%;
  max-width: 460px;

  margin-left: auto;
  margin-right: auto;
}


/* =========================================================
   24. FULL WIDTH SECTION
   ========================================================= */

.full-width {
  width: 100% !important;
  max-width: none !important;
}


/* =========================================================
   25. ASPECT RATIO HELPERS
   ========================================================= */

.aspect-square {
  aspect-ratio: 1 / 1;
}

.aspect-video {
  aspect-ratio: 16 / 9;
}

.aspect-wide {
  aspect-ratio: 21 / 9;
}


/* =========================================================
   26. OVERLAY FOUNDATION
   ========================================================= */

.layout-overlay {
  position: fixed;

  inset: 0;

  z-index: var(--z-overlay);

  width: 100%;
  height: 100%;

  background: rgb(15 23 42 / 0.48);

  opacity: 0;
  visibility: hidden;

  transition:
    opacity var(--transition-normal),
    visibility var(--transition-normal);
}

.layout-overlay.is-visible {
  opacity: 1;
  visibility: visible;
}


/* =========================================================
   27. MOBILE NAVIGATION SPACE
   ========================================================= */

.mobile-bottom-space {
  display: none;
}


/* =========================================================
   28. DASHBOARD LAYOUT
   ========================================================= */

.dashboard-layout {
  display: grid;

  grid-template-columns:
    repeat(12, minmax(0, 1fr));

  gap: var(--space-6);

  width: 100%;
}

.dashboard-main {
  grid-column: span 8;

  min-width: 0;
}

.dashboard-aside {
  grid-column: span 4;

  min-width: 0;
}


/* =========================================================
   29. STAT GRID
   ========================================================= */

.stat-grid {
  display: grid;

  grid-template-columns:
    repeat(4, minmax(0, 1fr));

  gap: var(--space-5);

  width: 100%;
}


/* =========================================================
   30. LIST + DETAIL LAYOUT
   ========================================================= */

.list-detail-layout {
  display: grid;

  grid-template-columns:
    minmax(280px, 360px)
    minmax(0, 1fr);

  gap: var(--space-6);

  width: 100%;
  min-width: 0;
}

.list-detail__list,
.list-detail__detail {
  min-width: 0;
}


/* =========================================================
   31. SEARCH LAYOUT
   ========================================================= */

.search-layout {
  display: grid;

  grid-template-columns:
    minmax(240px, 300px)
    minmax(0, 1fr);

  gap: var(--space-6);

  width: 100%;
  min-width: 0;
}

.search-layout__filters,
.search-layout__results {
  min-width: 0;
}


/* =========================================================
   32. FORM + PREVIEW LAYOUT
   ========================================================= */

.form-preview-layout {
  display: grid;

  grid-template-columns:
    minmax(0, 1fr)
    minmax(300px, 420px);

  gap: var(--space-6);

  width: 100%;
  min-width: 0;
}

.form-preview-layout > * {
  min-width: 0;
}


/* =========================================================
   33. PROFILE LAYOUT
   ========================================================= */

.profile-layout {
  display: grid;

  grid-template-columns:
    minmax(220px, 280px)
    minmax(0, 1fr);

  gap: var(--space-6);

  width: 100%;
  min-width: 0;
}

.profile-layout > * {
  min-width: 0;
}


/* =========================================================
   34. MESSAGE LAYOUT
   ========================================================= */

.message-layout {
  display: grid;

  grid-template-columns:
    minmax(260px, 340px)
    minmax(0, 1fr);

  width: 100%;
  min-height: 650px;

  overflow: hidden;

  border:
    1px solid var(--color-border);

  border-radius: var(--radius-lg);

  background: var(--color-surface);
}

.message-list,
.message-conversation {
  min-width: 0;
  min-height: 0;
}

.message-list {
  border-right: 1px solid var(--color-border);
}


/* =========================================================
   35. LOCATION LAYOUT
   ========================================================= */

.location-layout {
  display: grid;

  grid-template-columns:
    minmax(0, 1fr)
    minmax(280px, 380px);

  gap: var(--space-6);

  width: 100%;
  min-width: 0;
}


/* =========================================================
   36. FOOTER SPACE
   ========================================================= */

.app-footer {
  width: 100%;
  flex-shrink: 0;
}


/* =========================================================
   37. SAFE AREA SUPPORT
   ========================================================= */

.safe-area-bottom {
  padding-bottom:
    max(
      var(--space-4),
      env(safe-area-inset-bottom)
    );
}

.safe-area-top {
  padding-top:
    max(
      var(--space-4),
      env(safe-area-inset-top)
    );
}


/* =========================================================
   38. MOBILE — TABLET
   ========================================================= */

@media (max-width: 1199px) {
  .four-column {
    grid-template-columns:
      repeat(3, minmax(0, 1fr));
  }

  .stat-grid {
    grid-template-columns:
      repeat(2, minmax(0, 1fr));
  }

  .dashboard-main {
    grid-column: span 12;
  }

  .dashboard-aside {
    grid-column: span 12;
  }
}


/* =========================================================
   39. TABLET
   ========================================================= */

@media (max-width: 991px) {
  .main-content {
    padding:
      var(--space-5)
      var(--space-5)
      var(--space-7);
  }

  .container {
    padding-left: var(--space-5);
    padding-right: var(--space-5);
  }

  .three-column {
    grid-template-columns:
      repeat(2, minmax(0, 1fr));
  }

  .four-column {
    grid-template-columns:
      repeat(2, minmax(0, 1fr));
  }

  .two-column,
  .two-column--equal,
  .two-column--wide-sidebar {
    grid-template-columns:
      minmax(0, 1fr);
  }

  .search-layout {
    grid-template-columns:
      minmax(0, 1fr);
  }

  .form-preview-layout {
    grid-template-columns:
      minmax(0, 1fr);
  }

  .profile-layout {
    grid-template-columns:
      minmax(0, 1fr);
  }

  .location-layout {
    grid-template-columns:
      minmax(0, 1fr);
  }

  .list-detail-layout {
    grid-template-columns:
      minmax(0, 1fr);
  }
}


/* =========================================================
   40. MOBILE
   ========================================================= */

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

  .container {
    padding-left: var(--space-4);
    padding-right: var(--space-4);
  }

  .page-header {
    flex-direction: column;
    align-items: stretch;

    gap: var(--space-4);

    margin-bottom: var(--space-5);
  }

  .page-header__actions {
    justify-content: flex-start;
    width: 100%;
  }

  .page-title {
    font-size: var(--font-size-2xl);
  }

  .page-description {
    font-size: var(--font-size-sm);
  }

  .toolbar {
    flex-direction: column;
    align-items: stretch;
  }

  .toolbar__left,
  .toolbar__right {
    width: 100%;
  }

  .toolbar__right {
    justify-content: flex-start;
  }

  .section-header {
    align-items: flex-start;
    flex-direction: column;
  }

  .section-header__actions {
    width: 100%;
  }

  .grid-2,
  .grid-3,
  .grid-4,
  .three-column,
  .four-column {
    grid-template-columns:
      minmax(0, 1fr);
  }

  .stat-grid {
    grid-template-columns:
      minmax(0, 1fr);
  }

  .dashboard-layout {
    grid-template-columns:
      minmax(0, 1fr);
  }

  .dashboard-main,
  .dashboard-aside {
    grid-column: auto;
  }

  .message-layout {
    grid-template-columns:
      minmax(0, 1fr);

    min-height: auto;
  }

  .message-list {
    border-right: 0;
    border-bottom: 1px solid var(--color-border);
  }

  .mobile-bottom-space {
    display: block;

    width: 100%;
    height:
      calc(
        var(--mobile-nav-height, 64px)
        + env(safe-area-inset-bottom)
      );
  }

  .auth-layout {
    align-items: flex-start;

    padding:
      var(--space-6)
      var(--space-4);
  }
}


/* =========================================================
   41. SMALL MOBILE
   ========================================================= */

@media (max-width: 479px) {
  .main-content {
    padding:
      var(--space-3)
      var(--space-3)
      var(--space-5);
  }

  .container {
    padding-left: var(--space-3);
    padding-right: var(--space-3);
  }

  .page-title {
    font-size: var(--font-size-xl);
  }

  .page-section,
  .content-section {
    margin-bottom: var(--space-6);
  }

  .auth-layout {
    padding:
      var(--space-4)
      var(--space-3);
  }
}


/* =========================================================
   42. REDUCED MOTION
   ========================================================= */

@media (prefers-reduced-motion: reduce) {
  .layout-overlay {
    transition: none;
  }
}


/* =========================================================
   END OF LAYOUT CSS
   ========================================================= */