/* =========================================================
   ZINC v1 - Base Application Styles
   ---------------------------------------------------------
   Structure:
   1. Theme variables
   2. Reset / base
   3. Typography / links
   4. Layout
   5. Cards / containers
   6. Flash messages
   7. Forms
   8. Checkbox row controls
   9. Buttons
   10. Tables
   11. Dashboard metrics
   12. Detail pages
   13. Branding preview
   14. Utility page headers
   15. Sidebar states
   16. Auth pages
   17. Responsive rules
   18. Organisation
   ========================================================= */


/* =========================================================
   1. Theme Variables
   ---------------------------------------------------------
   Central place for colours, spacing, radius, shadows.
   Update these first before changing component rules.
   ========================================================= */
:root {
    --brand-primary: #111827;
    --brand-primary-hover: #1f2937;
    --brand-secondary: #6b7280;
    --brand-accent: #1f2937;
    --brand-text: #1f2937;
    --brand-surface: #ffffff;

    --zinc-bg: #f7f7f8;
    --zinc-border: #d9dde3;
    --zinc-text: var(--brand-text);
    --zinc-text-muted: #6b7280;
    --zinc-heading: var(--brand-primary);

    --zinc-link: var(--brand-primary);
    --zinc-link-hover: #000000;

    --zinc-button-bg: var(--brand-primary);
    --zinc-button-text: #ffffff;
    --zinc-button-hover: var(--brand-accent);

    --zinc-success-bg: #e8f7ed;
    --zinc-success-text: #1f5130;
    --zinc-error-bg: #fdecec;
    --zinc-error-text: #7f1d1d;
    --zinc-warning-bg: #fff7e6;
    --zinc-warning-text: #7c4a03;

    --zinc-shadow: 0 2px 12px rgba(0, 0, 0, 0.06);

    --zinc-radius: 10px;
    --zinc-radius-sm: 6px;

    --zinc-space-1: 8px;
    --zinc-space-2: 12px;
    --zinc-space-3: 16px;
    --zinc-space-4: 20px;
    --zinc-space-5: 24px;
    --zinc-space-6: 32px;
}


/* =========================================================
   2. Reset / Base
   ---------------------------------------------------------
   Basic box sizing and page defaults.
   ========================================================= */
*,
*::before,
*::after {
    box-sizing: border-box;
}

html,
body {
    margin: 0;
    padding: 0;
}

body {
    background: var(--zinc-bg);
    color: var(--zinc-text);
    font-family: Arial, sans-serif;
    font-size: 14px;
    line-height: 1.5;
}


/* =========================================================
   3. Typography / Links
   ---------------------------------------------------------
   Global heading, paragraph and link styles.
   ========================================================= */
a {
    color: var(--zinc-link);
    text-decoration: none;
}

a:hover {
    color: var(--zinc-link-hover);
    text-decoration: underline;
}

h1,
h2,
h3,
h4,
h5,
h6 {
    color: var(--zinc-heading);
    margin-top: 0;
}

p {
    margin-top: 0;
}


/* =========================================================
   4. Layout
   ---------------------------------------------------------
   Main shell, sidebar, primary content area.
   ========================================================= */
.shell {
    display: grid;
    grid-template-columns: 240px minmax(0, 1fr);
    min-height: 100vh;
}

.sidebar {
    background: var(--brand-primary);
    color: #ffffff;
    padding: 20px;
}

.main {
    min-width: 0;
    padding: 24px;
}

.page-shell {
    width: 100%;
    max-width: none;
    margin: 0;
    padding: var(--zinc-space-5);
    box-sizing: border-box;
}

/* =========================================================
   5. Cards / Containers
   ---------------------------------------------------------
   Reusable content containers used throughout the UI.
   ========================================================= */
.card {
    background: var(--brand-surface);
    border: 1px solid var(--zinc-border);
    border-radius: var(--zinc-radius);
    box-shadow: var(--zinc-shadow);
    padding: var(--zinc-space-5);
    margin-bottom: var(--zinc-space-5);
}

