/* ==========================================================================
   Quality Colors - Design Tokens & Base Styles
   ==========================================================================
   Shared CSS variables, resets, typography, and utility classes extracted
   from all 5 HTML pages of the Quality Colors project.

   Pages:
     - index.html           (Hub / dark theme)
     - colour/index.html    (Color Prompt Generator / light theme)
     - colour/repaint.html  (Repaint Visualizer / light theme)
     - colour/repaint-ai.html (AI Building Repaint / light theme)
     - colour/template.html (A4 Marketing Template / dark theme)

   Usage:
     <link rel="stylesheet" href="/css/qc-design-tokens.css">
   ========================================================================== */


/* ==========================================================================
   1. FONT LOADING
   ========================================================================== */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&family=Poppins:wght@400;500;600;700;800;900&display=swap');


/* ==========================================================================
   2. LIGHT THEME (default)
   Used by: colour/index.html, colour/repaint.html, colour/repaint-ai.html
   ========================================================================== */

:root {
    /* --- Brand Colors --- */
    --primary: #6366f1;
    --primary-dark: #4f46e5;
    --secondary: #ec4899;

    /* --- Backgrounds --- */
    --bg: #f8fafc;
    --card: #ffffff;

    /* --- Text --- */
    --text: #1e293b;
    --text-light: #64748b;
    --text-muted: #64748b;

    /* --- Borders --- */
    --border: #e2e8f0;

    /* --- Status Colors --- */
    --success: #22c55e;
    --success-dark: #16a34a;
    --warning: #f59e0b;
    --warning-dark: #d97706;
    --error: #ef4444;
    --error-dark: #dc2626;
    --info: #3b82f6;

    /* --- AI Gradient --- */
    --ai-gradient: linear-gradient(135deg, #667eea 0%, #764ba2 100%);

    /* --- Header Gradients (page-specific, available globally) --- */
    --header-gradient-green: linear-gradient(135deg, #059669 0%, #10b981 100%);

    /* --- Shadows --- */
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.1);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 20px 40px rgba(0, 0, 0, 0.15);

    /* --- Radius --- */
    --radius-sm: 6px;
    --radius-md: 8px;
    --radius-lg: 12px;
    --radius-xl: 16px;
    --radius-full: 50px;

    /* --- Spacing --- */
    --space-xs: 4px;
    --space-sm: 8px;
    --space-md: 15px;
    --space-lg: 20px;
    --space-xl: 30px;
    --space-2xl: 40px;

    /* --- Transitions --- */
    --transition-fast: 0.2s ease;
    --transition-normal: 0.3s ease;

    /* --- Font Families --- */
    --font-sans: 'Inter', system-ui, -apple-system, sans-serif;
    --font-display: 'Poppins', system-ui, sans-serif;
    --font-mono: 'Monaco', 'Consolas', 'Courier New', monospace;
}


/* ==========================================================================
   3. DARK THEME
   Used by: index.html (Hub), colour/template.html (A4 Template)
   ========================================================================== */

[data-theme="dark"],
.theme-dark {
    --primary: #6366f1;
    --primary-dark: #4f46e5;
    --secondary: #ec4899;

    /* --- Backgrounds --- */
    --bg: #0f172a;
    --bg-card: #1e293b;
    --bg-card-hover: #334155;
    --card: #1e293b;

    /* --- Text --- */
    --text: #f1f5f9;
    --text-light: #94a3b8;
    --text-muted: #94a3b8;

    /* --- Borders --- */
    --border: #334155;

    /* --- Status Colors (same as light) --- */
    --success: #22c55e;
    --success-dark: #16a34a;
    --warning: #f59e0b;
    --warning-dark: #d97706;
    --error: #ef4444;
    --error-dark: #dc2626;
    --info: #3b82f6;

    /* --- AI Gradient --- */
    --ai-gradient: linear-gradient(135deg, #667eea 0%, #764ba2 100%);

    /* --- Hub Card Gradients --- */
    --gradient-1: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    --gradient-2: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
    --gradient-3: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%);
    --gradient-4: linear-gradient(135deg, #43e97b 0%, #38f9d7 100%);
    --gradient-5: linear-gradient(135deg, #fa709a 0%, #fee140 100%);

    /* --- Shadows (adjusted for dark bg) --- */
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.3);
    --shadow-lg: 0 20px 40px rgba(0, 0, 0, 0.5);
}


/* ==========================================================================
   4. BASE RESET
   ========================================================================== */

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


/* ==========================================================================
   5. BASE TYPOGRAPHY & BODY
   ========================================================================== */

body {
    font-family: var(--font-sans);
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* Pages using Poppins as primary font */
body.font-poppins {
    font-family: var(--font-display);
}

h1, h2, h3, h4, h5, h6 {
    line-height: 1.3;
}

a {
    color: var(--primary);
    text-decoration: none;
}

a:hover {
    color: var(--primary-dark);
}

img {
    max-width: 100%;
    height: auto;
}


/* ==========================================================================
   6. LAYOUT - CONTAINER
   ========================================================================== */

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: var(--space-2xl) var(--space-lg);
}

.container--wide {
    max-width: 1400px;
}

.container--narrow {
    max-width: 900px;
}


/* ==========================================================================
   7. COMMON CARD COMPONENT
   ========================================================================== */

.card {
    background: var(--card);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    padding: var(--space-lg);
}

.card h2 {
    font-size: 1.1rem;
    margin-bottom: var(--space-md);
    display: flex;
    align-items: center;
    gap: var(--space-sm);
}


/* ==========================================================================
   8. BUTTONS
   ========================================================================== */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-sm);
    padding: 12px 24px;
    border: none;
    border-radius: var(--radius-md);
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition-fast);
    font-family: inherit;
    line-height: 1.4;
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn-primary {
    background: var(--primary);
    color: white;
}

