/* ==========================================================================
   GREEN LOGISTIC - SHARED STYLES
   --------------------------------------------------------------------------
   This file is loaded by BOTH the public website and the admin panel.
   It contains everything that must look identical in both places:

     1. Design tokens (colours, fonts, spacing, radius, shadows)
     2. Reset and base typography
     3. Layout helpers and brand logo
     4. Buttons
     5. Form fields
     6. Badges (status labels)
     7. Toast messages (flash messages)
     8. Utilities and accessibility helpers

   Page-specific styles live in:
     - site.css  (public website)
     - admin.css (admin panel)
   ========================================================================== */


/* ==========================================================================
   1. DESIGN TOKENS
   Change a value here and it updates everywhere on the website.
   ========================================================================== */
:root {
    /* ---- Brand green scale (600 is the original brand green #1f7a4d) ---- */
    --green-50:  #effaf3;
    --green-100: #d6f2e0;
    --green-200: #aee4c4;
    --green-300: #7bcf9f;
    --green-400: #46b377;
    --green-500: #2a9461;
    --green-600: #1f7a4d;   /* main brand colour */
    --green-700: #186241;
    --green-800: #124d34;
    --green-900: #0c3a27;   /* deep forest - hero / contact backgrounds */
    --green-950: #06241a;   /* darkest - footer / admin sidebar */

    /* ---- Accent: used only on dark green backgrounds for energy ---- */
    --lime:      #c8f25a;
    --lime-dark: #b4de3f;

    /* ---- Neutrals (slightly green-tinted so they sit well with the brand) ---- */
    --ink:     #0e1d16;     /* main text */
    --ink-2:   #3b4a43;     /* secondary text */
    --muted:   #5c6c64;     /* helper text (meets contrast on white) */
    --line:    #dbe6e0;     /* borders and dividers */
    --paper:   #f5faf7;     /* light section background */
    --surface: #ffffff;     /* cards */

    /* ---- WhatsApp keeps its own recognisable green ---- */
    --wa:      #25d366;
    --wa-dark: #1ebe5b;

    /* ---- Status colours (text + background pairs) ---- */
    --info-text:  #1d4ed8;
    --info-bg:    #e3ebff;
    --warn-text:  #8a5200;
    --warn-bg:    #fdf0d2;
    --danger-text:#b42318;
    --danger-bg:  #fde7e4;
    --neutral-text:#4b5a53;
    --neutral-bg: #e9efec;

    /* ---- Typography ---- */
    --font-display: "Bricolage Grotesque", "Figtree", system-ui, sans-serif;
    --font-body:    "Figtree", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;

    /* ---- Corner radius ---- */
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 20px;
    --radius-xl: 28px;

    /* ---- Shadows (tinted with brand green, never pure black) ---- */
    --shadow-sm: 0 1px 2px rgba(12, 58, 39, 0.06), 0 1px 3px rgba(12, 58, 39, 0.05);
    --shadow-md: 0 8px 24px rgba(12, 58, 39, 0.08);
    --shadow-lg: 0 24px 60px rgba(12, 58, 39, 0.16);

    /* ---- Layout ---- */
    --container: 1160px;
    --gutter: 20px;          /* side padding on phones */
    --header-h: 68px;        /* public sticky header height */

    /* ---- Motion ---- */
    --ease: cubic-bezier(0.22, 0.61, 0.36, 1);
}


/* ==========================================================================
   2. RESET AND BASE TYPOGRAPHY
   ========================================================================== */
*,
*::before,
*::after {
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
    /* Stops iOS from resizing text when the phone is rotated */
    -webkit-text-size-adjust: 100%;
    /* Anchor links stop below the sticky header instead of hiding under it */
    scroll-padding-top: calc(var(--header-h) + 12px);
}

body {
    margin: 0;
    font-family: var(--font-body);
    font-size: 1rem;
    line-height: 1.6;
    color: var(--ink);
    background: var(--surface);
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
}

h1,
h2,
h3,
h4 {
    margin: 0;
    font-family: var(--font-display);
    font-weight: 700;
    line-height: 1.1;
    letter-spacing: -0.02em;
    color: inherit;
}

p {
    margin: 0;
}

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

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

ul,
ol {
    margin: 0;
    padding: 0;
    list-style: none;
}

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

button {
    cursor: pointer;
}

small {
    color: var(--muted);
    font-size: 0.8125rem;
}

