/* =========================================================
   Functional/Layout Styles (uses variables from colors.css)
   ========================================================= */

* { box-sizing: border-box; }
html, body { height: 100%; }

body{
  margin:0;
  font-family: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial, "Apple Color Emoji","Segoe UI Emoji";
  color: var(--text-color);
  background:
    var(--bg-body-deco1),
    var(--bg-body-deco2),
    var(--bg-body);
  /* Center simple pages (e.g., auth) without using CSS Grid */
  display: flex;
  align-items: center;
  justify-content: center;
  min-height:100vh;
  flex-direction: column; /* keeps stacked content natural */
}

a{ color: var(--link-color); text-decoration: none; }
a:hover{ text-decoration: underline; }

/* Signed-in banner */
.topbar{
  position:fixed;
  top:10px;
  left:50%;
  transform:translateX(-50%);
  background: var(--topbar-bg);
  border: 1px solid var(--topbar-br);
  border-radius: 12px;
  padding: 8px 12px;
  box-shadow: var(--shadow-1);
}

/* Card */
.card{
  background: var(--card-bg);
  border: 1px solid var(--card-br);
  border-radius:16px;
  width:min(92vw, 420px);
  padding:24px 20px;
  box-shadow: var(--shadow-2);
}
@media (min-width: 480px){
  .card{ width: 440px; }
}

h1{ font-size:20px; margin:0 0 16px; }

/* Forms */
label{
  display:block;
  font-size:14px;
  margin:10px 0 6px;
  color: var(--ink-400);
}

input[type="email"],
input[type="password"],
input[type="text"]{
  width:100%;
  padding:12px;
  border-radius:10px;
  border:1px solid var(--input-br);
  background: var(--input-bg);
  color: var(--text-color);
  outline: none;
  transition: border-color .15s ease, box-shadow .15s ease, background .15s ease;
}
input::placeholder{ color: var(--ink-500); }
input:focus{
  border-color: var(--brand-accent);
  box-shadow: 0 0 0 3px rgba(29,197,239,0.25);
  background: var(--input-bg-focus);
}

/* Inline row */
.row{
  display:flex;
  align-items:center;
  justify-content:space-between;
  margin:10px 0 0;
  gap:10px;
}

/* Buttons */
.btn{
  -webkit-appearance: none;
  appearance: none;
  display:inline-flex;
  align-items:center;
  justify-content:center;
  gap:8px;
  border:none;
  border-radius:10px;
  padding:12px 16px;
  font-weight:600;
  cursor:pointer;
  color: var(--btn-primary-fg);
  background: var(--btn-primary-bg);
  box-shadow:
    inset 0 1px 0 rgba(255,255,255,0.20),
    0 6px 16px rgba(0,0,0,0.18);
  transition: transform .06s ease, box-shadow .15s ease, filter .15s ease;
}
.btn:hover{
  filter: brightness(1.05);
  box-shadow:
    inset 0 1px 0 rgba(255,255,255,0.28),
    0 8px 22px rgba(0,0,0,0.22);
}
.btn:active{ transform: translateY(1px); }

.btn.secondary{
  color: var(--btn-secondary-fg);
  background: var(--btn-secondary-bg);
  border: 1px solid var(--btn-secondary-br);
  box-shadow: none;
}
.btn.secondary:hover{ border-color: var(--brand-accent); }

/* Flash messages */
.flash{
  padding:10px 12px;
  border-radius:10px;
  margin-bottom:12px;
  border:1px solid transparent;
}
.flash.error{
  background: var(--error-bg);
  border-color: var(--error-br);
  color: var(--error-fg);
}
.flash.info{
  background: var(--info-bg);
  border-color: var(--info-br);
  color: var(--info-fg);
}

