/* CSS Variables */
:root {
    --primary: #2563eb;
    --primary-dark: #1d4ed8;
    --secondary: #64748b;
    --success: #16a34a;
    --danger: #dc2626;
    --warning: #f59e0b;
    --bg: #f8fafc;
    --bg-card: #ffffff;
    --text: #1e293b;
    --text-muted: #64748b;
    --border: #e2e8f0;
    --radius: 8px;
    --shadow: 0 1px 3px rgba(0,0,0,0.1);
    --shadow-lg: 0 4px 6px rgba(0,0,0,0.1);
}

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

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    font-size: 16px;
    line-height: 1.6;
    color: var(--text);
    background: var(--bg);
}

/* Layout */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 1rem;
}

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

.header-content {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 2rem;
}

.logo {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    text-decoration: none;
    color: var(--text);
    font-weight: 700;
    font-size: 1.25rem;
}

.logo-icon {
    font-size: 1.5rem;
}

.nav {
    display: flex;
    gap: 1.5rem;
}

.nav-link {
    color: var(--text-muted);
    text-decoration: none;
    font-weight: 500;
    transition: color 0.2s;
}

.nav-link:hover {
    color: var(--primary);
}

.header-actions {
    display: flex;
    gap: 0.5rem;
}

/* Main */
.main {
    min-height: calc(100vh - 140px);
    padding: 2rem 0;
}

/* Footer */
.footer {
    background: var(--bg-card);
    border-top: 1px solid var(--border);
    padding: 2rem 0;
    text-align: center;
    color: var(--text-muted);
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.625rem 1.25rem;
    font-size: 0.875rem;
    font-weight: 500;
    border: none;
    border-radius: var(--radius);
    cursor: pointer;
    text-decoration: none;
    transition: all 0.2s;
}

.btn-primary {
    background: var(--primary);
    color: white;
}

.btn-primary:hover {
    background: var(--primary-dark);
}

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

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

.btn-success {
    background: var(--success);
    color: white;
}

.btn-danger {
    background: var(--danger);
    color: white;
}

.btn-lg {
    padding: 0.875rem 1.5rem;
    font-size: 1rem;
}

.btn-sm {
    padding: 0.375rem 0.75rem;
    font-size: 0.75rem;
}

.btn-link {
    background: none;
    color: var(--text-muted);
    text-decoration: underline;
}

/* Forms */
.form-input,
.form-select,
textarea {
    width: 100%;
    padding: 0.625rem 0.875rem;
    font-size: 0.875rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--bg-card);
    color: var(--text);
    transition: border-color 0.2s;
}

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

textarea {
    resize: vertical;
    min-height: 100px;
}

.form-select {
    cursor: pointer;
}

/* Hero */
.hero {
    text-align: center;
    padding: 4rem 0;
}

.hero h1 {
    font-size: 2.5rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
}

.hero-subtitle {
    font-size: 1.25rem;
    color: var(--text-muted);
    margin-bottom: 2rem;
}

.hero-actions {
    display: flex;
    gap: 1rem;
    justify-content: center;
}

/* Features */
.features {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 1.5rem;
    padding: 2rem 0;
}

.feature-card {
    background: var(--bg-card);
    padding: 1.5rem;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.feature-icon {
    font-size: 2rem;
    margin-bottom: 0.75rem;
}

.feature-card h3 {
    font-size: 1.125rem;
    margin-bottom: 0.5rem;
}

.feature-card p {
    color: var(--text-muted);
    font-size: 0.875rem;
}

/* Dashboard */
.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 1.5rem;
    padding: 1rem 0;
}