/* Small inline icons used across the site (drawn from the SVG sprite) */
.icon {
    width: 1.25em;
    height: 1.25em;
    flex: none;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.8;
    stroke-linecap: round;
    stroke-linejoin: round;
}


/* ==========================================================================
   3. LAYOUT HELPERS AND BRAND LOGO
   ========================================================================== */
.container {
    width: 100%;
    max-width: calc(var(--container) + var(--gutter) * 2);
    margin-inline: auto;
    padding-inline: var(--gutter);
}


/* ---- Brand logo (used in the public header/footer and the admin sidebar) ---- */
.brand {
    display: inline-flex;
    align-items: center;
    gap: 0.6rem;
    margin-right: auto;          /* pushes everything else to the right */
}

.brand__mark {
    width: 38px;
    height: 38px;
    flex: none;
}

.brand__name {
    font-family: var(--font-display);
    font-size: 1.25rem;
    font-weight: 800;
    letter-spacing: -0.02em;
    color: var(--ink);
}
.brand__name span {
    color: var(--green-600);
}

/* Light version of the logo for dark backgrounds (footer) */
.brand--light .brand__name {
    color: #fff;
}
.brand--light .brand__name span {
    color: var(--lime);
}


/* ==========================================================================
   4. BUTTONS
   Base class .btn + one colour variant + optional size/width modifiers.
   Example: <a class="btn btn--primary btn--block">
   ========================================================================== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    min-height: 48px;              /* comfortable touch target on phones */
    padding: 0.75rem 1.4rem;
    border: 1px solid transparent;
    border-radius: var(--radius-md);
    font-weight: 700;
    font-size: 1rem;
    line-height: 1.2;
    text-align: center;
    transition: background-color 0.18s var(--ease),
                border-color 0.18s var(--ease),
                transform 0.18s var(--ease),
                box-shadow 0.18s var(--ease);
}

.btn:active {
    transform: translateY(1px);
}

/* Main brand button */
.btn--primary {
    background: var(--green-600);
    color: #fff;
    box-shadow: 0 6px 16px rgba(31, 122, 77, 0.28);
}
.btn--primary:hover {
    background: var(--green-700);
}

/* Lime button - used only on dark green backgrounds */
.btn--lime {
    background: var(--lime);
    color: var(--green-950);
}
.btn--lime:hover {
    background: var(--lime-dark);
}

/* WhatsApp button */
.btn--whatsapp {
    background: var(--wa);
    color: var(--green-950);
}
.btn--whatsapp:hover {
    background: var(--wa-dark);
}

/* Outlined button for light backgrounds */
.btn--ghost {
    background: var(--surface);
    border-color: var(--line);
    color: var(--ink);
}
.btn--ghost:hover {
    border-color: var(--green-600);
    color: var(--green-700);
}

/* Outlined button for dark backgrounds */
.btn--ghost-light {
    background: rgba(255, 255, 255, 0.06);
    border-color: rgba(255, 255, 255, 0.28);
    color: #fff;
}
.btn--ghost-light:hover {
    background: rgba(255, 255, 255, 0.14);
}

/* Red outlined button for destructive actions (delete) */
.btn--danger {
    background: var(--surface);
    border-color: #f1c2bd;
    color: var(--danger-text);
}
.btn--danger:hover {
    background: var(--danger-bg);
}

/* Size and width modifiers */
.btn--sm {
    min-height: 38px;
    padding: 0.4rem 0.9rem;
    font-size: 0.875rem;
    border-radius: var(--radius-sm);
}
.btn--block {
    width: 100%;
}

/* Disabled / loading state (JS adds .is-loading while a form is submitting) */
.btn:disabled,
.btn.is-loading {
    opacity: 0.7;
    cursor: progress;
    pointer-events: none;
}


/* ==========================================================================
   5. FORM FIELDS
   Markup pattern used everywhere:

     <label class="field">
       <span class="field__label">Name</span>
       <input class="field__control" name="name">
     </label>
   ========================================================================== */
.field {
    display: block;
    margin-bottom: 1rem;
}

.field__label {
    display: block;
    margin-bottom: 0.4rem;
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--ink-2);
}

.field__control {
    display: block;
    width: 100%;
    min-height: 48px;
    padding: 0.7rem 0.9rem;
    background: var(--surface);
    border: 1px solid #cfdcd5;
    border-radius: var(--radius-md);
    /* 16px stops iPhones from zooming into the field when it is tapped */
    font-size: 1rem;
    transition: border-color 0.15s var(--ease), box-shadow 0.15s var(--ease);
}

