/* ============================================================
   Tiphys global theme — "Aegean" dark-nautical
   ------------------------------------------------------------
   One palette to rule them all: every per-page stylesheet draws
   its colors from the tokens below, so the whole app stays in
   sync. Add new colors here as tokens, not as one-off hex values
   in page CSS. Headings use Cinzel (loaded in base.html); body
   stays on the system sans for speed + legibility.
   ============================================================ */
:root {
    color-scheme: dark;             /* native controls (scrollbars, selects, arrows) render dark */

    --font-display: "Cinzel", Georgia, "Times New Roman", serif;
    --font-body: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;

    /* ---- Surfaces (deep Aegean navy) ---- */
    --bg:          #081726;   /* page base */
    --bg-2:        #0c2236;   /* gradient stop / glow */
    --surface:     #0f2742;   /* cards, header */
    --surface-2:   #143052;   /* inputs, nested panels, chips */
    --surface-3:   #1b3c61;   /* hover, raised chips */
    --accent-soft: rgba(86, 212, 212, 0.12);  /* subtle teal tint bg */

    /* ---- Lines ---- */
    --border:      #21405f;   /* default 1px borders */
    --border-bright: #356f93; /* card frames, emphasis */
    --divider:     #16314e;   /* faint row dividers inside surfaces */

    /* ---- Ink ---- */
    --text:        #e6eef6;   /* primary text */
    --text-2:      #c0d2e2;   /* secondary / labels */
    --muted:       #8aa4bb;   /* hints, captions */
    --heading:     #f1f7fc;   /* Cinzel headings */
    --on-accent:   #ffffff;   /* text on filled buttons */

    /* ---- Accent: cyan / teal (the glow) ---- */
    --accent:        #56d4d4;
    --accent-hover:  #7ce6e6;
    --accent-ring:   rgba(86, 212, 212, 0.40);
    --ornament:      #5ea3c2; /* Greek-key + wave linework */

    /* ---- Primary action: harbor green ---- */
    --cta:        #2bc46c;
    --cta-2:      #23a85c;
    --cta-hover:  #34d97c;

    /* ---- Status families (dark-tuned) ---- */
    --success-bg: rgba(43, 196, 108, 0.15); --success-fg: #57e08e; --success-border: rgba(43, 196, 108, 0.45);
    --warn-bg:    rgba(224, 184, 96, 0.15);  --warn-fg: #e8c372;    --warn-border: rgba(224, 184, 96, 0.45);
    --error-bg:   rgba(224, 96, 86, 0.15);   --error-fg: #f0938a;   --error-border: rgba(224, 96, 86, 0.45);
    --purple-bg:  rgba(154, 122, 224, 0.16); --purple-fg: #c2aef0;

    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.30);
    --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.40);
    --shadow-lg: 0 16px 48px rgba(0, 0, 0, 0.50);

    /* Greek-key meander tile (vertical, repeats down page edges). */
    --meander: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='26' height='26' viewBox='0 0 26 26'%3E%3Cpath d='M3 0V26M3 4H20V22H7V9H15V15' fill='none' stroke='%235ea3c2' stroke-width='2'/%3E%3C/svg%3E");
    /* Wave tile (horizontal, card-foot accents). */
    --wave: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='80' height='14' viewBox='0 0 80 14'%3E%3Cpath d='M0 7 Q 20 0 40 7 T 80 7' fill='none' stroke='%235ea3c2' stroke-width='1.5'/%3E%3C/svg%3E");
}

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

body {
    font-family: var(--font-body);
    margin: 0; padding: 0;
    color: var(--text);
    background-color: var(--bg);
    background-image:
        radial-gradient(1100px 600px at 50% -8%, var(--bg-2), transparent 70%),
        radial-gradient(900px 500px at 90% 110%, rgba(86, 212, 212, 0.06), transparent 70%);
    background-attachment: fixed;
    min-height: 100vh;
}

/* Greek-key frame down the page edges — decorative, non-interactive.
   Hidden on small screens (no room); shown from 1100px up. */
body::before, body::after {
    content: ""; position: fixed; top: 0; bottom: 0; width: 26px;
    background-image: var(--meander); background-repeat: repeat-y;
    opacity: 0.22; pointer-events: none; z-index: 0;
}
body::before { left: 6px; }
body::after  { right: 6px; transform: scaleX(-1); }
@media (max-width: 1099px) { body::before, body::after { display: none; } }

a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-hover); text-decoration: underline; }

/* ---- Typography ---- */
h1, h2, h3 { font-family: var(--font-display); color: var(--heading); }
h1 { font-size: 24px; font-weight: 700; letter-spacing: 0.5px; margin: 0 0 14px; }
h2 { font-size: 16px; margin: 0 0 14px; color: var(--heading); font-weight: 600;
     text-transform: uppercase; letter-spacing: 1px; }
