/**
 * ReadAgora Design System
 * Based on Wattpad-style consistency
 * Single source of truth for all UI elements
 */

:root {
    /* Color Palette */
    --primary: #FF6B6B;
    --primary-gradient-start: #FF6B6B;
    --primary-gradient-end: #FF8E53;
    --primary-hover: #E55555;
    
    --gray-900: #1a1a1a;
    --gray-800: #2d2d2d;
    --gray-700: #404040;
    --gray-600: #6b7280;
    --gray-500: #9ca3af;
    --gray-400: #d1d5db;
    --gray-300: #e5e7eb;
    --gray-200: #f3f4f6;
    --gray-100: #f9fafb;
    --white: #ffffff;
    
    /* Typography Scale (rem) */
    --text-h1: 2.25rem;    /* 36px */
    --text-h2: 1.875rem;   /* 30px */
    --text-h3: 1.5rem;     /* 24px */
    --text-h4: 1.25rem;    /* 20px */
    --text-base: 1rem;     /* 16px */
    --text-sm: 0.875rem;   /* 14px */
    --text-xs: 0.75rem;    /* 12px */
    
    /* Spacing System (8px base) */
    --space-1: 0.5rem;     /* 8px */
    --space-2: 1rem;       /* 16px */
    --space-3: 1.5rem;     /* 24px */
    --space-4: 2rem;       /* 32px */
    --space-6: 3rem;       /* 48px */
    --space-8: 4rem;       /* 64px */
    
    /* Shadows */
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1);
    
    /* Border Radius */
    --radius-sm: 0.375rem;  /* 6px */
    --radius-md: 0.5rem;    /* 8px */
    --radius-lg: 0.75rem;   /* 12px */
    --radius-xl: 1rem;      /* 16px */
    --radius-2xl: 1.5rem;   /* 24px */
    
    /* Line Heights */
    --line-tight: 1.25;
    --line-normal: 1.5;
    --line-relaxed: 1.625;
}

/* TYPOGRAPHY STYLES */
.text-h1 {
    font-size: var(--text-h1);
    font-weight: 700;
    line-height: var(--line-tight);
    letter-spacing: -0.02em;
}

.text-h2 {
    font-size: var(--text-h2);
    font-weight: 600;
    line-height: var(--line-tight);
    letter-spacing: -0.01em;
}

.text-h3 {
    font-size: var(--text-h3);
    font-weight: 600;
    line-height: var(--line-tight);
}

.text-h4 {
    font-size: var(--text-h4);
    font-weight: 500;
    line-height: var(--line-normal);
}

.text-body {
    font-size: var(--text-base);
    line-height: var(--line-relaxed);
    color: var(--gray-700);
}

.text-small {
    font-size: var(--text-sm);
    line-height: var(--line-normal);
    color: var(--gray-600);
}

.text-caption {
    font-size: var(--text-xs);
    line-height: var(--line-normal);
    color: var(--gray-500);
}

/* BUTTON STYLES */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    height: 2.5rem;
    padding: 0 1rem;
    border-radius: var(--radius-lg);
    font-weight: 500;
    transition: all 150ms ease-in-out;
    border: none;
    cursor: pointer;
    gap: var(--space-1);
}

.btn-primary {
    background-color: var(--primary);
    color: white;
}

.btn-primary:hover {
    background-color: var(--primary-hover);
    box-shadow: var(--shadow-md);
}

.btn-secondary {
    background-color: var(--gray-100);
    color: var(--gray-900);
}

.btn-secondary:hover {
    background-color: var(--gray-200);
}

.btn-text {
    background: none;
    color: var(--primary);
    padding: 0;
    height: auto;
}

.btn-text:hover {
    text-decoration: underline;
}

.btn-small {
    height: 2rem;
    padding: 0 0.75rem;
    font-size: var(--text-sm);
}

/* CARD STYLES */
.card {
    background-color: white;
    border-radius: var(--radius-xl);
    padding: 1.5rem;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--gray-200);
}

.card:hover {
    box-shadow: var(--shadow-md);
    transition: box-shadow 150ms ease-in-out;
}

