/* ==========================================================================
   Quality Colors - Shared Component Styles
   qc-components.css

   Shared UI components used across all pages:
     - index.html (Hub)
     - colour/index.html (Color Prompt Generator)
     - colour/repaint.html (Building Repaint)
     - colour/repaint-ai.html (AI Building Repaint)
     - colour/template.html (A4 Print Template)

   Requires CSS custom properties (--primary, --primary-dark, --success,
   --warning, --card, --text, --text-light, --border) to be defined
   in each page's own <style> block or a separate theme file.
   ========================================================================== */


/* --------------------------------------------------------------------------
   1. BUTTONS
   -------------------------------------------------------------------------- */

.btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 12px 24px;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

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

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

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

.btn-ai {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    position: relative;
    overflow: hidden;
}

.btn-ai:hover {
    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 {
    background: var(--primary);
    color: white;
}

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

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

.btn-full {
    width: 100%;
    justify-content: center;
}


/* --------------------------------------------------------------------------
   2. CARDS
   -------------------------------------------------------------------------- */

.card {
    background: var(--card);
    border-radius: 12px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    padding: 20px;
}

.card h2 {
    font-size: 1.1rem;
    margin-bottom: 15px;
    color: var(--text);
    display: flex;
    align-items: center;
    gap: 8px;
}


/* --------------------------------------------------------------------------
   3. UPLOAD ZONES
   -------------------------------------------------------------------------- */

.upload-zone {
    border: 2px dashed var(--border);
    border-radius: 12px;
    padding: 40px;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s;
    background: #fafafa;
}

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

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

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

.upload-icon {
    font-size: 3rem;
    margin-bottom: 10px;
}

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


/* --------------------------------------------------------------------------
   4. COLOR GRID & SWATCHES
   -------------------------------------------------------------------------- */

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

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

.color-swatch {
    aspect-ratio: 1;
    border-radius: 6px;
    cursor: pointer;
    position: relative;
    transition: transform 0.2s;
    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);
}


/* --------------------------------------------------------------------------
   5. SPINNERS & LOADING OVERLAYS
   -------------------------------------------------------------------------- */

.spinner {
    display: inline-block;
    width: 40px;
    height: 40px;
    border: 3px solid rgba(99, 102, 241, 0.2);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

.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: 12px;
    z-index: 20;
}

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


/* --------------------------------------------------------------------------
   6. PROMPT OUTPUT
   Normalized: use .prompt-output everywhere (replaces .prompt-box)
   -------------------------------------------------------------------------- */

.prompt-output,
.prompt-box {
    background: #1e293b;
    color: #e2e8f0;
    padding: 15px;
    border-radius: 8px;
    font-family: 'Monaco', 'Consolas', monospace;
    font-size: 0.85rem;
    line-height: 1.6;
    white-space: pre-wrap;
    word-break: break-word;
    position: relative;
}

.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;
}

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


/* --------------------------------------------------------------------------
   7. PROMPT TABS
   -------------------------------------------------------------------------- */

.prompt-tabs {
    display: flex;
    gap: 4px;
    margin-top: 15px;
}

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

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


/* --------------------------------------------------------------------------
   8. AI SECTION
   -------------------------------------------------------------------------- */

.ai-section {
    border: 2px solid transparent;
    background:
        linear-gradient(white, white) padding-box,
        linear-gradient(135deg, #667eea, #764ba2) border-box;
    border-radius: 14px;
}

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

.ai-result h3 {
    font-size: 0.95rem;
    color: var(--primary-dark);
    margin-bottom: 10px;
}

.ai-suggestion {
    background: white;
    padding: 12px;
    border-radius: 8px;
    font-size: 0.85rem;
    border-left: 3px solid var(--primary);
}


/* --------------------------------------------------------------------------
   9. ERROR MESSAGES
   -------------------------------------------------------------------------- */

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


/* --------------------------------------------------------------------------
   10. SELECTED COLORS DISPLAY
   -------------------------------------------------------------------------- */

.selected-colors {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    min-height: 50px;
    padding: 10px;
    background: #f8f9fa;
    border-radius: 8px;
    margin-bottom: 15px;
}

.selected-color {
    display: flex;
    align-items: center;
    gap: 8px;
    background: white;
    padding: 6px 10px;
    border-radius: 8px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    font-size: 0.85rem;
}

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

.selected-color .remove {
    cursor: pointer;
    color: var(--text-light);
    font-weight: bold;
}

.selected-color .remove:hover {
    color: #ef4444;
    background: #fee2e2;
}


/* --------------------------------------------------------------------------
   11. PALETTE PREVIEW
   -------------------------------------------------------------------------- */

.palette-preview {
    display: flex;
    height: 50px;
    border-radius: 8px;
    overflow: hidden;
    margin-bottom: 15px;
}

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


/* --------------------------------------------------------------------------
   12. COLOR FAMILIES
   -------------------------------------------------------------------------- */

.color-families {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 15px;
}

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

.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;
}


/* --------------------------------------------------------------------------
   13. FORM ELEMENTS
   -------------------------------------------------------------------------- */

.form-group {
    margin-bottom: 15px;
}

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

.form-group select,
.form-group input,
.form-group textarea {
    width: 100%;
    padding: 10px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 1rem;
}

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

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

.search-box {
    display: flex;
    gap: 10px;
    margin-bottom: 15px;
}

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

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


/* --------------------------------------------------------------------------
   14. STATUS MESSAGES
   -------------------------------------------------------------------------- */

.status-message {
    padding: 12px;
    border-radius: 8px;
    margin-bottom: 15px;
    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;
}


/* --------------------------------------------------------------------------
   15. FOOTER
   -------------------------------------------------------------------------- */

footer {
    text-align: center;
    margin-top: 30px;
    padding: 20px;
    color: var(--text-light);
    font-size: 0.85rem;
}


/* --------------------------------------------------------------------------
   16. ANIMATIONS
   -------------------------------------------------------------------------- */

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


/* --------------------------------------------------------------------------
   17. NAV
   -------------------------------------------------------------------------- */

nav {
    margin-bottom: 15px;
}

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


/* --------------------------------------------------------------------------
   18. TOOLTIP
   -------------------------------------------------------------------------- */

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