/* ============================================
   Base CSS - Variables, Reset, Typography
   ============================================ */

/* CSS Variables - Branding & Theme (Dark - Default) */
:root {
    /* Brand Colors - Easy to customize */
    --brand-primary: #e94560;
    --brand-primary-hover: #ff6b6b;
    --brand-secondary: #1a1a2e;
    --brand-accent: #e94560;
    
    /* Background Colors */
    --bg-primary: #1a1a2e;
    --bg-secondary: #16213e;
    --bg-tertiary: #0f0f1a;
    --bg-card: #252540;
    
    /* Accent & Interactive */
    --accent: var(--brand-primary);
    --accent-hover: var(--brand-primary-hover);
    
    /* Text Colors */
    --text-primary: #ffffff;
    --text-secondary: #a0a0b0;
    --text-muted: #6a6a7a;
    
    /* Border */
    --border: #3a3a5a;
    
    /* Status Colors */
    --success: #4ade80;
    --warning: #fbbf24;
    --danger: #ef4444;
    --info: #3b82f6;
    
    /* Platform Colors */
    --instagram: #E1306C;
    --tiktok: #00f2ea;
    --x: #ffffff;
    --youtube: #FF0000;
    --linkedin: #0A66C2;
    --facebook: #1877F2;
    --threads: #000000;
    --pinterest: #E60023;
    
    /* Spacing Scale */
    --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: 10px;
    --radius-lg: 16px;
    --radius-full: 9999px;
    
    /* Shadows */
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.2);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.3);
    --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.4);
    --shadow-accent: 0 4px 20px rgba(233, 69, 96, 0.4);
    
    /* Transitions */
    --transition-fast: 0.15s ease;
    --transition-normal: 0.2s ease;
    --transition-slow: 0.3s ease;
    
    /* Z-Index Scale */
    --z-base: 0;
    --z-dropdown: 50;
    --z-sticky: 100;
    --z-modal: 200;
    --z-toast: 300;
    
    /* Safe areas for mobile */
    --safe-top: env(safe-area-inset-top, 0px);
    --safe-bottom: env(safe-area-inset-bottom, 0px);
    --safe-left: env(safe-area-inset-left, 0px);
    --safe-right: env(safe-area-inset-right, 0px);
}

/* Light Theme - Multiple selectors for maximum compatibility */
html[data-theme="light"],
:root[data-theme="light"],
body[data-theme="light"],
body.theme-light,
.theme-light,
[data-theme="light"] {
    --bg-primary: #f8f9fa !important;
    --bg-secondary: #f0f1f3 !important;
    --bg-tertiary: #e8e9eb !important;
    --bg-card: #ffffff !important;
    --text-primary: #111827 !important;
    --text-secondary: #4b5563 !important;
    --text-muted: #6b7280 !important;
    --border: #d1d5db !important;
    --brand-secondary: #f3f4f6 !important;
    
    /* Adjusted shadows for light theme */
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.06) !important;
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.08) !important;
    --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.12) !important;
}

/* Dark Theme - Explicit for toggle back */
html[data-theme="dark"],
body[data-theme="dark"],
body.theme-dark,
.theme-dark,
[data-theme="dark"] {
    --bg-primary: #1a1a2e !important;
    --bg-secondary: #16213e !important;
    --bg-tertiary: #0f0f1a !important;
    --bg-card: #252540 !important;
    --text-primary: #ffffff !important;
    --text-secondary: #a0a0b0 !important;
    --text-muted: #6a6a7a !important;
    --border: #3a3a5a !important;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.2) !important;
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.3) !important;
    --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.4) !important;
}

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

html {
    font-size: 16px;
    -webkit-tap-highlight-color: transparent;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    min-height: 100dvh;
    overflow-x: hidden;
    line-height: 1.5;
}

/* Remove default list styles */
ul, ol {
    list-style: none;
}

/* Remove default link styles */
a {
    color: inherit;
    text-decoration: none;
}

/* Make images responsive */
img, video {
    max-width: 100%;
    height: auto;
    display: block;
}