h3 { font-size: 15px; margin: 0 0 8px; }

/* ============================================================
   Header — sticky, transparent over the navy with a teal hairline.
   Brand logo is the light (knockout) variant so it reads on dark.
   ============================================================ */
header { background: rgba(8, 23, 38, 0.82); backdrop-filter: blur(8px);
         border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 100; }
.header-inner { max-width: 1200px; margin: 0 auto; padding: 12px 16px;
                display: flex; flex-wrap: wrap; justify-content: space-between;
                align-items: center; gap: 8px; }
header .brand a { display: inline-flex; flex-direction: column; align-items: flex-start;
                  gap: 3px; color: var(--heading); text-decoration: none; }
header .brand img.logo { height: 60px; width: auto; display: block; }
header .brand .tagline { display: none; font-family: var(--font-display);
                         font-weight: 400; font-size: 14px; color: var(--heading);
                         font-style: italic; }

.nav-toggle { display: inline-flex; align-items: center; justify-content: center;
              width: 40px; height: 40px; border: 1px solid var(--border);
              border-radius: 6px; background: var(--surface-2); cursor: pointer;
              padding: 0; color: var(--text); }
.nav-toggle:hover { border-color: var(--accent); color: var(--accent); }
.nav-toggle svg { display: block; }

header nav { display: none; flex-basis: 100%; flex-direction: column;
             align-items: stretch; padding-top: 8px; }
header nav.open { display: flex; }
header .nav-links, header .nav-account { display: flex; flex-direction: column;
             align-items: stretch; }
header nav a { padding: 11px 4px; color: var(--text-2); text-decoration: none;
               font-size: 15px; text-transform: capitalize;
               border-bottom: 1px solid var(--divider); }
header .nav-account a:last-child { border-bottom: 0; }
header nav a:hover { color: var(--accent); text-decoration: none; }
header .user { padding: 11px 4px; font-size: 14px; color: var(--text);
               border-bottom: 1px solid var(--divider); }

main { max-width: 1200px; margin: 22px auto; padding: 0 16px; position: relative; z-index: 1; }

/* ============================================================
   Cards — dark surface, teal-tinted frame, soft lift.
   ============================================================ */
.card { background: linear-gradient(180deg, rgba(255,255,255,0.02), rgba(0,0,0,0.04)), var(--surface);
        border: 1px solid var(--border); border-radius: 10px;
        padding: 16px 18px; margin-bottom: 16px; box-shadow: var(--shadow-sm); }

/* Card-header icon slot: <h2><span class="ico">…</span> Title</h2>.
   The .ico holds an inline SVG sized to the heading. */
h2 .ico, h3 .ico { display: inline-flex; vertical-align: -3px; margin-right: 8px;
                   color: var(--accent); }
h2 .ico svg, h3 .ico svg { width: 20px; height: 20px; display: block; }

/* Wave foot accent — add class "wave-foot" to a card to get the
   classical wave band along its bottom edge. */
.wave-foot { position: relative; overflow: hidden; }
.wave-foot::after { content: ""; position: absolute; left: 0; right: 0; bottom: 0;
                    height: 14px; background-image: var(--wave); background-repeat: repeat-x;
                    opacity: 0.30; pointer-events: none; }

/* ---- Pills / role badges ---- */
.pill { display: inline-block; padding: 2px 10px; border-radius: 12px;
        font-size: 12px; background: var(--accent-soft); color: var(--accent);
        font-weight: 600; border: 1px solid var(--border); }
.pill.admin       { background: var(--error-bg);   color: var(--error-fg);   border-color: var(--error-border); }
.pill.sales_rep   { background: var(--accent-soft); color: var(--accent);     border-color: var(--border-bright); }
.pill.partner     { background: var(--purple-bg);   color: var(--purple-fg);  border-color: transparent; }
.pill.warehouse   { background: var(--success-bg);  color: var(--success-fg); border-color: var(--success-border); }
.pill.rate_ship   { background: var(--warn-bg);     color: var(--warn-fg);    border-color: transparent; }

/* ============================================================
   Buttons — primary = harbor-green CTA, secondary = teal outline.
   ============================================================ */
a.button, button.button {
    display: inline-block; padding: 10px 20px;
    background: linear-gradient(180deg, var(--cta), var(--cta-2));
    color: var(--on-accent); text-decoration: none; border: 0; border-radius: 7px;
    font-size: 14px; font-weight: 600; cursor: pointer;
    box-shadow: 0 2px 10px rgba(43, 196, 108, 0.25);
    transition: filter 0.15s, box-shadow 0.15s, transform 0.05s;
}
a.button:hover, button.button:hover { filter: brightness(1.08);
    box-shadow: 0 4px 16px rgba(43, 196, 108, 0.38); text-decoration: none; }
