/* =============================================
   RasterNest — Global Base Styles
   Design system: Claude.ai-inspired, warm minimal
   Light mode default, dark mode via [data-theme="dark"]
   ============================================= */

/* --- Design Tokens (Light Mode) --- */
:root {
    /* Colors — PRD Section 7.2 */
    --bg-primary: #FAF9F6;
    --bg-secondary: #F0EFEB;
    --bg-tertiary: #E8E5E0;
    --bg-card: #FFFFFF;
    --bg-card-hover: #F7F6F3;
    --bg-input: #FFFFFF;
    --bg-overlay: rgba(0, 0, 0, 0.4);

    --text-primary: #1A1A1A;
    --text-secondary: #6B6560;
    --text-tertiary: #9B9590;

    --accent: #0D9488;
    --accent-hover: #0F766E;
    --accent-light: #CCFBF1;
    --accent-text: #0D9488;

    --success: #16A34A;
    --warning: #D97706;
    --error: #DC2626;

    --border-color: #E8E5E0;
    --border-focus: #0D9488;

    /* Typography — PRD Section 7.3 */
    --font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    --font-h1: 600 30px/1.2 var(--font-family);
    --font-h2: 600 22px/1.3 var(--font-family);
    --font-h3: 500 17px/1.4 var(--font-family);
    --font-body: 400 15px/1.6 var(--font-family);
    --font-small: 500 13px/1.5 var(--font-family);
    --font-caption: 400 12px/1.5 var(--font-family);

    /* Spacing — PRD Section 7.4 (base 4px) */
    --space-xs: 4px;
    --space-sm: 8px;
    --space-md: 16px;
    --space-lg: 24px;
    --space-xl: 32px;
    --space-2xl: 48px;

    /* Legacy aliases for existing code */
    --gap-xs: var(--space-xs);
    --gap-sm: var(--space-sm);
    --gap-md: var(--space-md);
    --gap-lg: var(--space-lg);
    --gap-xl: var(--space-xl);

    /* Radius — PRD Section 7.5 */
    --radius-sm: 8px;
    --radius-md: 8px;
    --radius-lg: 12px;
    --radius-xl: 16px;

    /* Shadows */
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.06);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.08);
    --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.1);
    --shadow-glow: 0 0 0 3px rgba(13, 148, 136, 0.15);

    /* Transitions */
    --transition-fast: 0.15s ease;
    --transition-normal: 0.25s ease;
    --transition-slow: 0.4s ease;

    /* Legacy aliases */
    --accent-cyan: var(--accent);
    --text-muted: var(--text-tertiary);
    --accent-gradient: var(--accent);
    --accent-gradient-hover: var(--accent-hover);
}

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

html {
    font-size: 15px;
    scroll-behavior: smooth;
}

body {
    font: var(--font-body);
    background: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    overflow-x: hidden;
}

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

/* --- Header --- */
.app-header {
    background: var(--bg-card);
    border-bottom: 1px solid var(--border-color);
    padding: var(--space-md) var(--space-xl);
    position: sticky;
    top: 0;
    z-index: 100;
}

.header-content {
    max-width: 1200px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.logo {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
}

.logo h1 {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--accent);
    letter-spacing: -0.5px;
}

/* --- Header Navigation --- */
.header-nav {
    display: flex;
    align-items: center;
    gap: 4px;
}

.nav-link {
    color: var(--text-secondary);
    text-decoration: none;
    padding: 8px 14px;
    border-radius: var(--radius-sm);
    font-size: 0.87rem;
    font-weight: 500;
    transition: all var(--transition-fast);
    background: none;
    border: none;
    cursor: pointer;
    font-family: inherit;
}

.nav-link:hover {
    color: var(--text-primary);
    background: var(--bg-secondary);
}

.nav-cta {
    background: var(--accent);
    color: #fff !important;
    border-radius: var(--radius-sm);
}

.nav-cta:hover {
    background: var(--accent-hover);
}

/* Dark mode toggle in header */
.btn-theme-toggle {
    background: none;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    padding: 6px 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition-fast);
    font-size: 1rem;
}

.btn-theme-toggle:hover {
    border-color: var(--accent);
    color: var(--accent);
}

/* --- Buttons (shared) --- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-sm);
    padding: 10px 24px;
    border: none;
    border-radius: var(--radius-sm);
    font-family: inherit;
    font-size: 0.87rem;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition-normal);
}

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

.btn-primary {
    background: var(--accent);
    color: #fff;
    width: 100%;
}

.btn-primary:hover:not(:disabled) {
    background: var(--accent-hover);
    box-shadow: var(--shadow-glow);
    transform: translateY(-1px);
}

.btn-primary:active:not(:disabled) {
    transform: translateY(0);
}

.btn-secondary {
    background: transparent;
    color: var(--accent);
    border: 1px solid var(--border-color);
    width: 100%;
}

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

.btn-success {
    background: var(--success);
    color: #fff;
    width: 100%;
}

.btn-success:hover:not(:disabled) {
    filter: brightness(1.1);
    transform: translateY(-1px);
}

/* --- Badge --- */
.badge {
    background: var(--accent-light);
    color: var(--accent);
    font-size: 0.75rem;
    font-weight: 600;
    padding: 2px 10px;
    border-radius: 12px;
    min-width: 24px;
    text-align: center;
}

