/* ============================================
   Sparks to Perfection - Common Styles
   Shared variables, reset, typography, utilities
   ============================================ */

/* Google Fonts */
@import url('https://fonts.googleapis.com/css2?family=Playfair+Display:ital,wght@0,400;0,500;0,600;0,700;0,800;1,400;1,600&family=DM+Sans:ital,opsz,wght@0,9..40,300;0,9..40,400;0,9..40,500;0,9..40,600;0,9..40,700;1,9..40,400&display=swap');

/* CSS Custom Properties */
:root {
    /* Brand Colors - Gold / Navy */
    --brand-primary: #0c1a32;
    --brand-accent: #c9a84c;
    --brand-accent-light: #dfc06e;
    --brand-accent-dark: #a88a35;
    --brand-accent-glow: rgba(201, 168, 76, 0.3);

    /* Legacy compatibility (admin pages still use these) */
    --color-primary: #1e293b;
    --color-primary-light: #334155;
    --color-primary-dark: #0f172a;
    --color-accent: var(--brand-accent);
    --color-accent-light: var(--brand-accent-light);
    --color-accent-dark: var(--brand-accent-dark);

    /* Status Colors */
    --color-success: #22c55e;
    --color-success-bg: #f0fdf4;
    --color-warning: #f59e0b;
    --color-warning-bg: #fffbeb;
    --color-danger: #ef4444;
    --color-danger-bg: #fef2f2;
    --color-info: #3b82f6;
    --color-info-bg: #eff6ff;

    /* Neutrals (light mode defaults) */
    --color-bg: #f8fafc;
    --color-surface: #ffffff;
    --color-border: #e2e8f0;
    --color-border-light: #f1f5f9;
    --color-text: #1e293b;
    --color-text-secondary: #64748b;
    --color-text-muted: #94a3b8;
    --color-text-inverse: #ffffff;

    /* Dark theme overrides (used by designer + dark mode) */
    --dark-bg: #0b1220;
    --dark-surface: #1e293b;
    --dark-surface-light: #334155;
    --dark-border: #475569;
    --dark-text: #f1f5f9;
    --dark-text-secondary: #94a3b8;

    /* Typography */
    --font-display: 'Playfair Display', Georgia, 'Times New Roman', serif;
    --font-sans: 'DM Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    --font-mono: 'SF Mono', SFMono-Regular, Consolas, 'Liberation Mono', Menlo, monospace;

    /* Spacing */
    --space-xs: 4px;
    --space-sm: 8px;
    --space-md: 16px;
    --space-lg: 24px;
    --space-xl: 32px;
    --space-2xl: 48px;

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

    /* Shadows */
    --shadow-sm: 0 1px 2px rgba(0,0,0,0.05);
    --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.1), 0 2px 4px -2px rgba(0,0,0,0.1);
    --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.1), 0 4px 6px -4px rgba(0,0,0,0.1);
    --shadow-xl: 0 20px 25px -5px rgba(0,0,0,0.1), 0 8px 10px -6px rgba(0,0,0,0.1);

    /* Transitions */
    --transition-fast: 150ms ease;
    --transition-normal: 250ms ease;
    --transition-slow: 350ms ease;
}

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

html {
    -webkit-text-size-adjust: 100%;
    -webkit-tap-highlight-color: transparent;
    scroll-behavior: smooth;
}

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

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

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

button, input, select, textarea {
    font-family: inherit;
    font-size: inherit;
    line-height: inherit;
}

/* Typography Utilities */
.text-sm { font-size: 13px; }
.text-base { font-size: 15px; }
.text-lg { font-size: 18px; }
.text-xl { font-size: 22px; }
.text-2xl { font-size: 28px; }
.text-muted { color: var(--color-text-muted); }
.text-secondary { color: var(--color-text-secondary); }
.text-center { text-align: center; }
.text-right { text-align: right; }
.font-bold { font-weight: 700; }
.font-medium { font-weight: 500; }