small{ color:#94a3b8; }

/* Toolbar for theme toggle (optional; used on index.php) */
.page-toolbar{
  position: fixed;
  top: 14px;
  right: 14px;
  display: flex;
  gap: 10px;
  z-index: 2;
}
.theme-toggle .label{ display:inline-block; margin-left:4px; font-weight:600; }
.theme-toggle .icon{ font-size: 14px; line-height: 1; }

/* Flush, full-width header pinned to the top */
.site-header{
  position: sticky; /* stays at top on scroll, but participates in flow */
  top: 0;
  left: 0;
  right: 0;
  width: 100%;
  margin: 0;                /* no outside spacing */
  background: var(--topbar-bg);
  border-bottom: 1px solid var(--topbar-br);
  z-index: 100;
}
.site-header .header-inner{
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 16px;       /* inner breathing room */
}

/* Nav links */
.nav-list{ display:flex; align-items:center; gap:16px; list-style:none; margin:0; padding:0; }
.nav-list a{
  color: var(--link-color);
  padding: 8px 10px;
  border-radius: 10px;
  text-decoration: none;
}
.nav-list a:hover{ background: rgba(29,197,239,0.10); }

/* Right-side actions */
.header-actions{ display:flex; align-items:center; gap:10px; }

/* Make body layout not center everything on pages with header */
body.has-header{
  display: block;          /* override the flex centering */
  min-height: 100vh;
}

/* Main area spacing under the header */
.page-main{
  display: flex;
  justify-content: center;
  padding: 24px 16px;
}

/* Avatar (profile/account) */
.avatar{
  display:inline-flex;
  align-items:center;
  justify-content:center;
  width:36px;
  height:36px;
  border-radius:9999px;
  text-decoration:none;
  font-weight:700;
  font-size:13px;
  letter-spacing:.3px;
  color:#fff;
  background: linear-gradient(180deg, var(--indigo-500), var(--brand-primary));
  border:1px solid var(--topbar-br);
  box-shadow: var(--shadow-1);
}
.avatar:hover{
  filter: brightness(1.06);
}
.header-actions{ display:flex; align-items:center; gap:10px; } /* ensures spacing around avatar */
/* A11y helper */
.sr-only{
  position:absolute !important; width:1px; height:1px; padding:0; margin:-1px;
  overflow:hidden; clip:rect(0,0,0,0); white-space:nowrap; border:0;
}

/* Base tweaks */
.site-header .menu-toggle{ display:none; }

@media (max-width: 720px){
  .site-header .menu-toggle{ display:inline-flex; }

  /* Drawer (fully hidden & non-interactive by default) */
  #primaryNav{
    position: fixed;
    top: 0; left: 0;
    height: 100dvh;
    width: min(84vw, 320px);
    background: var(--topbar-bg);
    border-right: 1px solid var(--topbar-br);
    box-shadow: 0 10px 30px rgba(0,0,0,.25);
    transform: translateX(-100%);
    transition: transform .22s ease-out, visibility 0s linear .22s;
    z-index: 1100;
    padding-top: 64px;

    /* hide-before-open safeguards */
    visibility: hidden;           /* no paint */
    pointer-events: none;         /* no clicks */
    opacity: 0;                   /* belt + suspenders for some UAs */
  }

  /* Drawer content */
  #primaryNav .nav-list{
    display:flex; flex-direction:column;
    gap:4px; padding:12px;
  }
  #primaryNav .nav-list a{ display:block; padding:12px 14px; border-radius:12px; }

  /* Backdrop */
  .site-header .nav-backdrop{
    position: fixed; inset:0;
    background: rgba(8,12,32,.45);
    -webkit-backdrop-filter: blur(2px);
    backdrop-filter: blur(2px);
    z-index: 1090;
    display:none;
  }

  /* When open */
  .nav-open #primaryNav{
    transform: translateX(0);
    visibility: visible;
    pointer-events: auto;
    opacity: 1;
    transition: transform .22s ease-out;
  }
  .nav-open .site-header .nav-backdrop{ display:block; }

  /* keep header bar compact */
  .site-header .header-actions .signout{ padding:10px 12px; }
  .site-header .theme-toggle .label{ display:none; }
  
  .header-actions .signout{
    position: relative;
    width: 36px;
    height: 36px;
    padding: 0;
    font-size: 0;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center; /* true center alignment */
  }
  .header-actions .signout::before{
    content: "⏻";
    font-size: 18px;
    line-height: 1;
    color: var(--btn-secondary-fg);
    display: inline-block;
    transform: translateY(1px); /* ↓ adjust vertical centering */
  }
  .header-actions .signout:hover::before{
    color: var(--brand-accent);
  }
}


@media (max-width: 380px){
  .avatar{ width:32px; height:32px; font-size:12px; }
  .site-header .header-inner{ padding:10px 12px; }
}

/* --- Normalize action buttons (desktop) --- */
.header-actions .btn,
.header-actions .signout,
.header-actions .theme-toggle{
  height: 36px;           /* same height */
  padding: 8px 12px;      /* same padding */
  line-height: 1;         /* avoid icon stretching */
  border-radius: 10px;
}

/* Tweak icon alignment on desktop */
.header-actions .theme-toggle .icon{ font-size: 16px; transform: translateY(1px); }

/* --- Mobile: make both true icon buttons (same square size) --- */
@media (max-width: 720px){
  .header-actions .theme-toggle,
  .header-actions .signout{
    width: 36px;
    height: 36px;
    padding: 0;                   /* kill default .btn padding */
    display: inline-flex;
    align-items: center;
    justify-content: center;      /* perfect center */
    gap: 0;                       /* no icon/label gap */
  }

  /* Hide theme label and size the icon */
  .site-header .theme-toggle .label{ display:none; }
  .header-actions .theme-toggle .icon{ font-size: 18px; transform: translateY(1px); }

  /* Signout already uses ::before; ensure same visual weight */
  .header-actions .signout{ font-size: 0; } /* hide link text on mobile */
  .header-actions .signout::before{
    content: "⏻";
    font-size: 18px;
    line-height: 1;
    transform: translateY(1px);
    color: var(--btn-secondary-fg);
  }
  .header-actions .signout:hover::before{ color: var(--brand-accent); }
}