.empty-state {
    padding: var(--zinc-space-4);
    border: 1px dashed var(--zinc-border);
    border-radius: var(--zinc-radius-sm);
    color: var(--zinc-text-muted);
    background: #fcfcfc;
}


/* =========================================================
   6. Flash Messages
   ---------------------------------------------------------
   Success / error / warning banners.
   ========================================================= */
.flash {
    border-radius: var(--zinc-radius-sm);
    padding: var(--zinc-space-3);
    margin-bottom: var(--zinc-space-4);
}

.flash.success {
    background: var(--zinc-success-bg);
    color: var(--zinc-success-text);
}

.flash.error {
    background: var(--zinc-error-bg);
    color: var(--zinc-error-text);
}

.flash.warning {
    background: var(--zinc-warning-bg);
    color: var(--zinc-warning-text);
}


/* =========================================================
   7. Forms
   ---------------------------------------------------------
   Labels, fields, help text, actions and form layouts.
   ========================================================= */
label {
    display: block;
    margin-bottom: 6px;
    font-weight: 600;
    color: var(--zinc-heading);
}

input,
select,
textarea {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--zinc-border);
    border-radius: var(--zinc-radius-sm);
    font: inherit;
    color: var(--zinc-text);
    background: #fff;
}

textarea {
    min-height: 120px;
    resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
    outline: none;
    border-color: #9ca3af;
    box-shadow: 0 0 0 3px rgba(17, 24, 39, 0.08);
}

.form-grid {
    display: grid;
    gap: var(--zinc-space-4);
    max-width: 760px;
}

.form-actions {
    display: flex;
    gap: var(--zinc-space-3);
    align-items: center;
    flex-wrap: wrap;
}

.form-help {
    display: block;
    margin-top: 6px;
    color: var(--zinc-text-muted);
    font-size: 12px;
}


/* =========================================================
   8. Checkbox Row Controls
   ---------------------------------------------------------
   Used for larger, easier-to-click checkbox rows in forms.
   Markup pattern:
   <label class="checkbox-row">
       <input type="checkbox">
       <span>Label text</span>
   </label>
   ========================================================= */
.checkbox-row {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 14px;
    border: 1px solid var(--zinc-border);
    border-radius: var(--zinc-radius-sm);
    background: #fff;
    cursor: pointer;
    min-height: 48px;
    margin-bottom: 0;
}

.checkbox-row input[type="checkbox"] {
    width: 22px;
    height: 22px;
    margin: 0;
    accent-color: var(--brand-primary);
    cursor: pointer;
    flex: 0 0 22px;
}

.checkbox-row span {
    margin: 0;
    font-weight: 600;
    cursor: pointer;
    flex: 1 1 auto;
    color: var(--zinc-heading);
    line-height: 1.4;
}

.checkbox-row:hover {
    background: #f8fafc;
    border-color: #b8c2cc;
}

.checkbox-cell {
    display: flex;
    align-items: end;
}


/* =========================================================
   9. Buttons
   ---------------------------------------------------------
   Includes:
   - legacy button styling: button, .button, a.button
   - new CTA button styling: .btn, .btn-primary, .btn-secondary
   ========================================================= */

/* Legacy button system */
button,
.button,
a.button {
    display: inline-block;
    padding: 10px 16px;
    border: 0;
    border-radius: var(--zinc-radius-sm);
    background: var(--zinc-button-bg);
    color: var(--zinc-button-text);
    font: inherit;
    cursor: pointer;
    text-decoration: none;
}

button:hover,
.button:hover,
a.button:hover {
    background: var(--zinc-button-hover);
    color: var(--zinc-button-text);
    text-decoration: none;
}

.button.secondary,
a.button.secondary {
    background: #e5e7eb;
    color: #111827;
}

.button.secondary:hover,
a.button.secondary:hover {
    background: #d1d5db;
    color: #111827;
    text-decoration: none;
}