/* Layout Utilities */
.flex { display: flex; }
.flex-col { flex-direction: column; }
.flex-wrap { flex-wrap: wrap; }
.items-center { align-items: center; }
.items-start { align-items: flex-start; }
.justify-between { justify-content: space-between; }
.justify-center { justify-content: center; }
.gap-xs { gap: var(--space-xs); }
.gap-sm { gap: var(--space-sm); }
.gap-md { gap: var(--space-md); }
.gap-lg { gap: var(--space-lg); }

/* Spacing Utilities */
.mt-sm { margin-top: var(--space-sm); }
.mt-md { margin-top: var(--space-md); }
.mt-lg { margin-top: var(--space-lg); }
.mt-xl { margin-top: var(--space-xl); }
.mb-sm { margin-bottom: var(--space-sm); }
.mb-md { margin-bottom: var(--space-md); }
.mb-lg { margin-bottom: var(--space-lg); }
.p-sm { padding: var(--space-sm); }
.p-md { padding: var(--space-md); }
.p-lg { padding: var(--space-lg); }

.hidden { display: none !important; }

/* ============================================
   Common Components
   ============================================ */

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-sm);
    padding: 10px 20px;
    font-size: 14px;
    font-weight: 600;
    line-height: 1;
    border: none;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all var(--transition-fast);
    white-space: nowrap;
    min-height: 44px; /* Touch-friendly */
    user-select: none;
}
.btn:active { transform: scale(0.97); }
.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

.btn-primary {
    background: var(--color-primary);
    color: var(--color-text-inverse);
}
.btn-primary:hover:not(:disabled) { background: var(--color-primary-light); }

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

.btn-danger {
    background: var(--color-danger);
    color: var(--color-text-inverse);
}
.btn-danger:hover:not(:disabled) { background: #dc2626; }

.btn-outline {
    background: transparent;
    color: var(--color-text);
    border: 1.5px solid var(--color-border);
}
.btn-outline:hover:not(:disabled) {
    background: var(--color-bg);
    border-color: var(--color-text-muted);
}

.btn-ghost {
    background: transparent;
    color: var(--color-text-secondary);
    padding: 8px 12px;
}
.btn-ghost:hover:not(:disabled) { background: var(--color-border-light); }

.btn-sm {
    padding: 6px 14px;
    font-size: 13px;
    min-height: 34px;
}
.btn-lg {
    padding: 14px 28px;
    font-size: 16px;
    min-height: 52px;
}
.btn-block { width: 100%; }

/* Form Controls */
.form-group {
    margin-bottom: var(--space-md);
}

.form-label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: var(--color-text-secondary);
    margin-bottom: var(--space-xs);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.form-control {
    width: 100%;
    padding: 10px 14px;
    font-size: 15px;
    border: 1.5px solid var(--color-border);
    border-radius: var(--radius-md);
    background: var(--color-surface);
    color: var(--color-text);
    transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
    min-height: 44px;
}
.form-control:focus {
    outline: none;
    border-color: var(--color-accent);
    box-shadow: 0 0 0 3px rgba(245, 158, 11, 0.15);
}
.form-control::placeholder {
    color: var(--color-text-muted);
}

/* File input styling */
input[type="file"].form-control {
    padding: 0;
    line-height: 44px;
    cursor: pointer;
}
input[type="file"].form-control::file-selector-button {
    padding: 10px 16px;
    margin-right: 12px;
    background: var(--color-primary);
    color: var(--color-text-inverse);
    border: none;
    border-right: 1.5px solid var(--color-border);
    border-radius: var(--radius-md) 0 0 var(--radius-md);
    font-family: var(--font-sans);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: background var(--transition-fast);
}
input[type="file"].form-control::file-selector-button:hover {
    background: var(--color-primary-light);
}

select.form-control {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%2364748b' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 36px;
}

textarea.form-control {
    min-height: 80px;
    resize: vertical;
}

/* Range Slider */
input[type="range"] {
    -webkit-appearance: none;
    width: 100%;
    height: 6px;
    border-radius: 3px;
    background: var(--color-border);
    outline: none;
}
input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: var(--color-accent);
    cursor: pointer;
    border: 2px solid var(--color-surface);
    box-shadow: var(--shadow-sm);
}
input[type="range"]::-moz-range-thumb {
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: var(--color-accent);
    cursor: pointer;
    border: 2px solid var(--color-surface);
    box-shadow: var(--shadow-sm);
}