/* FORM STYLES */
.input-base {
    display: block;
    width: 100%;
    height: 2.5rem;
    padding: 0 0.75rem;
    border-radius: var(--radius-lg);
    border: 1px solid var(--gray-300);
    font-size: var(--text-base);
    transition: border-color 150ms ease-in-out, box-shadow 150ms ease-in-out;
}

.input-base:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(255, 107, 107, 0.1);
}

.input-label {
    display: block;
    margin-bottom: 0.5rem;
    font-size: var(--text-sm);
    font-weight: 500;
    color: var(--gray-700);
}

/* IMAGE STYLES */
.img-story-cover {
    aspect-ratio: 3 / 4;
    object-fit: cover;
    border-radius: var(--radius-lg);
}

.img-avatar {
    width: 2.5rem;
    height: 2.5rem;
    border-radius: 9999px;
    object-fit: cover;
}

.img-avatar-large {
    width: 6rem;
    height: 6rem;
    border-radius: 9999px;
    object-fit: cover;
}

.img-thumbnail {
    aspect-ratio: 16 / 9;
    object-fit: cover;
    border-radius: var(--radius-lg);
}

/* LAYOUT PATTERNS */
.flex-center {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-1);
}

.flex-between {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.grid-cols-auto {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(15rem, 1fr));
    gap: var(--space-4);
}

/* DARK MODE */
@media (prefers-color-scheme: dark) {
    :root {
        --gray-900: #f9fafb;
        --gray-800: #f3f4f6;
        --gray-700: #e5e7eb;
        --gray-100: #1a1a1a;
        --white: #0f0609;
    }
    
    .card {
        background-color: #1a0c13;
        border-color: #3d1d2e;
    }
    
    .input-base {
        background-color: #0f0609;
        border-color: #3d1d2e;
        color: white;
    }
    
    .text-body {
        color: #e5e7eb;
    }
    
    .text-small {
        color: #d1d5db;
    }
    
    .text-caption {
        color: #9ca3af;
    }
    
    .btn-secondary {
        background-color: #2d2d2d;
        color: #f9fafb;
    }
    
    .btn-secondary:hover {
        background-color: #404040;
    }
    
    .form-input,
    .form-textarea,
    .form-select {
        background-color: #0f0609;
        border-color: #3d1d2e;
        color: white;
    }
    
    .form-input:focus,
    .form-textarea:focus,
    .form-select:focus {
        border-color: var(--primary);
        box-shadow: 0 0 0 3px rgba(255, 107, 107, 0.1);
    }
}

/* STORY CARD COMPONENT */
.story-card {
    display: flex;
    flex-direction: column;
    gap: var(--space-1);
    border-radius: var(--radius-lg);
    overflow: hidden;
    cursor: pointer;
    transition: transform 150ms ease-in-out, box-shadow 150ms ease-in-out;
    text-decoration: none;
    color: inherit;
}

.story-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-lg);
}

.story-card-image-container {
    position: relative;
    width: 100%;
    aspect-ratio: 3 / 4;
    overflow: hidden;
    border-radius: var(--radius-lg);
}

.story-card-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.story-card-content {
    padding: var(--space-1);
}

.story-card-content h3 {
    margin: 0;
    font-size: var(--text-base);
    font-weight: 600;
}

.story-card-content p {
    margin: 0;
    font-size: var(--text-sm);
    color: var(--gray-600);
}

.story-card-meta {
    display: flex;
    align-items: center;
    gap: var(--space-1);
    margin-top: var(--space-1);
    font-size: var(--text-xs);
    color: var(--gray-600);
}

.story-card-meta span.material-symbols-outlined {
    font-size: 1rem;
}

/* USER CARD COMPONENT */
.user-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--space-2);
    padding: var(--space-3);
    background-color: white;
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-sm);
    text-align: center;
}

.user-card:hover {
    box-shadow: var(--shadow-md);
}

.user-card-avatar {
    width: 4rem;
    height: 4rem;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid var(--primary);
}

.user-card h3 {
    margin: 0;
    font-size: var(--text-base);
    font-weight: 600;
}

