/* ============================================================
   app.css  –  eyeCodeHub Application-Specific Styles
   Layout, chrome, utilities, and page-level overrides.
   Requires: liquid-glass.css (loaded first)
   ============================================================ */

/* ----------------------------------------------------------
   1. MAIN CONTENT LAYOUT
   ---------------------------------------------------------- */
.main-content {
  margin-left: var(--sidebar-width);
  padding: 2rem 2.5rem;
  min-height: 100vh;
  transition: margin-left var(--transition-slow);
}

@media (max-width: 768px) {
  .main-content {
    margin-left: 0;
    padding: 1.25rem 1rem;
    padding-top: 3.5rem; /* room for mobile toggle */
  }
}

@media (min-width: 769px) and (max-width: 1024px) {
  .main-content {
    padding: 1.5rem 1.5rem;
  }
}

/* ----------------------------------------------------------
   2. PAGE HEADER
   ---------------------------------------------------------- */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 1rem;
  margin-bottom: 2rem;
}

.page-header__title {
  font-size: var(--fs-xl);
  font-weight: 800;
  letter-spacing: -0.01em;
  color: var(--color-text-primary);
  margin: 0;
  line-height: var(--lh-tight);
}

.page-header__subtitle {
  font-size: var(--fs-sm);
  color: var(--color-text-secondary);
  margin: 0.25rem 0 0;
  font-weight: 400;
}

.page-header__actions {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  flex-shrink: 0;
}

/* Breadcrumbs inside page header */
.page-breadcrumb {
  display: flex;
  align-items: center;
  gap: 0.375rem;
  font-size: var(--fs-xs);
  color: var(--color-text-tertiary);
  margin-bottom: 0.5rem;
}

.page-breadcrumb a {
  color: var(--color-text-tertiary);
  transition: color var(--transition-fast);
}

.page-breadcrumb a:hover {
  color: var(--color-text-primary);
}

.page-breadcrumb__sep {
  opacity: 0.4;
}

/* ----------------------------------------------------------
   3. SIDEBAR BRAND / LOGO AREA
   ---------------------------------------------------------- */
.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 1.25rem 1.25rem 1rem;
  border-bottom: 1px solid var(--glass-border);
  margin-bottom: 0.25rem;
  text-decoration: none;
  flex-shrink: 0;
}

.sidebar-brand__logo {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--color-accent) 0%, #6366f1 100%);
  color: #fff;
  font-weight: 800;
  font-size: var(--fs-md);
  flex-shrink: 0;
  box-shadow: 0 2px 8px var(--color-accent-glow);
}

.sidebar-brand__text {
  display: flex;
  flex-direction: column;
}

.sidebar-brand__name {
  font-size: var(--fs-base);
  font-weight: 700;
  color: var(--color-text-primary);
  line-height: 1.2;
}

.sidebar-brand__tagline {
  font-size: 0.625rem;
  color: var(--color-text-tertiary);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 600;
}

/* Sidebar footer / user area */
.sidebar-footer {
  padding: 0.75rem 1.25rem;
  border-top: 1px solid var(--glass-border);
  flex-shrink: 0;
}

.sidebar-user {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  font-size: var(--fs-xs);
  color: var(--color-text-secondary);
}

.sidebar-user__avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--glass-bg-strong);
  border: 1px solid var(--glass-border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: var(--fs-xs);
  color: var(--color-accent);
  flex-shrink: 0;
}

/* ----------------------------------------------------------
   4. TOAST / FLASH MESSAGE STYLES
   ---------------------------------------------------------- */
.toast-container {
  position: fixed;
  top: 1.25rem;
  right: 1.25rem;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 0.625rem;
  max-width: 400px;
  width: 100%;
  pointer-events: none;
}

