/* Modern & Cute Design System for Bareeed Storage */

:root {
    /* Bareeed sovereign tokens - light defaults */
    --bareed-surface-base: #efebe2;
    --bareed-text-primary: #2d3131;
    --bareed-text-secondary: #4a4f4e;
    --bareed-text-muted: #ae5d35;
    --bareed-border-default: #4a4f4e;
    --bareed-border-subtle: #4a4f4e;
    --bareed-accent-primary: #c06537;
    --bareed-accent-deep: #d0845e;
    --bareed-accent-strong: #ae5d35;
    --bareed-accent-soft: #d0845e;
    --bareed-ink-deep: #2d3131;
    --bareed-surface-muted: #d9b7a2;
    --bareed-surface-strong: #ae5d35;
    --bareed-surface-overlay: #d9b7a2;
    --bareed-overlay-strong: #ae5d35;
    --bareed-text-on-accent: #efebe2;

    /* Compatibility aliases */
    --primary: var(--bareed-accent-primary);
    --primary-light: var(--bareed-accent-soft);
    --primary-dark: var(--bareed-accent-strong);
    
    /* Status Colors */
    --success: var(--bareed-accent-primary);
    --success-light: var(--bareed-accent-soft);
    --warning: var(--bareed-accent-strong);
    --warning-light: var(--bareed-accent-soft);
    --danger: var(--bareed-accent-strong);
    --danger-light: var(--bareed-accent-soft);
    --info: var(--bareed-accent-primary);
    --info-light: var(--bareed-accent-soft);
    
    /* Neutral Colors */
    --bg-light: var(--bareed-surface-base);
    --bg-dark: #191c20;
    --border-color: var(--bareed-border-subtle);
    --border-dark: #4c504d;
    
    /* Text Colors */
    --text-primary: var(--bareed-text-primary);
    --text-secondary: var(--bareed-text-secondary);
    --text-light: #f1f0e9;
    --text-dark: #f1f0e9;
    --bg: var(--bareed-surface-base);
    --panel: var(--bareed-surface-base);
    --card: var(--bareed-surface-base);
    --muted: var(--bareed-text-secondary);
    --text: var(--bareed-text-primary);
    --accent: var(--bareed-accent-primary);
    --radius: 4px;
    --gap: 16px;
    --shadow: none;
    --bg-gradient: var(--bareed-surface-base);
    --panel-gradient: var(--bareed-surface-base);
    --card-gradient: var(--bareed-surface-base);
    --preview-gradient: var(--bareed-surface-base);
    --avatar-bg: var(--bareed-accent-soft);
    --search-bg: var(--bareed-surface-base);
    --compose-bg: var(--bareed-surface-base);
    --mail-hover: var(--bareed-accent-soft);
    
    /* Spacing */
    --spacing-xs: 4px;
    --spacing-sm: 8px;
    --spacing-md: 16px;
    --spacing-lg: 24px;
    --spacing-xl: 32px;
    --spacing-2xl: 48px;
    
    /* Border Radius */
    --radius-sm: 4px;
    --radius-md: 6px;
    --radius-lg: 8px;
    --radius-xl: 8px;
    --radius-full: 8px;
    
    /* Shadows */
    --shadow-sm: none;
    --shadow-md: none;
    --shadow-lg: none;
    --shadow-xl: none;
    --shadow-primary: none;
    
    /* Transitions */
    --transition-fast: 150ms cubic-bezier(0.4, 0, 0.2, 1);
    --transition-base: 250ms cubic-bezier(0.4, 0, 0.2, 1);
    --transition-slow: 350ms cubic-bezier(0.4, 0, 0.2, 1);
}