/* New button system */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 42px;
    padding: 0 16px;
    border-radius: var(--zinc-radius-sm);
    border: 1px solid transparent;
    font-weight: 600;
    text-decoration: none;
    cursor: pointer;
    transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.btn:link,
.btn:visited,
.btn:hover,
.btn:active {
    text-decoration: none;
}

.btn-primary,
.btn-primary:link,
.btn-primary:visited {
    background: var(--brand-primary);
    color: #ffffff;
    border-color: var(--brand-primary);
}

.btn-primary:hover,
.btn-primary:active,
.btn-primary:focus {
    background: var(--brand-primary-hover);
    color: #ffffff;
    border-color: var(--brand-primary-hover);
}

.btn-secondary,
.btn-secondary:link,
.btn-secondary:visited {
    background: #ffffff;
    color: var(--zinc-heading);
    border-color: var(--zinc-border);
}

.btn-secondary:hover,
.btn-secondary:active,
.btn-secondary:focus {
    background: #f8fafc;
    color: var(--zinc-heading);
    border-color: var(--zinc-border);
}


/* =========================================================
   10. Tables
   ---------------------------------------------------------
   Standard table wrapper and cell styling.
   ========================================================= */
.table-wrap {
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
    background: #fff;
}

th,
td {
    text-align: left;
    padding: 12px 10px;
    border-bottom: 1px solid var(--zinc-border);
    vertical-align: top;
}

th {
    color: var(--zinc-heading);
    font-size: 13px;
    background: #fafafa;
}
.table-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.btn-sm {
    min-height: 34px;
    padding: 0 12px;
    font-size: 13px;
}

/* =========================================================
   11. Dashboard Metrics
   ---------------------------------------------------------
   Summary cards used on dashboard screens.
   ========================================================= */
.metrics {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 12px;
    margin-bottom: 20px;
}

.metric {
    background: var(--brand-surface);
    padding: 16px;
    border-radius: 8px;
    box-shadow: var(--zinc-shadow);
    border: 1px solid var(--zinc-border);
    min-height: 96px;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.metric strong {
    display: block;
    margin-bottom: 6px;
    color: var(--zinc-heading);
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.metric-value {
    font-size: 28px;
    font-weight: 700;
    color: var(--zinc-heading);
    line-height: 1.2;
    margin-top: 4px;
}


/* =========================================================
   12. Detail Pages
   ---------------------------------------------------------
   Used on "show/view" type pages with labelled fields.
   ========================================================= */
.detail-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: var(--zinc-space-4);
    margin-bottom: var(--zinc-space-5);
    flex-wrap: wrap;
}

.detail-header p {
    margin-bottom: 0;
    color: var(--zinc-text-muted);
}

.detail-actions {
    display: flex;
    gap: var(--zinc-space-3);
    align-items: center;
    flex-wrap: wrap;
}

.detail-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(240px, 1fr));
    gap: var(--zinc-space-4) var(--zinc-space-5);
}

.detail-item strong {
    display: block;
    margin-bottom: 4px;
    color: var(--zinc-heading);
}

.detail-item div {
    color: var(--zinc-text);
    word-break: break-word;
}

.detail-meta {
    color: var(--zinc-text-muted);
}

.muted-value {
    color: var(--zinc-text-muted);
    font-style: italic;
}

.status-pill {
    display: inline-flex;
    align-items: center;
    padding: 4px 10px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 600;
    line-height: 1.2;
    background: #eef2f7;
    color: #334155;
}

.status-pill.success {
    background: #e8f7ed;
    color: #1f5130;
}

.status-pill.neutral {
    background: #eef2f7;
    color: #334155;
}

.status-pill.warning {
    background: #fff7e6;
    color: #7c4a03;
}

.status-pill.danger {
    background: #fdecec;
    color: #7f1d1d;
}


/* =========================================================
   13. Branding / White-Label Settings
   ---------------------------------------------------------
   Used on branding settings pages, including:
   - identity fields
   - logo upload / preview
   - horizontal colour controls
   - live UI preview
   ========================================================= */