/* Cards */
.card {
    background: var(--color-surface);
    border-radius: var(--radius-lg);
    border: 1px solid var(--color-border);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
}
.card-body { padding: var(--space-lg); }
.card-header {
    padding: var(--space-md) var(--space-lg);
    border-bottom: 1px solid var(--color-border);
    font-weight: 600;
}

/* Badges */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 3px 10px;
    font-size: 12px;
    font-weight: 600;
    border-radius: var(--radius-full);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.badge-pending { background: var(--color-warning-bg); color: var(--color-warning); }
.badge-in_progress { background: var(--color-info-bg); color: var(--color-info); }
.badge-completed { background: var(--color-success-bg); color: var(--color-success); }
.badge-cancelled { background: var(--color-danger-bg); color: var(--color-danger); }

/* Toast Notifications */
.toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 10000;
    display: flex;
    flex-direction: column;
    gap: var(--space-sm);
}

.toast {
    padding: 14px 20px;
    border-radius: var(--radius-md);
    color: var(--color-text-inverse);
    font-size: 14px;
    font-weight: 500;
    box-shadow: var(--shadow-lg);
    animation: toastIn 0.3s ease, toastOut 0.3s ease 3.7s forwards;
    max-width: 360px;
}
.toast-success { background: #16a34a; }
.toast-error { background: #dc2626; }
.toast-info { background: #2563eb; }

@keyframes toastIn {
    from { opacity: 0; transform: translateX(100px); }
    to { opacity: 1; transform: translateX(0); }
}
@keyframes toastOut {
    from { opacity: 1; }
    to { opacity: 0; transform: translateY(-10px); }
}

/* Loading Spinner */
.spinner {
    width: 32px;
    height: 32px;
    border: 3px solid var(--color-border);
    border-top-color: var(--color-accent);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}
.spinner-sm { width: 18px; height: 18px; border-width: 2px; }

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

.loading-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.4);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
}

/* Empty State */
.empty-state {
    text-align: center;
    padding: var(--space-2xl) var(--space-lg);
    color: var(--color-text-muted);
}
.empty-state-icon {
    font-size: 48px;
    margin-bottom: var(--space-md);
    opacity: 0.5;
}

/* Modal / Dialog */
.modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 5000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: var(--space-md);
    animation: fadeIn 0.2s ease;
}
.modal {
    background: var(--color-surface);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-xl);
    max-width: 560px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    animation: modalIn 0.25s ease;
}
.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--space-lg);
    border-bottom: 1px solid var(--color-border);
}
.modal-header h3 { font-size: 18px; }
.modal-body { padding: var(--space-lg); }
.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: var(--space-sm);
    padding: var(--space-md) var(--space-lg);
    border-top: 1px solid var(--color-border);
}
.modal-close {
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: var(--color-text-muted);
    padding: 4px;
    line-height: 1;
}

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes modalIn {
    from { opacity: 0; transform: scale(0.95) translateY(10px); }
    to { opacity: 1; transform: scale(1) translateY(0); }
}

/* Table */
.table-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}
table.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}
.data-table th {
    text-align: left;
    padding: 10px 14px;
    background: var(--color-bg);
    color: var(--color-text-secondary);
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-bottom: 2px solid var(--color-border);
    white-space: nowrap;
}
.data-table td {
    padding: 12px 14px;
    border-bottom: 1px solid var(--color-border-light);
    vertical-align: middle;
}
.data-table tr:hover td {
    background: var(--color-border-light);
}
.data-table .row-link {
    cursor: pointer;
}