/* Dark Mode */
@media (prefers-color-scheme: dark) {
    :root {
        --bareed-surface-base: #191c20;
        --bareed-text-primary: #f1f0e9;
        --bareed-text-secondary: #f1f0e9;
        --bareed-text-muted: #d0845e;
        --bareed-border-default: #4c504d;
        --bareed-border-subtle: #4c504d;
        --bareed-accent-primary: #bf6436;
        --bareed-accent-deep: #75432c;
        --bareed-accent-strong: #a75932;
        --bareed-accent-soft: #4d3226;
        --bareed-ink-deep: #191c20;
        --bareed-surface-muted: #4d3226;
        --bareed-surface-strong: #a75932;
        --bareed-surface-overlay: #4d3226;
        --bareed-overlay-strong: #a75932;
        --bareed-text-on-accent: #f1f0e9;
        --bg-light: var(--bareed-surface-base);
        --border-color: var(--bareed-border-subtle);
        --text-primary: var(--bareed-text-primary);
        --text-secondary: var(--bareed-text-secondary);
        --bg: var(--bareed-surface-base);
        --panel: var(--bareed-surface-base);
        --card: var(--bareed-surface-base);
        --muted: var(--bareed-text-secondary);
        --text: var(--bareed-text-primary);
        --accent: var(--bareed-accent-primary);
        --bg-gradient: var(--bareed-surface-base);
        --panel-gradient: var(--bareed-surface-base);
        --card-gradient: var(--bareed-surface-base);
        --preview-gradient: var(--bareed-surface-base);
        --avatar-bg: var(--bareed-accent-soft);
        --search-bg: var(--bareed-surface-base);
        --compose-bg: var(--bareed-surface-base);
        --mail-hover: var(--bareed-accent-soft);
    }

    /* Keep component surfaces aligned with an explicit user-selected theme. */
    :root[data-theme="dark"] .card {
        background: var(--bareed-surface-base);
        border-color: var(--bareed-border-default);
    }

    :root[data-theme="dark"] input[type="text"],
    :root[data-theme="dark"] input[type="email"],
    :root[data-theme="dark"] input[type="password"],
    :root[data-theme="dark"] input[type="number"],
    :root[data-theme="dark"] textarea,
    :root[data-theme="dark"] select {
        background: var(--bareed-surface-overlay);
        color: var(--bareed-text-primary);
        border-color: var(--bareed-border-default);
    }

    :root[data-theme="dark"] input:focus,
    :root[data-theme="dark"] textarea:focus,
    :root[data-theme="dark"] select:focus {
        background: var(--bareed-surface-muted);
    }

    /* Explicit user-selected themes take precedence over system preference. */
    :root[data-theme="light"] {
        color-scheme: light;
        --bareed-surface-base: #efebe2;
        --bareed-text-primary: #2d3131;
        --bareed-text-secondary: #4a4f4e;
        --bareed-text-muted: #ae5d35;
        --bareed-border-default: #4a4f4e;
        --bareed-border-subtle: #4a4f4e;
        --bareed-accent-primary: #c06537;
        --bareed-accent-deep: #d0845e;
        --bareed-accent-strong: #ae5d35;
        --bareed-accent-soft: #d0845e;
        --bareed-ink-deep: #2d3131;
        --bareed-surface-muted: #d9b7a2;
        --bareed-surface-strong: #ae5d35;
        --bareed-surface-overlay: #d9b7a2;
        --bareed-overlay-strong: #ae5d35;
        --bareed-text-on-accent: #efebe2;
    }

    :root[data-theme="dark"] {
        color-scheme: dark;
        --bareed-surface-base: #191c20;
        --bareed-text-primary: #f1f0e9;
        --bareed-text-secondary: #f1f0e9;
        --bareed-text-muted: #d0845e;
        --bareed-border-default: #4c504d;
        --bareed-border-subtle: #4c504d;
        --bareed-accent-primary: #bf6436;
        --bareed-accent-deep: #75432c;
        --bareed-accent-strong: #a75932;
        --bareed-accent-soft: #4d3226;
        --bareed-ink-deep: #191c20;
        --bareed-surface-muted: #4d3226;
        --bareed-surface-strong: #a75932;
        --bareed-surface-overlay: #4d3226;
        --bareed-overlay-strong: #a75932;
        --bareed-text-on-accent: #f1f0e9;
    }

}

/* Shared logo treatment: the neutral backing keeps the transparent emblem legible
   on both the light and dark application surfaces. */