.branding-form-stack {
    display: grid;
    gap: 24px;
}

.branding-section-card {
    margin-bottom: 0;
}

.branding-section-card h2 {
    margin-bottom: 16px;
}

.branding-preview {
    padding: 12px;
    border: 1px solid var(--zinc-border);
    border-radius: var(--zinc-radius-sm);
    background: #fff;
}

.branding-preview-logo {
    display: block;
    max-width: 220px;
    width: 100%;
    height: auto;
}

.branding-settings-grid {
    display: grid;
    gap: 16px;
}

.branding-setting-row {
    display: grid;
    grid-template-columns: minmax(220px, 280px) minmax(0, 1fr);
    gap: 16px;
    align-items: center;
    padding: 14px 0;
    border-bottom: 1px solid var(--zinc-border);
}

.branding-setting-row:last-child {
    border-bottom: 0;
    padding-bottom: 0;
}

.branding-setting-label label {
    margin-bottom: 4px;
}

.branding-setting-label .form-help {
    margin-top: 0;
}

.branding-setting-control {
    display: grid;
    grid-template-columns: 64px minmax(0, 180px);
    gap: 12px;
    align-items: center;
}

.branding-setting-control input[type="text"] {
    min-width: 0;
}

.branding-colour-picker {
    width: 64px;
    height: 44px;
    padding: 4px;
    border: 1px solid var(--zinc-border);
    border-radius: var(--zinc-radius-sm);
    background: #fff;
    cursor: pointer;
}