.btn-primary:hover:not(:disabled) {
    background: var(--primary-dark);
}

.btn-success {
    background: var(--success);
    color: white;
}

.btn-success:hover:not(:disabled) {
    background: var(--success-dark);
}

.btn-warning {
    background: var(--warning);
    color: #1e1b4b;
}

.btn-warning:hover:not(:disabled) {
    background: var(--warning-dark);
}

.btn-ai {
    background: var(--ai-gradient);
    color: white;
    position: relative;
    overflow: hidden;
}

.btn-ai:hover:not(:disabled) {
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.4);
    transform: translateY(-1px);
}

.btn-ai:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.btn-outline {
    background: white;
    color: var(--primary);
    border: 1px solid var(--primary);
}

.btn-outline:hover:not(:disabled) {
    background: var(--primary);
    color: white;
}

.btn-full {
    width: 100%;
}


/* ==========================================================================
   9. FORM ELEMENTS
   ========================================================================== */

.form-group {
    margin-bottom: var(--space-md);
}

.form-group label {
    display: block;
    margin-bottom: 6px;
    font-weight: 500;
    font-size: 0.9rem;
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 10px;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    font-size: 1rem;
    font-family: inherit;
    color: var(--text);
    background: var(--card);
    transition: border-color var(--transition-fast);
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--primary);
}

.form-group textarea {
    min-height: 60px;
    resize: vertical;
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}


/* ==========================================================================
   10. NAVIGATION (breadcrumb-style)
   ========================================================================== */

nav {
    margin-bottom: var(--space-md);
}

nav a {
    color: var(--primary);
    text-decoration: none;
    font-size: 0.9rem;
}

nav a:hover {
    color: var(--primary-dark);
}


/* ==========================================================================
   11. UPLOAD ZONE
   ========================================================================== */

.upload-zone {
    border: 2px dashed var(--border);
    border-radius: var(--radius-lg);
    padding: 30px;
    text-align: center;
    cursor: pointer;
    transition: all var(--transition-normal);
    background: #fafbfc;
}

.upload-zone:hover {
    border-color: var(--primary);
    background: #f0f4ff;
}

.upload-zone.dragover {
    border-color: var(--primary);
    background: #e0e7ff;
}

.upload-zone.has-image {
    padding: 10px;
    border-style: solid;
    border-color: var(--success);
}