.user-card p {
    margin: 0;
    font-size: var(--text-sm);
    color: var(--gray-600);
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* FORM GROUP COMPONENT */
.form-group {
    display: flex;
    flex-direction: column;
    gap: var(--space-1);
    margin-bottom: var(--space-2);
}

.form-group label {
    font-size: var(--text-sm);
    font-weight: 500;
    color: var(--gray-700);
}

.form-group input,
.form-group textarea,
.form-group select {
    padding: 0.75rem;
    border: 1px solid var(--gray-300);
    border-radius: var(--radius-lg);
    font-size: var(--text-base);
    font-family: inherit;
    transition: border-color 150ms, box-shadow 150ms;
}

.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(255, 107, 107, 0.1);
}

/* FORM INPUT CLASS OVERRIDE */
.form-input {
    padding: 0.75rem;
    border: 1px solid var(--gray-300);
    border-radius: var(--radius-lg);
    font-size: var(--text-base);
    font-family: inherit;
    width: 100%;
    transition: border-color 150ms, box-shadow 150ms;
}

.form-input::placeholder {
    color: var(--gray-500);
}

.form-input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(255, 107, 107, 0.1);
}

/* FORM TEXTAREA CLASS OVERRIDE */
.form-textarea {
    padding: 0.75rem;
    border: 1px solid var(--gray-300);
    border-radius: var(--radius-lg);
    font-size: var(--text-base);
    font-family: inherit;
    width: 100%;
    min-height: 6rem;
    resize: vertical;
    transition: border-color 150ms, box-shadow 150ms;
}

.form-textarea::placeholder {
    color: var(--gray-500);
}

.form-textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(255, 107, 107, 0.1);
}

/* FORM SELECT CLASS OVERRIDE */
.form-select {
    padding: 0.75rem;
    border: 1px solid var(--gray-300);
    border-radius: var(--radius-lg);
    font-size: var(--text-base);
    font-family: inherit;
    width: 100%;
    cursor: pointer;
    transition: border-color 150ms, box-shadow 150ms;
}

.form-select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(255, 107, 107, 0.1);
}

/* AVATAR UTILITY CLASSES */
.avatar-sm {
    width: 2rem;
    height: 2rem;
    border-radius: 50%;
    object-fit: cover;
    display: inline-block;
}

.avatar-md {
    width: 2.5rem;
    height: 2.5rem;
    border-radius: 50%;
    object-fit: cover;
    display: inline-block;
}

.avatar-lg {
    width: 4rem;
    height: 4rem;
    border-radius: 50%;
    object-fit: cover;
    display: inline-block;
}

/* BADGE UTILITY CLASSES */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.25rem 0.75rem;
    border-radius: 9999px;
    font-size: var(--text-xs);
    font-weight: 500;
}

.badge-primary {
    background-color: var(--primary);
    color: white;
}

.badge-success {
    background-color: #10b981;
    color: white;
}

.badge-warning {
    background-color: #f59e0b;
    color: white;
}

.badge-error {
    background-color: #ef4444;
    color: white;
}

/* ALERT UTILITY CLASSES */
.alert {
    display: flex;
    align-items: flex-start;
    gap: var(--space-1);
    padding: var(--space-2);
    border-radius: var(--radius-lg);
    border-left: 4px solid;
    font-size: var(--text-sm);
}

.alert-info {
    background-color: #dbeafe;
    border-left-color: #3b82f6;
    color: #1e40af;
}

.alert-success {
    background-color: #dcfce7;
    border-left-color: #10b981;
    color: #166534;
}

.alert-warning {
    background-color: #fef3c7;
    border-left-color: #f59e0b;
    color: #92400e;
}

.alert-error {
    background-color: #fee2e2;
    border-left-color: #ef4444;
    color: #991b1b;
}

@media (prefers-color-scheme: dark) {
    .alert-info {
        background-color: #1e3a8a;
        color: #93c5fd;
    }
    
    .alert-success {
        background-color: #064e3b;
        color: #6ee7b7;
    }
    
    .alert-warning {
        background-color: #78350f;
        color: #fcd34d;
    }
    
    .alert-error {
        background-color: #7f1d1d;
        color: #fca5a5;
    }
    
    .user-card {
        background-color: #1a0c13;
    }
}