/* Tabs */
.tabs {
    display: flex;
    gap: 2px;
    border-bottom: 2px solid var(--color-border);
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
}
.tab {
    padding: 10px 18px;
    font-size: 14px;
    font-weight: 500;
    color: var(--color-text-secondary);
    background: none;
    border: none;
    cursor: pointer;
    white-space: nowrap;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    transition: all var(--transition-fast);
}
.tab:hover { color: var(--color-text); }
.tab.active {
    color: var(--color-accent-dark);
    border-bottom-color: var(--color-accent);
    font-weight: 600;
}
.tab .count {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 20px;
    height: 20px;
    padding: 0 6px;
    margin-left: 6px;
    font-size: 11px;
    font-weight: 700;
    border-radius: var(--radius-full);
    background: var(--color-border);
    color: var(--color-text-secondary);
}
.tab.active .count {
    background: var(--color-accent);
    color: var(--color-primary-dark);
}

/* Scrollbar */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--color-border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--color-text-muted); }

/* ============================================
   Theme System: Light / Dark Mode
   Applied to storefront pages via [data-theme]
   ============================================ */

/* Light Mode (Storefront) */
[data-theme="light"] {
    --sf-bg: #f4f5f7;
    --sf-bg-alt: #e8eaef;
    --sf-surface: #ffffff;
    --sf-surface-hover: #f8f9fb;
    --sf-border: #d1d5de;
    --sf-border-light: #e8eaef;
    --sf-text: #0c1a32;
    --sf-text-secondary: #3d4f6f;
    --sf-text-muted: #7a849b;
    --sf-header-bg: #ffffff;
    --sf-header-text: #0c1a32;
    --sf-footer-bg: #0c1a32;
    --sf-footer-text: #8e98af;
    --sf-card-shadow: 0 2px 12px rgba(12, 26, 50, 0.06);
    --sf-card-shadow-hover: 0 8px 30px rgba(12, 26, 50, 0.12);
    --sf-overlay: rgba(12, 26, 50, 0.5);
    --sf-input-bg: #ffffff;
    --sf-input-border: #c5cad5;
}

/* Dark Mode (Storefront) */
[data-theme="dark"] {
    --sf-bg: #080e1a;
    --sf-bg-alt: #0e1628;
    --sf-surface: #131d33;
    --sf-surface-hover: #1a2744;
    --sf-border: #1f2d4a;
    --sf-border-light: #1a2744;
    --sf-text: #eceef2;
    --sf-text-secondary: #8e98af;
    --sf-text-muted: #5c667e;
    --sf-header-bg: #0a1226;
    --sf-header-text: #eceef2;
    --sf-footer-bg: #060a14;
    --sf-footer-text: #5c667e;
    --sf-card-shadow: 0 2px 12px rgba(0, 0, 0, 0.3);
    --sf-card-shadow-hover: 0 8px 30px rgba(0, 0, 0, 0.45);
    --sf-overlay: rgba(0, 0, 0, 0.65);
    --sf-input-bg: #131d33;
    --sf-input-border: #1f2d4a;

    /* Admin content area dark overrides */
    --color-bg: #0b1220;
    --color-surface: #131d33;
    --color-border: #1f2d4a;
    --color-border-light: #1a2744;
    --color-text: #eceef2;
    --color-text-secondary: #8e98af;
    --color-text-muted: #5c667e;
    --color-success-bg: rgba(34, 197, 94, 0.1);
    --color-warning-bg: rgba(245, 158, 11, 0.1);
    --color-danger-bg: rgba(239, 68, 68, 0.1);
    --color-info-bg: rgba(59, 130, 246, 0.1);
    --shadow-sm: 0 1px 2px rgba(0,0,0,0.2);
    --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.3), 0 2px 4px -2px rgba(0,0,0,0.2);
    --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.3), 0 4px 6px -4px rgba(0,0,0,0.2);
    --shadow-xl: 0 20px 25px -5px rgba(0,0,0,0.3), 0 8px 10px -6px rgba(0,0,0,0.2);
}