.toast {
  position: relative;
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  padding: 0.875rem 1.125rem;
  background: var(--glass-bg-strong);
  backdrop-filter: blur(var(--glass-blur-strong));
  -webkit-backdrop-filter: blur(var(--glass-blur-strong));
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-card);
  box-shadow: var(--glass-shadow);
  color: var(--color-text-primary);
  font-size: var(--fs-sm);
  line-height: var(--lh-normal);
  pointer-events: all;
  animation: toast-slide-in 300ms ease forwards;
  overflow: hidden;
}

.toast::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: var(--shine-top);
  pointer-events: none;
}

.toast.is-leaving {
  animation: toast-slide-out 200ms ease forwards;
}

@keyframes toast-slide-in {
  from {
    opacity: 0;
    transform: translateX(40px) scale(0.96);
  }
  to {
    opacity: 1;
    transform: translateX(0) scale(1);
  }
}

@keyframes toast-slide-out {
  from {
    opacity: 1;
    transform: translateX(0) scale(1);
  }
  to {
    opacity: 0;
    transform: translateX(40px) scale(0.96);
  }
}

.toast__icon {
  flex-shrink: 0;
  width: 20px;
  height: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  position: relative;
  z-index: 1;
}

.toast__body {
  flex: 1;
  min-width: 0;
  position: relative;
  z-index: 1;
}

.toast__title {
  font-weight: 600;
  margin-bottom: 0.125rem;
}

.toast__message {
  color: var(--color-text-secondary);
}

.toast__close {
  flex-shrink: 0;
  background: none;
  border: none;
  color: var(--color-text-tertiary);
  cursor: pointer;
  padding: 0.25rem;
  font-size: 1rem;
  line-height: 1;
  transition: color var(--transition-fast);
  position: relative;
  z-index: 1;
}

.toast__close:hover {
  color: var(--color-text-primary);
}

/* Toast color accents via left border */
.toast--success {
  border-left: 3px solid var(--color-ok);
}
.toast--success .toast__icon {
  color: var(--color-ok);
}

.toast--error {
  border-left: 3px solid var(--color-fail);
}
.toast--error .toast__icon {
  color: var(--color-fail);
}

.toast--warning {
  border-left: 3px solid var(--color-warn);
}
.toast--warning .toast__icon {
  color: var(--color-warn);
}

.toast--info {
  border-left: 3px solid var(--color-info);
}
.toast--info .toast__icon {
  color: var(--color-info);
}

/* Flask flash messages (simpler inline variant) */
.flash-messages {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-bottom: 1.5rem;
}

.flash-message {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  padding: 0.75rem 1rem;
  border-radius: var(--radius-sm);
  font-size: var(--fs-sm);
  font-weight: 500;
  border: 1px solid;
}

.flash-message--success {
  background: rgba(52, 211, 153, 0.1);
  border-color: rgba(52, 211, 153, 0.25);
  color: var(--color-ok);
}

.flash-message--error {
  background: rgba(248, 113, 113, 0.1);
  border-color: rgba(248, 113, 113, 0.25);
  color: var(--color-fail);
}

.flash-message--warning {
  background: rgba(251, 191, 36, 0.1);
  border-color: rgba(251, 191, 36, 0.25);
  color: var(--color-warn);
}

.flash-message--info {
  background: rgba(96, 165, 250, 0.1);
  border-color: rgba(96, 165, 250, 0.25);
  color: var(--color-info);
}

/* ----------------------------------------------------------
   5. MODAL – Glass Dialog
   ---------------------------------------------------------- */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 10000;
  background: rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
}

.modal-overlay.is-active {
  display: flex;
}

.modal-overlay.is-entering .modal-glass {
  animation: modal-enter 250ms ease forwards;
}

.modal-overlay.is-leaving .modal-glass {
  animation: modal-leave 180ms ease forwards;
}