/* --- Toast Notifications --- */
.toast-container {
    position: fixed;
    bottom: var(--space-lg);
    right: var(--space-lg);
    display: flex;
    flex-direction: column;
    gap: var(--space-sm);
    z-index: 1100;
}

.toast {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: var(--space-md) var(--space-lg);
    box-shadow: var(--shadow-lg);
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    animation: toastIn 0.3s ease;
    max-width: 380px;
    font-size: 0.87rem;
}

.toast.toast-success { border-left: 3px solid var(--success); }
.toast.toast-error { border-left: 3px solid var(--error); }
.toast.toast-warning { border-left: 3px solid var(--warning); }

.toast.toast-out {
    animation: toastOut 0.3s ease forwards;
}

@keyframes toastIn {
    from { opacity: 0; transform: translateX(40px); }
    to { opacity: 1; transform: translateX(0); }
}

@keyframes toastOut {
    from { opacity: 1; transform: translateX(0); }
    to { opacity: 0; transform: translateX(40px); }
}

/* --- Footer --- */
.app-footer {
    background: var(--bg-secondary);
    border-top: 1px solid var(--border-color);
    padding: var(--space-lg) var(--space-xl);
    margin-top: auto;
}

.footer-content {
    max-width: 1200px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: var(--space-md);
}

.footer-left {
    display: flex;
    align-items: center;
    gap: var(--space-md);
}

.footer-brand {
    font-weight: 600;
    font-size: 0.87rem;
    color: var(--text-primary);
}

.footer-copy {
    font-size: 0.75rem;
    color: var(--text-tertiary);
}

.footer-right {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
}

.footer-support-label {
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.footer-link {
    font-size: 0.8rem;
    color: var(--accent);
    text-decoration: none;
    padding: 4px 8px;
    border-radius: 6px;
    transition: all var(--transition-fast);
}

.footer-link:hover {
    background: var(--accent-light);
}

.footer-divider {
    color: var(--text-tertiary);
    font-size: 0.75rem;
}

/* --- Ad Container --- */
.ad-container {
    max-width: 1200px;
    margin: var(--space-md) auto;
    padding: 0 var(--space-lg);
    min-height: 0;
}

/* --- Donation Card (widget) --- */
.donation-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 24px;
    text-align: center;
}

.donation-title {
    font: var(--font-h3);
    color: var(--text-primary);
    margin-bottom: 8px;
}

.donation-desc {
    font-size: 0.87rem;
    color: var(--text-secondary);
    margin-bottom: 16px;
    line-height: 1.5;
}

.donation-links {
    display: flex;
    gap: 12px;
    justify-content: center;
}

.donation-link {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    border-radius: var(--radius-sm);
    text-decoration: none;
    font-weight: 500;
    font-size: 0.87rem;
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    transition: all var(--transition-fast);
}

.donation-link:hover {
    border-color: var(--accent);
    background: var(--accent-light);
    color: var(--accent);
}

/* --- Content Pages (privacy, terms, about) --- */
.content-page {
    max-width: 720px;
    margin: 0 auto;
    padding: var(--space-xl) var(--space-md);
}

.content-page h1 {
    font: var(--font-h1);
    color: var(--text-primary);
    margin-bottom: var(--space-md);
}

.content-page h2 {
    font: var(--font-h2);
    color: var(--text-primary);
    margin-top: var(--space-lg);
    margin-bottom: var(--space-sm);
}

.content-page p,
.content-page ul,
.content-page li {
    color: var(--text-secondary);
    line-height: 1.7;
    margin-bottom: var(--space-sm);
}

.content-page ul {
    padding-left: var(--space-lg);
}

.content-page a {
    color: var(--accent);
}

.content-page a:hover {
    text-decoration: underline;
}

.content-meta {
    font: var(--font-small);
    color: var(--text-tertiary);
    margin-bottom: var(--space-lg);
}

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

/* --- Responsive Header & Footer --- */
@media (max-width: 768px) {
    .header-content {
        padding: 0 var(--space-md);
    }
    .header-nav {
        gap: 2px;
    }
    .nav-link {
        padding: 6px 10px;
        font-size: 0.8rem;
    }
}

@media (max-width: 600px) {
    .header-content {
        flex-direction: column;
        align-items: flex-start;
        gap: var(--space-sm);
    }
    .footer-content {
        flex-direction: column;
        text-align: center;
    }
    .footer-left, .footer-right {
        justify-content: center;
    }
}