.field__control::placeholder {
    color: #8a9a92;
}

.field__control:hover {
    border-color: var(--green-400);
}

.field__control:focus {
    outline: none;
    border-color: var(--green-600);
    box-shadow: 0 0 0 4px rgba(31, 122, 77, 0.16);
}

textarea.field__control {
    min-height: 96px;
    resize: vertical;
}

select.field__control {
    /* Custom dropdown arrow (the browser's default arrow is removed) */
    appearance: none;
    -webkit-appearance: none;
    padding-right: 2.5rem;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%231f7a4d' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.85rem center;
}

.field__hint {
    display: block;
    margin-top: 0.35rem;
    font-size: 0.8125rem;
    color: var(--muted);
}

/* Two columns on tablets and up, one column on phones */
.form-grid {
    display: grid;
    grid-template-columns: 1fr;
    column-gap: 1rem;
}

@media (min-width: 640px) {
    .form-grid {
        grid-template-columns: 1fr 1fr;
    }
    /* Add .field--wide to make a field span both columns */
    .form-grid .field--wide {
        grid-column: 1 / -1;
    }
}


/* ==========================================================================
   6. BADGES (status labels)
   The class name is built from the status text in the template, e.g.
   "Under Review" becomes .badge--under-review
   ========================================================================== */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.2rem 0.7rem;
    border-radius: 999px;
    font-size: 0.8125rem;
    font-weight: 700;
    white-space: nowrap;
    background: var(--neutral-bg);
    color: var(--neutral-text);
}

/* Small dot before the label */
.badge::before {
    content: "";
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: currentColor;
}

/* Positive / ready */
.badge--available,
.badge--approved,
.badge--completed,
.badge--active {
    background: var(--green-100);
    color: var(--green-800);
}

/* Needs attention */
.badge--pending,
.badge--new,
.badge--maintenance {
    background: var(--warn-bg);
    color: var(--warn-text);
}

/* In progress */
.badge--under-review,
.badge--contacted,
.badge--in-progress {
    background: var(--info-bg);
    color: var(--info-text);
}

/* Negative */
.badge--rejected {
    background: var(--danger-bg);
    color: var(--danger-text);
}

/* Switched off / finished */
.badge--inactive,
.badge--closed {
    background: var(--neutral-bg);
    color: var(--neutral-text);
}


/* ==========================================================================
   7. TOAST MESSAGES (flask flash messages)
   Rendered by partials/flash.html (public) and admin/base.html (admin).
   ========================================================================== */
.toast-stack {
    position: fixed;
    top: 12px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 100;
    display: grid;
    gap: 10px;
    width: min(440px, calc(100% - 24px));
}

.toast {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    padding: 0.85rem 0.9rem;
    border-radius: var(--radius-md);
    background: var(--green-900);
    color: #fff;
    font-size: 0.9375rem;
    font-weight: 500;
    box-shadow: var(--shadow-lg);
    animation: toast-in 0.35s var(--ease);
}

.toast .icon {
    margin-top: 0.1rem;
    color: var(--lime);
}

.toast__text {
    flex: 1;
}

.toast__close {
    flex: none;
    display: grid;
    place-items: center;
    width: 28px;
    height: 28px;
    margin: -4px -4px 0 0;
    padding: 0;
    background: transparent;
    border: 0;
    border-radius: 50%;
    color: inherit;
    opacity: 0.8;
}
.toast__close:hover {
    background: rgba(255, 255, 255, 0.15);
    opacity: 1;
}

.toast--error {
    background: #9b2c20;
}
.toast--error .icon {
    color: #ffd3cd;
}

/* JS adds this class just before removing the toast, for a smooth exit */
.toast.is-leaving {
    opacity: 0;
    transform: translateY(-8px);
    transition: opacity 0.25s ease, transform 0.25s ease;
}

@keyframes toast-in {
    from { opacity: 0; transform: translateY(-12px); }
    to   { opacity: 1; transform: translateY(0); }
}


/* ==========================================================================
   8. UTILITIES AND ACCESSIBILITY
   ========================================================================== */

/* Hides an element completely. main.js toggles this on the estimate result. */
.hidden {
    display: none !important;
}

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

/* Clear keyboard focus ring for everyone who navigates without a mouse */
:focus-visible {
    outline: 3px solid var(--green-400);
    outline-offset: 2px;
}

/* Respect the "reduce motion" setting on phones and computers */
@media (prefers-reduced-motion: reduce) {
    html {
        scroll-behavior: auto;
    }
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}