@keyframes modal-enter {
  from {
    opacity: 0;
    transform: scale(0.92) translateY(12px);
  }
  to {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

@keyframes modal-leave {
  from {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
  to {
    opacity: 0;
    transform: scale(0.95) translateY(8px);
  }
}

.modal-glass {
  position: relative;
  width: 100%;
  max-width: 540px;
  max-height: 85vh;
  display: flex;
  flex-direction: column;
  background: var(--glass-bg-strong);
  backdrop-filter: blur(var(--glass-blur-strong));
  -webkit-backdrop-filter: blur(var(--glass-blur-strong));
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-panel);
  box-shadow: var(--glass-shadow);
  overflow: hidden;
}

.modal-glass::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: var(--shine-top);
  box-shadow: var(--shine-edge);
  pointer-events: none;
  z-index: 0;
}

.modal-glass__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--glass-border);
  position: relative;
  z-index: 1;
}

.modal-glass__title {
  font-size: var(--fs-md);
  font-weight: 700;
  color: var(--color-text-primary);
  margin: 0;
}

.modal-glass__close {
  background: none;
  border: none;
  color: var(--color-text-tertiary);
  font-size: 1.25rem;
  cursor: pointer;
  padding: 0.25rem;
  border-radius: var(--radius-xs);
  transition: color var(--transition-fast), background var(--transition-fast);
  line-height: 1;
}

.modal-glass__close:hover {
  color: var(--color-text-primary);
  background: rgba(255, 255, 255, 0.06);
}

.modal-glass__body {
  padding: 1.5rem;
  overflow-y: auto;
  flex: 1;
  position: relative;
  z-index: 1;
}

.modal-glass__footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.625rem;
  padding: 1rem 1.5rem;
  border-top: 1px solid var(--glass-border);
  position: relative;
  z-index: 1;
}

/* Wider modal */
.modal-glass--wide {
  max-width: 720px;
}

/* Full-height modal */
.modal-glass--tall {
  max-height: 92vh;
}

/* ----------------------------------------------------------
   6. LOADING SPINNER
   ---------------------------------------------------------- */
.spinner {
  display: inline-block;
  width: 24px;
  height: 24px;
  border: 2.5px solid rgba(255, 255, 255, 0.12);
  border-top-color: var(--color-accent);
  border-radius: 50%;
  animation: spinner-rotate 700ms linear infinite;
}

.spinner--sm {
  width: 16px;
  height: 16px;
  border-width: 2px;
}

.spinner--lg {
  width: 40px;
  height: 40px;
  border-width: 3px;
}

@keyframes spinner-rotate {
  to {
    transform: rotate(360deg);
  }
}

/* Full-page loader */
.page-loader {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  min-height: 300px;
  color: var(--color-text-tertiary);
  font-size: var(--fs-sm);
}

/* Skeleton loader lines */
.skeleton {
  background: linear-gradient(
    90deg,
    rgba(255, 255, 255, 0.04) 25%,
    rgba(255, 255, 255, 0.08) 50%,
    rgba(255, 255, 255, 0.04) 75%
  );
  background-size: 200% 100%;
  animation: skeleton-shimmer 1.5s ease infinite;
  border-radius: var(--radius-xs);
}

.skeleton--text {
  height: 0.9rem;
  margin-bottom: 0.5rem;
}

.skeleton--title {
  height: 1.4rem;
  width: 60%;
  margin-bottom: 0.75rem;
}

.skeleton--circle {
  border-radius: 50%;
}

@keyframes skeleton-shimmer {
  0%   { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* ----------------------------------------------------------
   7. SCROLLBAR CUSTOMISATION (Dark)
   ---------------------------------------------------------- */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.1);
  border-radius: 4px;
  border: 2px solid transparent;
  background-clip: content-box;
}

::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.18);
  background-clip: content-box;
}

::-webkit-scrollbar-corner {
  background: transparent;
}

/* Firefox */
* {
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.1) transparent;
}

/* ----------------------------------------------------------
   8. HELPER UTILITIES
   ---------------------------------------------------------- */