.upload-zone .upload-icon {
    font-size: 2.5rem;
    margin-bottom: 8px;
}

.upload-zone .upload-text {
    color: var(--text-light);
    font-size: 0.9rem;
}


/* ==========================================================================
   12. PROMPT OUTPUT BOX (code-style)
   ========================================================================== */

.prompt-output,
.prompt-box {
    background: #1e293b;
    color: #e2e8f0;
    padding: 15px;
    border-radius: var(--radius-md);
    font-family: var(--font-mono);
    font-size: 0.85rem;
    line-height: 1.6;
    white-space: pre-wrap;
    word-break: break-word;
    position: relative;
    margin-top: var(--space-md);
}

.copy-btn {
    position: absolute;
    top: 8px;
    right: 8px;
    background: var(--primary);
    color: white;
    border: none;
    padding: 5px 10px;
    border-radius: 5px;
    cursor: pointer;
    font-size: 0.8rem;
    transition: background var(--transition-fast);
}

.copy-btn:hover {
    background: var(--primary-dark);
}

.copy-btn.copied {
    background: var(--success);
}


/* ==========================================================================
   13. PROMPT TABS
   ========================================================================== */

.prompt-tabs {
    display: flex;
    gap: 4px;
    margin-top: var(--space-md);
    margin-bottom: 0;
}

.prompt-tab,
.prompt-tab-btn {
    padding: 8px 16px;
    background: #e2e8f0;
    border: none;
    border-radius: var(--radius-md) var(--radius-md) 0 0;
    cursor: pointer;
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--text-light);
    transition: all var(--transition-fast);
}

.prompt-tab.active,
.prompt-tab-btn.active {
    background: #1e293b;
    color: #e2e8f0;
}

.prompt-tab:hover:not(.active),
.prompt-tab-btn:hover:not(.active) {
    background: #cbd5e1;
}


/* ==========================================================================
   14. COLOR SWATCHES & GRID
   ========================================================================== */

.color-grid-container {
    max-height: 500px;
    overflow-y: auto;
    padding: 10px;
    background: #f8f9fa;
    border-radius: var(--radius-md);
}

.color-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(50px, 1fr));
    gap: 6px;
}

.color-swatch {
    aspect-ratio: 1;
    border-radius: var(--radius-sm);
    cursor: pointer;
    position: relative;
    transition: transform var(--transition-fast);
    border: 2px solid transparent;
}

.color-swatch:hover {
    transform: scale(1.15);
    z-index: 10;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.color-swatch.selected {
    border-color: #000;
    box-shadow: 0 0 0 2px white, 0 0 0 4px var(--primary);
}


/* ==========================================================================
   15. COLOR FAMILIES (filter buttons)
   ========================================================================== */

.color-families {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: var(--space-md);
}

.family-btn {
    padding: 5px 10px;
    border: 1px solid var(--border);
    border-radius: 15px;
    background: white;
    cursor: pointer;
    font-size: 0.8rem;
    transition: all var(--transition-fast);
}

.family-btn:hover,
.family-btn.active {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

.family-btn .count {
    font-size: 0.7rem;
    opacity: 0.7;
    margin-left: 4px;
}


/* ==========================================================================
   16. SELECTED COLORS DISPLAY
   ========================================================================== */

.selected-colors {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-sm);
    min-height: 40px;
    padding: 10px;
    background: #f8f9fa;
    border-radius: var(--radius-md);
    margin-bottom: var(--space-md);
}

.selected-color {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    background: white;
    padding: 6px 10px;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
    font-size: 0.85rem;
}

.selected-color .swatch {
    width: 24px;
    height: 24px;
    border-radius: 4px;
    flex-shrink: 0;
}

.selected-color .remove {
    cursor: pointer;
    color: var(--text-light);
    font-weight: bold;
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: all var(--transition-fast);
}

.selected-color .remove:hover {
    color: var(--error);
    background: #fee2e2;
}


/* ==========================================================================
   17. PALETTE PREVIEW BAR
   ========================================================================== */

.palette-preview {
    display: flex;
    height: 50px;
    border-radius: var(--radius-md);
    overflow: hidden;
    margin-bottom: var(--space-md);
}

.palette-preview > div {
    flex: 1;
}


/* ==========================================================================
   18. AI SECTION (gradient border)
   ========================================================================== */

.ai-section {
    border: 2px solid transparent;
    background:
        linear-gradient(white, white) padding-box,
        var(--ai-gradient) border-box;
    border-radius: 14px;
    padding: var(--space-lg);
    margin-bottom: var(--space-lg);
}

.ai-section-header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 15px 20px;
    background: linear-gradient(135deg, rgba(102, 126, 234, 0.08) 0%, rgba(118, 75, 162, 0.08) 100%);
    border-radius: 12px 12px 0 0;
    border-bottom: 1px solid var(--border);
}