/* Remove default button styles */
button {
    font-family: inherit;
    font-size: inherit;
    background: none;
    border: none;
    cursor: pointer;
}

/* Remove default input styles */
input, textarea, select {
    font-family: inherit;
    font-size: inherit;
}

/* ============================================
   Typography
   ============================================ */
h1, h2, h3, h4, h5, h6 {
    font-weight: 600;
    line-height: 1.3;
}

h1 { font-size: 1.75rem; }
h2 { font-size: 1.5rem; }
h3 { font-size: 1.25rem; }
h4 { font-size: 1.1rem; }
h5 { font-size: 1rem; }
h6 { font-size: 0.9rem; }

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

p:last-child {
    margin-bottom: 0;
}

small {
    font-size: 0.85rem;
}

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

.text-secondary {
    color: var(--text-secondary);
}

.text-accent {
    color: var(--accent);
}

.text-success {
    color: var(--success);
}

.text-warning {
    color: var(--warning);
}

.text-danger {
    color: var(--danger);
}

/* ============================================
   Utility Classes
   ============================================ */
.hidden {
    display: none !important;
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* ============================================
   Scrollbar Styling
   ============================================ */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

::-webkit-scrollbar-track {
    background: var(--bg-tertiary);
}

::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

/* Firefox */
* {
    scrollbar-width: thin;
    scrollbar-color: var(--border) var(--bg-tertiary);
}

/* ============================================
   Animations
   ============================================ */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

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

@keyframes slideUp {
    from { transform: translateY(100%); }
    to { transform: translateY(0); }
}

@keyframes slideDown {
    from { transform: translateY(-100%); }
    to { transform: translateY(0); }
}

@keyframes slideInRight {
    from { 
        transform: translateX(100%);
        opacity: 0;
    }
    to { 
        transform: translateX(0);
        opacity: 1;
    }
}

@keyframes toastIn {
    from { opacity: 0; transform: translateX(-50%) translateY(20px); }
    to { opacity: 1; transform: translateX(-50%) translateY(0); }
}

@keyframes toastOut {
    from { opacity: 1; transform: translateX(-50%) translateY(0); }
    to { opacity: 0; transform: translateX(-50%) translateY(20px); }
}

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

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

/* ============================================
   Focus Styles (Accessibility)
   ============================================ */
:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

button:focus-visible,
input:focus-visible,
textarea:focus-visible,
select:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

/* Light Theme - Enhanced Readability */
[data-theme="light"] .stat-card,
[data-theme="light"] .vision-card,
[data-theme="light"] .note-card,
[data-theme="light"] .idea-card,
[data-theme="light"] .pipeline-card,
[data-theme="light"] .goals-card,
[data-theme="light"] .batch-card,
[data-theme="light"] .template-card,
[data-theme="light"] .caption-template-card,
[data-theme="light"] .swipe-card,
[data-theme="light"] .recycle-card {
    border: 1px solid var(--border) !important;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04) !important;
}

[data-theme="light"] .calendar-day {
    border: 1px solid rgba(0, 0, 0, 0.06);
}

[data-theme="light"] .nav-item,
[data-theme="light"] .toggle-btn,
[data-theme="light"] .tag-filter,
[data-theme="light"] .timeframe-btn {
    border: 1px solid transparent;
}

[data-theme="light"] .nav-item:hover,
[data-theme="light"] .toggle-btn:hover,
[data-theme="light"] .tag-filter:hover,
[data-theme="light"] .timeframe-btn:hover {
    border-color: var(--border);
}

[data-theme="light"] .btn-action-top.btn-note {
    border-color: var(--border);
}

[data-theme="light"] input,
[data-theme="light"] textarea,
[data-theme="light"] select {
    border: 1px solid var(--border) !important;
}

[data-theme="light"] .detail-info-section,
[data-theme="light"] .quick-note-container,
[data-theme="light"] .modal-content {
    border: 1px solid var(--border);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
}

[data-theme="light"] .pillar-legend,
[data-theme="light"] .streak-section,
[data-theme="light"] .stats-overview {
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: var(--space-md);
    background: var(--bg-card);
}