.brand-logo-frame {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    overflow: hidden;
    background: #f5f1e8;
    border: 1px solid rgba(45, 49, 49, 0.2);
    border-radius: inherit;
    box-sizing: border-box;
}

.brand-logo {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: contain;
    object-position: center;
}

.google-login,
.alternate-account {
    background: #ffffff;
    border: 1px solid #c7cbd1;
    color: #202124;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.12);
}

.google-login:hover,
.alternate-account:hover {
    background: #f8f9fa;
    color: #202124;
    opacity: 1;
}

/* Explicit user-selected themes take precedence over system preference. */
:root[data-theme="light"] {
    color-scheme: light;
    --bareed-surface-base: #efebe2;
    --bareed-text-primary: #2d3131;
    --bareed-text-secondary: #4a4f4e;
    --bareed-text-muted: #ae5d35;
    --bareed-border-default: #4a4f4e;
    --bareed-border-subtle: #4a4f4e;
    --bareed-accent-primary: #c06537;
    --bareed-accent-deep: #d0845e;
    --bareed-accent-strong: #ae5d35;
    --bareed-accent-soft: #d0845e;
    --bareed-ink-deep: #2d3131;
    --bareed-surface-muted: #d9b7a2;
    --bareed-surface-strong: #ae5d35;
    --bareed-surface-overlay: #d9b7a2;
    --bareed-overlay-strong: #ae5d35;
    --bareed-text-on-accent: #efebe2;
}

:root[data-theme="dark"] {
    color-scheme: dark;
    --bareed-surface-base: #191c20;
    --bareed-text-primary: #f1f0e9;
    --bareed-text-secondary: #f1f0e9;
    --bareed-text-muted: #d0845e;
    --bareed-border-default: #4c504d;
    --bareed-border-subtle: #4c504d;
    --bareed-accent-primary: #bf6436;
    --bareed-accent-deep: #75432c;
    --bareed-accent-strong: #a75932;
    --bareed-accent-soft: #4d3226;
    --bareed-ink-deep: #191c20;
    --bareed-surface-muted: #4d3226;
    --bareed-surface-strong: #a75932;
    --bareed-surface-overlay: #4d3226;
    --bareed-overlay-strong: #a75932;
    --bareed-text-on-accent: #f1f0e9;
}

/* Global Styles */
* {
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    color: var(--text-primary);
    background-color: var(--bg-light);
    transition: background-color var(--transition-base), color var(--transition-base);
}

/* Headings */
h1, h2, h3, h4, h5, h6 {
    font-weight: 700;
    letter-spacing: -0.02em;
    margin: 0;
}

h1 { font-size: 2.5em; }
h2 { font-size: 2em; }
h3 { font-size: 1.5em; }
h4 { font-size: 1.25em; }
h5 { font-size: 1.1em; }
h6 { font-size: 1em; }

/* Buttons */
.btn {
    display: inline-block;
    padding: var(--spacing-sm) var(--spacing-lg);
    border: none;
    border-radius: var(--radius-md);
    font-weight: 600;
    font-size: 1em;
    cursor: pointer;
    transition: all var(--transition-base);
    text-decoration: none;
    text-align: center;
    user-select: none;
}

.btn:hover {
    transform: translateY(-2px);
}

.btn:active {
    transform: translateY(0);
}

.btn-primary {
    background: var(--primary);
    color: var(--bareed-text-on-accent);
}

.btn-success {
    background: var(--success);
    color: var(--bareed-text-on-accent);
}

.btn-danger {
    background: var(--danger);
    color: var(--bareed-text-on-accent);
}

.btn-secondary {
    background: var(--bg-light);
    color: var(--text-primary);
    border: 2px solid var(--border-color);
}

.btn-secondary:hover {
    border-color: var(--primary);
}

/* Cards */
.card {
    background: var(--bareed-surface-base);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: var(--spacing-lg);
    transition: all var(--transition-base);
    box-shadow: none;
}

.card:hover {
    border-color: var(--primary);
    box-shadow: none;
    transform: translateY(-4px);
}

.card-gradient {
    background: var(--primary);
    color: var(--bareed-text-on-accent);
    border: none;
}