.ai-result {
    background: linear-gradient(135deg, rgba(102, 126, 234, 0.05) 0%, rgba(118, 75, 162, 0.05) 100%);
    border: 1px solid rgba(102, 126, 234, 0.2);
    border-radius: 10px;
    padding: var(--space-md);
    margin-top: var(--space-md);
}

.ai-result h3 {
    font-size: 0.95rem;
    color: var(--primary-dark);
    margin-bottom: 10px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.ai-suggestion {
    background: white;
    padding: 12px;
    border-radius: var(--radius-md);
    font-size: 0.85rem;
    border-left: 3px solid var(--primary);
    color: var(--text);
    line-height: 1.5;
}


/* ==========================================================================
   19. BADGES
   ========================================================================== */

.badge {
    display: inline-block;
    background: rgba(255, 255, 255, 0.2);
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 0.85rem;
    margin-top: 10px;
}

.ai-badge,
.badge.ai {
    background: rgba(255, 255, 255, 0.25);
    animation: pulse-glow 2s ease-in-out infinite;
}

.brand-badge {
    display: inline-block;
    background: rgba(255, 255, 255, 0.2);
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 0.85rem;
    margin-top: 10px;
}


/* ==========================================================================
   20. SPINNER & LOADING
   ========================================================================== */

.spinner {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    border-top-color: white;
    animation: spin 0.8s linear infinite;
}

.spinner--primary {
    border-color: rgba(99, 102, 241, 0.2);
    border-top-color: var(--primary);
}

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

.loading-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.9);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-lg);
    z-index: 20;
}

.loading-overlay .spinner {
    width: 40px;
    height: 40px;
    border-width: 3px;
    border-color: rgba(99, 102, 241, 0.2);
    border-top-color: var(--primary);
}

.loading-overlay p,
.loading-overlay .loading-text {
    margin-top: 12px;
    color: var(--text-light);
    font-size: 0.9rem;
}


/* ==========================================================================
   21. ERROR & STATUS MESSAGES
   ========================================================================== */

.error-msg {
    background: #fef2f2;
    border: 1px solid #fecaca;
    color: #dc2626;
    padding: 10px 15px;
    border-radius: var(--radius-md);
    font-size: 0.85rem;
    margin-top: 10px;
}

.status-message {
    padding: 12px;
    border-radius: var(--radius-md);
    margin-bottom: var(--space-md);
    display: none;
}

.status-message.active {
    display: block;
}

.status-message.success {
    background: #dcfce7;
    color: #166534;
}

.status-message.error {
    background: #fee2e2;
    color: #991b1b;
}

.status-message.info {
    background: #dbeafe;
    color: #1e40af;
}


/* ==========================================================================
   22. TOOLTIP
   ========================================================================== */

.tooltip {
    position: fixed;
    background: #1e293b;
    color: white;
    padding: 8px 12px;
    border-radius: var(--radius-sm);
    font-size: 0.8rem;
    pointer-events: none;
    z-index: 1000;
    max-width: 200px;
    white-space: pre-line;
}


/* ==========================================================================
   23. FOOTER (common across pages)
   ========================================================================== */

footer {
    text-align: center;
    padding: var(--space-lg);
    color: var(--text-light);
    font-size: 0.85rem;
}

footer p + p {
    margin-top: var(--space-sm);
}


/* ==========================================================================
   24. SECTION DIVIDER
   ========================================================================== */