a.button:active, button.button:active { transform: translateY(1px); }
a.button.secondary, button.button.secondary {
    background: transparent; color: var(--accent); border: 1px solid var(--border-bright);
    box-shadow: none; }
a.button.secondary:hover, button.button.secondary:hover {
    background: var(--accent-soft); border-color: var(--accent); filter: none; }

/* ============================================================
   Tables
   ============================================================ */
.table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 9px 11px; border-bottom: 1px solid var(--divider);
         font-size: 14px; vertical-align: top; color: var(--text); }
th { color: var(--muted); font-weight: 600; font-size: 12px; text-transform: uppercase;
     letter-spacing: 0.6px; }
code { background: var(--surface-2); padding: 1px 5px; border-radius: 3px;
       font-size: 12px; color: var(--accent); }
.muted { color: var(--muted); font-size: 13px; }

/* ---- Tiles (dashboard / settings index) ---- */
.tiles { display: grid; grid-template-columns: 1fr; gap: 12px; margin-top: 16px; }
.tile { display: block; background: var(--surface); border: 1px solid var(--border);
        border-radius: 10px; padding: 16px 18px; color: inherit; text-decoration: none;
        box-shadow: var(--shadow-sm);
        transition: border-color 0.15s, box-shadow 0.15s, transform 0.05s; }
.tile:hover { border-color: var(--border-bright); box-shadow: var(--shadow-md);
              transform: translateY(-1px); text-decoration: none; }
.tile.disabled { opacity: 0.5; pointer-events: none; }
.tile h3 { margin: 0 0 6px; font-size: 16px; color: var(--heading); }
.tile p { margin: 0; font-size: 13px; color: var(--muted); font-family: var(--font-body); }

/* ---- Flashes ---- */
.flash { padding: 11px 15px; margin-bottom: 14px; border-radius: 7px; border: 1px solid transparent; }
.flash.success { background: var(--success-bg); color: var(--success-fg); border-color: var(--success-border); }
.flash.warn    { background: var(--warn-bg);    color: var(--warn-fg);    border-color: var(--warn-border); }
.flash.error   { background: var(--error-bg);   color: var(--error-fg);   border-color: var(--error-border); }

/* ============================================================
   Forms — mobile first: labels stack above inputs, full-width.
   ============================================================ */
form .row { display: flex; flex-direction: column; gap: 6px; margin-bottom: 12px;
            align-items: stretch; }
form label { font-size: 13px; color: var(--text-2); }
form input[type=text], form input[type=email], form input[type=password],
form input[type=number], form select, form textarea {
    padding: 9px 11px; border: 1px solid var(--border); border-radius: 6px;
    font-size: 16px; /* 16px prevents iOS auto-zoom on focus */
    width: 100%; max-width: 100%; box-sizing: border-box;
    background: var(--surface-2); color: var(--text);
}
form input::placeholder, .field input::placeholder { color: var(--muted); }
form input:focus, form select:focus, form textarea:focus {
    outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-ring);
}
input[type=checkbox], input[type=radio] { accent-color: var(--accent); }

/* Desktop layout */
@media (min-width: 768px) {
    .header-inner { padding: 14px 24px; flex-wrap: nowrap; }
    header .brand .tagline { display: block; }
    .nav-toggle { display: none; }
    header nav { display: flex; flex: 1; flex-basis: auto; flex-direction: row;
                 align-items: center; padding-top: 0; }
    header .nav-links { flex-direction: row; align-items: center; gap: 20px; margin-left: 28px; }
    header .nav-account { flex-direction: row; align-items: center; gap: 20px; margin-left: auto; }
    header nav a { margin: 0; padding: 4px 0; font-size: 14px; border-bottom: 0; }
    header .user { margin: 0; padding: 0; border-bottom: 0; }
    main { margin: 30px auto; padding: 0 24px; }
    h1 { font-size: 26px; margin: 0 0 18px; }
    .card { padding: 22px 26px; margin-bottom: 18px; }
    .tiles { grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 16px; }
    .tile { padding: 20px 22px; }
    form .row { flex-direction: row; gap: 12px; align-items: center; }
    form label { min-width: 140px; }
    form input[type=text], form input[type=email], form input[type=password],
    form input[type=number], form select, form textarea {
        font-size: 14px; padding: 8px 11px; width: auto; min-width: 280px;
    }
}