/* Text truncation */
.text-truncate {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.text-truncate-2 {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.text-truncate-3 {
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* Text colors */
.text-primary   { color: var(--color-text-primary)   !important; }
.text-secondary { color: var(--color-text-secondary) !important; }
.text-tertiary  { color: var(--color-text-tertiary)  !important; }
.text-accent    { color: var(--color-accent)         !important; }
.text-ok        { color: var(--color-ok)             !important; }
.text-warn      { color: var(--color-warn)           !important; }
.text-fail      { color: var(--color-fail)           !important; }
.text-info      { color: var(--color-info)           !important; }

/* Font utilities */
.font-mono { font-family: var(--font-mono) !important; }
.fw-400    { font-weight: 400 !important; }
.fw-500    { font-weight: 500 !important; }
.fw-600    { font-weight: 600 !important; }
.fw-700    { font-weight: 700 !important; }
.fw-800    { font-weight: 800 !important; }

/* Sizing */
.fs-xs  { font-size: var(--fs-xs)  !important; }
.fs-sm  { font-size: var(--fs-sm)  !important; }
.fs-base{ font-size: var(--fs-base)!important; }
.fs-md  { font-size: var(--fs-md)  !important; }
.fs-lg  { font-size: var(--fs-lg)  !important; }
.fs-xl  { font-size: var(--fs-xl)  !important; }
.fs-2xl { font-size: var(--fs-2xl) !important; }
.fs-3xl { font-size: var(--fs-3xl) !important; }

/* Display */
.d-none          { display: none          !important; }
.d-block         { display: block         !important; }
.d-flex          { display: flex          !important; }
.d-inline-flex   { display: inline-flex   !important; }
.d-grid          { display: grid          !important; }

/* Flex helpers */
.flex-1          { flex: 1               !important; }
.flex-wrap       { flex-wrap: wrap       !important; }
.flex-col        { flex-direction: column !important; }
.items-center    { align-items: center   !important; }
.items-start     { align-items: flex-start !important; }
.items-end       { align-items: flex-end !important; }
.justify-center  { justify-content: center        !important; }
.justify-between { justify-content: space-between  !important; }
.justify-end     { justify-content: flex-end       !important; }

/* Gap */
.gap-xs  { gap: 0.25rem !important; }
.gap-sm  { gap: 0.5rem  !important; }
.gap-md  { gap: 1rem    !important; }
.gap-lg  { gap: 1.5rem  !important; }
.gap-xl  { gap: 2rem    !important; }

/* Margin helpers */
.mb-0  { margin-bottom: 0       !important; }
.mb-xs { margin-bottom: 0.25rem !important; }
.mb-sm { margin-bottom: 0.5rem  !important; }
.mb-md { margin-bottom: 1rem    !important; }
.mb-lg { margin-bottom: 1.5rem  !important; }
.mb-xl { margin-bottom: 2rem    !important; }

.mt-0  { margin-top: 0       !important; }
.mt-xs { margin-top: 0.25rem !important; }
.mt-sm { margin-top: 0.5rem  !important; }
.mt-md { margin-top: 1rem    !important; }
.mt-lg { margin-top: 1.5rem  !important; }
.mt-xl { margin-top: 2rem    !important; }

/* Padding helpers */
.p-0  { padding: 0       !important; }
.p-sm { padding: 0.5rem  !important; }
.p-md { padding: 1rem    !important; }
.p-lg { padding: 1.5rem  !important; }
.p-xl { padding: 2rem    !important; }

/* Width */
.w-full { width: 100% !important; }

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

/* Cursor */
.cursor-pointer { cursor: pointer !important; }
.cursor-default { cursor: default !important; }

/* Selection */
.select-none { user-select: none !important; }

/* Border radius */
.rounded-full { border-radius: 9999px !important; }
.rounded-card { border-radius: var(--radius-card) !important; }

/* Divider line */
.divider {
  border: none;
  border-top: 1px solid var(--glass-border);
  margin: 1rem 0;
}

/* Responsive grid helper */
.grid-auto {
  display: grid;
  gap: 1rem;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
}

.grid-auto-sm {
  display: grid;
  gap: 0.75rem;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
}

/* ----------------------------------------------------------
   9. EMPTY STATE
   ---------------------------------------------------------- */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 3rem 1.5rem;
  text-align: center;
}

.empty-state__icon {
  font-size: 2.5rem;
  color: var(--color-text-tertiary);
  margin-bottom: 1rem;
  opacity: 0.5;
}

.empty-state__title {
  font-size: var(--fs-md);
  font-weight: 700;
  color: var(--color-text-secondary);
  margin-bottom: 0.375rem;
}

.empty-state__text {
  font-size: var(--fs-sm);
  color: var(--color-text-tertiary);
  max-width: 320px;
  margin-bottom: 1.25rem;
}

/* ----------------------------------------------------------
   10. TOOLTIP (simple CSS-only)
   ---------------------------------------------------------- */
[data-tooltip] {
  position: relative;
}

[data-tooltip]::after {
  content: attr(data-tooltip);
  position: absolute;
  bottom: calc(100% + 6px);
  left: 50%;
  transform: translateX(-50%) scale(0.92);
  padding: 0.3rem 0.625rem;
  background: rgba(15, 25, 35, 0.95);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-xs);
  color: var(--color-text-primary);
  font-size: var(--fs-xs);
  font-weight: 500;
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  transition:
    opacity var(--transition-fast),
    transform var(--transition-fast);
  z-index: 9000;
}

[data-tooltip]:hover::after {
  opacity: 1;
  transform: translateX(-50%) scale(1);
}

/* ----------------------------------------------------------
   11. TABS (glass variant)
   ---------------------------------------------------------- */
.glass-tabs {
  display: flex;
  gap: 0;
  border-bottom: 1px solid var(--glass-border);
  margin-bottom: 1.5rem;
  overflow-x: auto;
}

.glass-tab {
  padding: 0.625rem 1.125rem;
  font-size: var(--fs-sm);
  font-weight: 500;
  color: var(--color-text-tertiary);
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  cursor: pointer;
  white-space: nowrap;
  transition:
    color var(--transition-fast),
    border-color var(--transition-fast);
}

.glass-tab:hover {
  color: var(--color-text-secondary);
}

.glass-tab.active,
.glass-tab[aria-selected="true"] {
  color: var(--color-accent);
  border-bottom-color: var(--color-accent);
  font-weight: 600;
}

/* ----------------------------------------------------------
   12. BADGE COUNT (notification dot)
   ---------------------------------------------------------- */
.badge-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 9px;
  background: var(--color-fail);
  color: #fff;
  font-size: 0.625rem;
  font-weight: 700;
  line-height: 1;
}

.badge-count--accent {
  background: var(--color-accent);
}

.badge-count--muted {
  background: var(--glass-bg-strong);
  color: var(--color-text-secondary);
}

/* ----------------------------------------------------------
   13. RESPONSIVE VISIBILITY
   ---------------------------------------------------------- */
@media (max-width: 768px) {
  .hide-mobile { display: none !important; }
}

@media (min-width: 769px) {
  .hide-desktop { display: none !important; }
}

@media (max-width: 1024px) {
  .hide-tablet-down { display: none !important; }
}

/* ----------------------------------------------------------
   14. PRINT STYLES
   ---------------------------------------------------------- */
@media print {
  body {
    background: #fff;
    color: #000;
  }

  .glass-sidebar,
  .sidebar-toggle,
  .sidebar-overlay,
  .toast-container,
  .modal-overlay {
    display: none !important;
  }

  .main-content {
    margin-left: 0;
    padding: 0;
  }

  .glass-card,
  .journal-card,
  .category-card,
  .milestone-card {
    background: #fff;
    border: 1px solid #ddd;
    box-shadow: none;
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
  }

  .glass-card::before,
  .journal-card::before,
  .category-card::before,
  .milestone-card::before {
    display: none;
  }
}