.section-divider {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: var(--space-md) 0;
    color: var(--text-light);
    font-size: 0.8rem;
}

.section-divider::before,
.section-divider::after {
    content: '';
    flex: 1;
    height: 1px;
    background: var(--border);
}


/* ==========================================================================
   25. MODE TOGGLE (AI / Manual switch)
   ========================================================================== */

.mode-toggle {
    display: flex;
    background: #f1f5f9;
    border-radius: 10px;
    padding: 4px;
    margin-bottom: var(--space-md);
}

.mode-btn {
    flex: 1;
    padding: 10px 16px;
    border: none;
    border-radius: var(--radius-md);
    cursor: pointer;
    font-size: 0.85rem;
    font-weight: 500;
    background: transparent;
    color: var(--text-light);
    transition: all var(--transition-fast);
    text-align: center;
}

.mode-btn.active {
    background: white;
    color: var(--text);
    box-shadow: var(--shadow-sm);
}

.mode-btn.ai-mode.active {
    background: var(--ai-gradient);
    color: white;
}


/* ==========================================================================
   26. SEARCH BOX
   ========================================================================== */

.search-box {
    display: flex;
    gap: 10px;
    margin-bottom: var(--space-md);
}

.search-box input {
    flex: 1;
    padding: 10px 15px;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    font-size: 1rem;
    color: var(--text);
    background: var(--card);
}

.search-box input:focus {
    outline: none;
    border-color: var(--primary);
}


/* ==========================================================================
   27. INSTRUCTIONS BOX
   ========================================================================== */

.instructions {
    background: #fef3c7;
    border: 1px solid #fbbf24;
    border-radius: var(--radius-md);
    padding: var(--space-md);
    font-size: 0.85rem;
    margin-bottom: var(--space-md);
}

.instructions h4 {
    color: #92400e;
    margin-bottom: var(--space-sm);
}

.instructions ol {
    margin-left: 20px;
    color: #78350f;
}


/* ==========================================================================
   28. KEYFRAME ANIMATIONS
   ========================================================================== */

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

@keyframes pulse-glow {
    0%, 100% {
        opacity: 0.8;
    }
    50% {
        opacity: 1;
        box-shadow: 0 0 10px rgba(255, 255, 255, 0.3);
    }
}

@keyframes pulse-tag {
    0%, 100% {
        opacity: 0.85;
    }
    50% {
        opacity: 1;
    }
}


/* ==========================================================================
   29. UTILITY CLASSES
   ========================================================================== */

/* --- Display --- */
.hidden {
    display: none !important;
}

/* --- Text Alignment --- */
.text-center {
    text-align: center;
}

.text-right {
    text-align: right;
}

/* --- Flex Utilities --- */
.flex {
    display: flex;
}

.flex-col {
    display: flex;
    flex-direction: column;
}

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

.flex-wrap {
    flex-wrap: wrap;
}

.gap-sm {
    gap: var(--space-sm);
}

.gap-md {
    gap: var(--space-md);
}

.gap-lg {
    gap: var(--space-lg);
}

/* --- Margin --- */
.mt-sm {
    margin-top: var(--space-sm);
}

.mt-md {
    margin-top: var(--space-md);
}

.mt-lg {
    margin-top: var(--space-lg);
}

.mb-sm {
    margin-bottom: var(--space-sm);
}

.mb-md {
    margin-bottom: var(--space-md);
}

.mb-lg {
    margin-bottom: var(--space-lg);
}

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


/* ==========================================================================
   30. RESPONSIVE BREAKPOINTS
   ========================================================================== */

@media (max-width: 1000px) {
    .grid-2col {
        grid-template-columns: 1fr !important;
    }
}

@media (max-width: 900px) {
    .grid-2col-equal {
        grid-template-columns: 1fr !important;
    }
}

@media (max-width: 600px) {
    .container {
        padding: var(--space-lg) var(--space-md);
    }

    h1 {
        font-size: 1.8rem;
    }

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


/* ==========================================================================
   31. PRINT STYLES
   ========================================================================== */

@media print {
    .no-print {
        display: none !important;
    }
}