.dashboard-card {
    background: var(--bg-card);
    padding: 1.5rem;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.dashboard-card h3 {
    font-size: 1rem;
    margin-bottom: 1rem;
    color: var(--text-muted);
}

.stats {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1rem;
}

.stat {
    text-align: center;
}

.stat-value {
    display: block;
    font-size: 2rem;
    font-weight: 700;
    color: var(--primary);
}

.stat-label {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.quick-actions {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

/* Learn Page */
.learn-container {
    max-width: 800px;
    margin: 0 auto;
}

.learn-options {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
    margin-bottom: 2rem;
}

.learn-option {
    background: var(--bg-card);
    padding: 1.5rem;
    border: 2px solid var(--border);
    border-radius: var(--radius);
    cursor: pointer;
    text-align: center;
    transition: all 0.2s;
}

.learn-option:hover,
.learn-option.active {
    border-color: var(--primary);
}

.option-icon {
    display: block;
    font-size: 2rem;
    margin-bottom: 0.5rem;
}

.option-title {
    display: block;
    font-weight: 600;
    margin-bottom: 0.25rem;
}

.option-desc {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.category-select {
    background: var(--bg-card);
    padding: 1.5rem;
    border-radius: var(--radius);
    margin-bottom: 2rem;
}

.category-select h3 {
    margin-bottom: 1rem;
}

.category-select .form-select {
    margin-bottom: 1rem;
}

/* Flashcard */
.learn-progress {
    margin-bottom: 2rem;
}

.learn-progress-text {
    display: block;
    text-align: center;
    margin-bottom: 0.5rem;
    color: var(--text-muted);
}

.progress-bar {
    height: 8px;
    background: var(--border);
    border-radius: 4px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: var(--primary);
    transition: width 0.3s;
}

.flashcard {
    background: var(--bg-card);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    overflow: hidden;
}

.flashcard-header {
    display: flex;
    justify-content: space-between;
    padding: 0.75rem 1rem;
    background: var(--bg);
    font-size: 0.75rem;
    color: var(--text-muted);
}

.card-identifier {
    font-family: monospace;
}

.flashcard-content {
    padding: 2rem;
    min-height: 300px;
}

.card-side h2 {
    font-size: 0.875rem;
    color: var(--text-muted);
    margin-bottom: 1rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.side-content {
    font-size: 1.25rem;
    line-height: 1.8;
    white-space: pre-wrap;
}

.side-media img {
    max-width: 100%;
    max-height: 200px;
    margin-top: 1rem;
    border-radius: var(--radius);
}

.flashcard-actions {
    padding: 1.5rem;
    text-align: center;
    border-top: 1px solid var(--border);
}

.answer-buttons {
    display: flex;
    gap: 1rem;
    justify-content: center;
}

/* Complete */
.learn-complete {
    text-align: center;
    padding: 4rem 2rem;
}

.complete-icon {
    font-size: 4rem;
    display: block;
    margin-bottom: 1rem;
}

.complete-actions {
    display: flex;
    gap: 1rem;
    justify-content: center;
    margin-top: 2rem;
}

/* Cards List */
.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
}

.cards-filters {
    display: flex;
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.cards-filters .form-input,
.cards-filters .form-select {
    flex: 1;
    max-width: 300px;
}

.cards-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1rem;
}

.card-item {
    background: var(--bg-card);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    overflow: hidden;
}

.card-item-header {
    display: flex;
    justify-content: space-between;
    padding: 0.75rem 1rem;
    background: var(--bg);
    font-size: 0.75rem;
}

.card-id {
    font-family: monospace;
    color: var(--text-muted);
}

.card-visibility {
    padding: 0.125rem 0.5rem;
    border-radius: 4px;
    font-size: 0.625rem;
    text-transform: uppercase;
    font-weight: 600;
}

.visibility-private {
    background: #fef3c7;
    color: #92400e;
}

.visibility-public_user_card {
    background: #dbeafe;
    color: #1e40af;
}

.visibility-reviewed_card {
    background: #d1fae5;
    color: #065f46;
}

.visibility-official_card {
    background: #e0e7ff;
    color: #3730a3;
}

.card-item-content {
    padding: 1rem;
}

.card-preview {
    font-size: 0.875rem;
    color: var(--text-muted);
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.card-item-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem 1rem;
    border-top: 1px solid var(--border);
}

.card-category {
    font-size: 0.75rem;
    color: var(--text-muted);
}

/* Card Editor */
.card-editor {
    max-width: 800px;
    margin: 0 auto;
}

.editor-section {
    background: var(--bg-card);
    padding: 1.5rem;
    border-radius: var(--radius);
    margin-bottom: 1rem;
}

.editor-tabs {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.tab-btn {
    padding: 0.75rem 1.25rem;
    background: var(--bg);
    border: none;
    border-radius: var(--radius);
    cursor: pointer;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-muted);
}

.tab-btn.active {
    background: var(--primary);
    color: white;
}

.tab-content {
    display: none;
    background: var(--bg-card);
    padding: 1.5rem;
    border-radius: var(--radius);
}

.tab-content.active {
    display: block;
}

.editor-field {
    margin-bottom: 1.5rem;
}

.editor-field label {
    display: block;
    font-size: 0.875rem;
    font-weight: 500;
    margin-bottom: 0.5rem;
}

.char-count {
    display: block;
    text-align: right;
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 0.25rem;
}

.editor-actions {
    display: flex;
    justify-content: flex-end;
    gap: 1rem;
    margin-top: 1.5rem;
}

/* Preview */
.preview-container {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

.preview-card {
    border: 2px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
}

.preview-header {
    padding: 0.5rem 1rem;
    background: var(--bg);
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    color: var(--text-muted);
}

.preview-content {
    padding: 1rem;
    min-height: 100px;
}

.preview-media {
    padding: 0 1rem 1rem;
}

.preview-media img {
    max-width: 100%;
    border-radius: var(--radius);
}

/* Empty/Loading states */
.loading, .empty-state, .error {
    text-align: center;
    padding: 3rem;
    color: var(--text-muted);
}

/* Responsive */
@media (max-width: 768px) {
    .header-content {
        flex-wrap: wrap;
    }

    .nav {
        order: 3;
        width: 100%;
        justify-content: center;
        gap: 1rem;
        padding-top: 1rem;
        border-top: 1px solid var(--border);
        margin-top: 1rem;
    }

    .hero h1 {
        font-size: 1.75rem;
    }

    .hero-actions {
        flex-direction: column;
    }

    .dashboard-grid {
        grid-template-columns: 1fr;
    }

    .cards-filters {
        flex-direction: column;
    }

    .cards-filters .form-input,
    .cards-filters .form-select {
        max-width: none;
    }

    .preview-container {
        grid-template-columns: 1fr;
    }
}

/* Auth Styles */
.auth-container {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 60vh;
    padding: 2rem 0;
}

.auth-card {
    background: var(--bg-card);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    padding: 2rem;
    width: 100%;
    max-width: 400px;
}

.auth-card h1 {
    text-align: center;
    margin-bottom: 1.5rem;
    font-size: 1.5rem;
}

.auth-card .form-group {
    margin-bottom: 1rem;
}

.auth-card label {
    display: block;
    font-weight: 500;
    margin-bottom: 0.25rem;
}

.auth-card input[type="text"],
.auth-card input[type="email"],
.auth-card input[type="password"] {
    width: 100%;
    padding: 0.625rem 0.75rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 1rem;
}

.auth-card input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.auth-card small {
    color: var(--text-muted);
    font-size: 0.875rem;
}

.auth-card .form-check {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.auth-card .form-check input {
    width: auto;
}

.auth-card .btn-block {
    width: 100%;
    margin-top: 1rem;
}

.auth-footer {
    text-align: center;
    margin-top: 1.5rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--border);
    color: var(--text-muted);
}

.auth-footer a {
    color: var(--primary);
    text-decoration: none;
}

.auth-footer a:hover {
    text-decoration: underline;
}

/* User Menu */
.user-menu {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-left: 1rem;
    padding-left: 1rem;
    border-left: 1px solid var(--border);
}

.user-name {
    font-weight: 500;
    color: var(--text);
}

/* Alerts */
.alert {
    padding: 1rem;
    border-radius: var(--radius);
    margin-bottom: 1rem;
}

.alert-success {
    background: #dcfce7;
    color: #166534;
    border: 1px solid #86efac;
}

.alert-error {
    background: #fee2e2;
    color: #991b1b;
    border: 1px solid #fca5a5;
}

.alert-info {
    background: #dbeafe;
    color: #1e40af;
    border: 1px solid #93c5fd;
}