.branding-live-preview {
    display: grid;
    grid-template-columns: 220px 1fr;
    min-height: 220px;
    border: 1px solid var(--zinc-border);
    border-radius: var(--zinc-radius);
    overflow: hidden;
    background: var(--preview-surface, #ffffff);
}

.branding-live-preview-sidebar {
    background: var(--preview-primary, #111827);
    color: #ffffff;
    padding: 18px;
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.branding-live-preview-brand {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.branding-live-preview-logo {
    display: block;
    max-width: 150px;
    width: 100%;
    height: auto;
}

.branding-live-preview-title {
    font-size: 20px;
    font-weight: 700;
    color: #ffffff;
    line-height: 1.2;
}

.branding-live-preview-tagline {
    font-size: 13px;
    color: rgba(255, 255, 255, 0.8);
    line-height: 1.4;
}

.branding-live-preview-nav {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 8px;
    font-size: 14px;
    color: rgba(255, 255, 255, 0.9);
}

.branding-live-preview-main {
    padding: 18px;
    background: var(--preview-surface, #ffffff);
    color: var(--preview-text, #1f2937);
}

.branding-live-preview-card {
    background: var(--preview-surface, #ffffff);
    border: 1px solid var(--zinc-border);
    border-radius: var(--zinc-radius-sm);
    padding: 16px;
    box-shadow: var(--zinc-shadow);
}

.branding-live-preview-logo.is-hidden,
.branding-live-preview-title.is-hidden {
    display: none;
}

@media (max-width: 768px) {
    .branding-setting-row {
        grid-template-columns: 1fr;
        align-items: start;
    }

    .branding-setting-control {
        grid-template-columns: 64px minmax(0, 1fr);
    }

    .branding-live-preview {
        grid-template-columns: 1fr;
    }
}
/* =========================================================
   14. Utility Page Headers
   ---------------------------------------------------------
   Useful for list pages where a heading sits beside a CTA.
   ========================================================= */
.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 16px;
}

.page-header h1 {
    margin: 0;
}


/* =========================================================
   15. Sidebar States
   ---------------------------------------------------------
   Branding, navigation links, and logout controls.
   ========================================================= */

/* --- Logo Wrapper & Image --- */
.sidebar-logo-wrap {
    display: flex;
    justify-content: flex-start;
    padding-bottom: var(--zinc-space-6); /* Using zinc-space-6 for a clean break */
    width: 100%;
}

.sidebar-logo-wrap img {
    max-width: 160px; /* Constrains logo from going full-width */
    width: 100%;
    height: auto;
    display: block;
}

/* --- Navigation Links --- */
.sidebar-link {
    display: flex;
    align-items: center;
    gap: 12px;
    color: #ffffff;
    text-decoration: none;
    padding: 10px 12px;
    border-radius: 8px;
    transition: background 0.15s ease, color 0.15s ease, opacity 0.15s ease;
    margin-bottom: 4px; /* Slight spacing between menu items */
}

.sidebar-link:link,
.sidebar-link:visited {
    color: #ffffff;
}

.sidebar-link:hover {
    background: rgba(255, 255, 255, 0.08);
    color: #ffffff;
    text-decoration: none;
}

.sidebar-link.is-active {
    background: rgba(255, 255, 255, 0.14);
    color: #ffffff;
    font-weight: 700;
}

.sidebar-link.is-active:hover {
    background: rgba(255, 255, 255, 0.18);
}

/* --- Sidebar Icons --- */
.sidebar-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 20px;       /* Fixed width ensures text alignment is uniform */
    height: 20px;
    flex-shrink: 0;    /* Prevents icon distortion if text wraps */
    opacity: 0.8;      /* Slightly muted to emphasize text */
    transition: opacity 0.15s ease;
}

.sidebar-icon svg,
.sidebar-icon i {
    width: 100%;
    height: 100%;
    font-size: 30px;   /* For icon fonts */
}

.sidebar-link:hover .sidebar-icon,
.sidebar-link.is-active .sidebar-icon {
    opacity: 1;        /* Highlights icon on hover/active */
}

/* --- Logout Button --- */
.btn-sidebar-logout {
    width: 100%;
    justify-content: center;
    background: rgba(255, 255, 255, 0.08);
    border-color: rgba(255, 255, 255, 0.14);
    color: #ffffff;
    margin-top: var(--zinc-space-5); /* Pushes logout away from nav */
}

.btn-sidebar-logout:hover,
.btn-sidebar-logout:focus,
.btn-sidebar-logout:active {
    background: rgba(255, 255, 255, 0.14);
    border-color: rgba(255, 255, 255, 0.22);
    color: #ffffff;
}
/* =========================================================
   16. Auth Pages
   ---------------------------------------------------------
   Split-screen authentication layout.
   Left = brand / restrictions / support links
   Right = auth card
   ========================================================= */
.auth-page {
    background: var(--zinc-bg);
}

.auth-layout {
    min-height: 100vh;
    display: grid;
    grid-template-columns: 1.05fr 0.95fr;
    background: var(--zinc-bg);
}

.auth-hero {
    background: linear-gradient(180deg, var(--brand-primary) 0%, var(--brand-accent) 100%);
    color: #ffffff;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 48px;
}

.auth-hero-inner {
    width: 100%;
    max-width: 520px;
}

.auth-hero-logo {
    display: block;
    max-width: 220px;
    width: 100%;
    height: auto;
    margin-bottom: 24px;
}

.auth-hero-wordmark {
    display: inline-block;
    font-size: 28px;
    font-weight: 800;
    letter-spacing: 0.03em;
    margin-bottom: 20px;
}

.auth-hero-title {
    margin: 0 0 12px 0;
    color: #ffffff;
    font-size: 36px;
    line-height: 1.15;
}

.auth-hero-panel {
    padding: 18px 20px;
    border: 1px solid rgba(255, 255, 255, 0.14);
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.08);
    backdrop-filter: blur(4px);
}

.auth-hero-panel strong {
    display: block;
    margin-bottom: 8px;
    color: #ffffff;
    font-size: 14px;
    letter-spacing: 0.03em;
    text-transform: uppercase;
}

.auth-hero-panel p {
    margin: 0;
    color: rgba(255, 255, 255, 0.82);
    line-height: 1.55;
}

.auth-hero-links {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    margin-top: 18px;
}

.auth-hero-link,
.auth-hero-link:link,
.auth-hero-link:visited {
    display: inline-flex;
    align-items: center;
    min-height: 38px;
    padding: 0 14px;
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.18);
    background: rgba(255, 255, 255, 0.06);
    color: #ffffff;
    text-decoration: none;
    font-weight: 600;
}

.auth-hero-link:hover,
.auth-hero-link:focus,
.auth-hero-link:active {
    background: rgba(255, 255, 255, 0.12);
    border-color: rgba(255, 255, 255, 0.26);
    color: #ffffff;
    text-decoration: none;
}

.auth-main {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 48px 32px;
    background: var(--zinc-bg);
}

.auth-main-inner {
    width: 100%;
    max-width: 440px;
}

.auth-card {
    width: 100%;
    background: var(--brand-surface);
    border: 1px solid var(--zinc-border);
    border-radius: var(--zinc-radius);
    box-shadow: var(--zinc-shadow);
    padding: 28px;
}

.auth-header {
    margin-bottom: var(--zinc-space-4);
}

.auth-header h1,
.auth-header h2 {
    margin: 0 0 6px 0;
    color: var(--zinc-heading);
}

.auth-header p {
    margin: 0;
    color: var(--zinc-text-muted);
}

.auth-form {
    display: grid;
    gap: var(--zinc-space-4);
}

.auth-actions {
    display: flex;
    align-items: center;
    justify-content: flex-start;
}

.auth-submit {
    min-width: 120px;
}

.auth-link-row {
    margin: var(--zinc-space-4) 0 0 0;
}


/* =========================================================
   17. Responsive Rules
   ---------------------------------------------------------
   Layout adjustments for tablet and mobile breakpoints.
   ========================================================= */
@media (max-width: 960px) {
    .auth-layout {
        grid-template-columns: 1fr;
    }

    .auth-hero {
        padding: 32px 24px;
    }

    .auth-hero-inner {
        max-width: 100%;
    }

    .auth-main {
        padding: 24px;
        align-items: flex-start;
    }

    .auth-main-inner {
        max-width: 100%;
    }
}

@media (max-width: 900px) {
    .shell {
        grid-template-columns: 1fr;
    }

    .sidebar {
        padding: 16px;
    }

    .main {
        padding: 16px;
    }

    .metrics {
        grid-template-columns: 1fr 1fr;
    }
}

@media (max-width: 768px) {
    .page-shell {
        padding: var(--zinc-space-4);
    }

    .card {
        padding: var(--zinc-space-4);
    }

    .detail-grid {
        grid-template-columns: 1fr;
    }

    th,
    td {
        padding: 10px 8px;
    }

    .branding-live-preview {
        grid-template-columns: 1fr;
    }

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

@media (max-width: 640px) {
    .metrics {
        grid-template-columns: 1fr;
    }

    .branding-colour-row {
        grid-template-columns: 1fr;
    }

    .branding-colour-picker {
        width: 100%;
    }

    .auth-hero {
        padding: 24px 20px;
    }

    .auth-main {
        padding: 20px;
    }

    .auth-card {
        padding: 22px;
    }

    .auth-hero-title {
        font-size: 28px;
    }
}

/* =========================================================
   18. Organisation Pages
   ---------------------------------------------------------
   Used on organisation show / edit / placeholder screens.
   Includes:
   - organisation summary blocks
   - placeholder states
   - organisation-specific spacing helpers
   ========================================================= */

.organisation-summary {
    display: grid;
    gap: 20px;
}

.organisation-section {
    display: grid;
    gap: 16px;
}

.organisation-meta-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(240px, 1fr));
    gap: 20px 24px;
}

.organisation-placeholder {
    margin-top: 20px;
}

.organisation-actions {
    margin-top: 20px;
}

.organisation-status {
    display: inline-flex;
    align-items: center;
}

@media (max-width: 768px) {
    .organisation-meta-grid {
        grid-template-columns: 1fr;
    }
}