/* Forms */
input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
textarea,
select {
    width: 100%;
    padding: var(--spacing-sm) var(--spacing-md);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    font-size: 1em;
    font-family: inherit;
    transition: border-color var(--transition-base), box-shadow var(--transition-base);
}

input:focus,
textarea:focus,
select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: none;
}

label {
    display: block;
    margin-bottom: var(--spacing-sm);
    font-weight: 600;
    color: var(--text-primary);
}

/* Badges */
.badge {
    display: inline-block;
    padding: var(--spacing-xs) var(--spacing-sm);
    border-radius: var(--radius-full);
    font-size: 0.85em;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.badge-primary {
    background: var(--primary-light);
    color: var(--primary);
}

.badge-success {
    background: var(--success-light);
    color: var(--success);
}

.badge-warning {
    background: var(--warning-light);
    color: var(--warning);
}

.badge-danger {
    background: var(--danger-light);
    color: var(--danger);
}

/* Progress Bar */
.progress {
    background: var(--bareed-surface-overlay);
    border-radius: var(--radius-full);
    height: 8px;
    overflow: hidden;
    margin: var(--spacing-sm) 0;
}

.progress-bar {
    background: var(--primary);
    height: 100%;
    border-radius: var(--radius-full);
    transition: width var(--transition-slow) ease;
    position: relative;
}

.progress-bar::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--bareed-text-on-accent);
    animation: shimmer 2s infinite;
}

@keyframes shimmer {
    0% { transform: translateX(-100%); }
    100% { transform: translateX(100%); }
}

/* Grid */
.grid {
    display: grid;
    gap: var(--spacing-md);
}

.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }

@media (max-width: 768px) {
    .grid-2,
    .grid-3,
    .grid-4 { grid-template-columns: 1fr; }
}

/* Utilities */
.text-center { text-align: center; }
.text-primary { color: var(--primary); }
.text-success { color: var(--success); }
.text-danger { color: var(--danger); }
.text-secondary { color: var(--text-secondary); }

.mt-xs { margin-top: var(--spacing-xs); }
.mt-sm { margin-top: var(--spacing-sm); }
.mt-md { margin-top: var(--spacing-md); }
.mt-lg { margin-top: var(--spacing-lg); }
.mt-xl { margin-top: var(--spacing-xl); }

.mb-xs { margin-bottom: var(--spacing-xs); }
.mb-sm { margin-bottom: var(--spacing-sm); }
.mb-md { margin-bottom: var(--spacing-md); }
.mb-lg { margin-bottom: var(--spacing-lg); }
.mb-xl { margin-bottom: var(--spacing-xl); }

.p-xs { padding: var(--spacing-xs); }
.p-sm { padding: var(--spacing-sm); }
.p-md { padding: var(--spacing-md); }
.p-lg { padding: var(--spacing-lg); }
.p-xl { padding: var(--spacing-xl); }

.rounded { border-radius: var(--radius-md); }
.rounded-lg { border-radius: var(--radius-lg); }
.rounded-xl { border-radius: var(--radius-xl); }
.rounded-full { border-radius: var(--radius-full); }

/* Animations */
@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes slideUp {
    from { transform: translateY(10px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

.animate-fade {
    animation: fadeIn var(--transition-base);
}

.animate-slide {
    animation: slideUp var(--transition-base);
}

.animate-pulse {
    animation: pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;
}

/* Responsive */
@media (max-width: 768px) {
    h1 { font-size: 1.8em; }
    h2 { font-size: 1.5em; }
    h3 { font-size: 1.25em; }
    
    .btn {
        padding: var(--spacing-md) var(--spacing-md);
    }
}

/* Dark Mode Specific */
@media (prefers-color-scheme: dark) {
    .card {
        background: var(--bg-dark);
        border-color: var(--border-dark);
    }
    
    input[type="text"],
    input[type="email"],
    input[type="password"],
    input[type="number"],
    textarea,
    select {
        background: var(--bareed-surface-overlay);
        color: var(--bareed-text-primary);
        border-color: var(--border-dark);
    }
    
    input:focus,
    textarea:focus,
    select:focus {
        background: var(--bareed-surface-muted);
    }
}
