:root {
    --primary: #4f46e5;
    --primary-dark: #4338ca;
    --text: #1a1a2e;
    --text-muted: #64748b;
    --bg: #f8fafc;
    --card-bg: #ffffff;
    --border: #e2e8f0;
    --success: #10b981;
    --error: #ef4444;
    --sidebar-width: 260px;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    color: var(--text);
    line-height: 1.5;
    background: var(--bg);
    min-height: 100vh;
}

/* Auth Pages */
.auth-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

.auth-container {
    width: 100%;
    max-width: 420px;
    padding: 20px;
}

.auth-card {
    background: white;
    border-radius: 16px;
    padding: 40px;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.2);
}

.auth-logo {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    font-size: 24px;
    font-weight: 700;
    color: var(--text);
    text-decoration: none;
    margin-bottom: 32px;
}

.logo-icon {
    font-size: 32px;
}

.auth-form h1 {
    font-size: 24px;
    margin-bottom: 8px;
    text-align: center;
}

.auth-subtitle {
    color: var(--text-muted);
    text-align: center;
    margin-bottom: 24px;
}

.auth-switch {
    text-align: center;
    margin-top: 24px;
    color: var(--text-muted);
}

.auth-switch a {
    color: var(--primary);
    text-decoration: none;
    font-weight: 500;
}

/* Google button */
.btn-google {
    background: white;
    border: 1px solid var(--border);
    color: var(--text);
    gap: 12px;
}

.btn-google:hover {
    background: #f8f8f8;
    border-color: #ccc;
}

.btn-google svg {
    flex-shrink: 0;
}

/* Auth divider */
.auth-divider {
    display: flex;
    align-items: center;
    margin: 20px 0;
    color: var(--text-muted);
    font-size: 14px;
}

.auth-divider::before,
.auth-divider::after {
    content: '';
    flex: 1;
    height: 1px;
    background: var(--border);
}

.auth-divider span {
    padding: 0 12px;
}

/* Forms */
.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    font-size: 14px;
    font-weight: 500;
    margin-bottom: 6px;
    color: var(--text);
}

.form-group input,
.form-group textarea,
.form-group select {
    width: 100%;
    padding: 12px 14px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 15px;
    transition: border-color 0.2s;
}

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

.form-error {
    color: var(--error);
    font-size: 14px;
    margin-bottom: 16px;
    min-height: 20px;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 24px;
    font-size: 15px;
    font-weight: 500;
    text-decoration: none;
    border-radius: 8px;
    border: none;
    cursor: pointer;
    transition: all 0.2s;
}

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

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

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

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

.btn-ghost {
    background: transparent;
    color: var(--text-muted);
}

.btn-block {
    width: 100%;
}

.btn-sm {
    padding: 8px 16px;
    font-size: 13px;
}

.btn-loader {
    width: 16px;
    height: 16px;
    border: 2px solid #fff;
    border-top-color: transparent;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

/* Dashboard Layout */
.dashboard-layout {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    width: var(--sidebar-width);
    background: var(--card-bg);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
}

.sidebar-logo {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 24px;
    font-size: 18px;
    font-weight: 700;
    color: var(--text);
    text-decoration: none;
    border-bottom: 1px solid var(--border);
}

.sidebar-nav {
    flex: 1;
    padding: 16px 12px;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    color: var(--text-muted);
    text-decoration: none;
    border-radius: 8px;
    margin-bottom: 4px;
    transition: all 0.2s;
}

.nav-item:hover {
    background: var(--bg);
    color: var(--text);
}

.nav-item.active {
    background: #eef2ff;
    color: var(--primary);
    font-weight: 500;
}

.nav-icon {
    font-size: 18px;
}

.sidebar-user {
    padding: 16px;
    border-top: 1px solid var(--border);
}

.user-info {
    display: flex;
    flex-direction: column;
    margin-bottom: 12px;
}

.user-name {
    font-weight: 500;
}

.user-plan {
    font-size: 12px;
    color: var(--primary);
    text-transform: uppercase;
}

/* Main Content */
.main-content {
    flex: 1;
    margin-left: var(--sidebar-width);
    padding: 32px;
}

.content-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 32px;
}

.content-header h1 {
    font-size: 28px;
}

/* Flipbooks Grid */
.flipbooks-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 24px;
}

.flipbook-card {
    background: var(--card-bg);
    border-radius: 12px;
    border: 1px solid var(--border);
    overflow: hidden;
    transition: transform 0.2s, box-shadow 0.2s;
}

.flipbook-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
}

.flipbook-thumbnail {
    width: 100%;
    height: 180px;
    background: var(--bg);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 48px;
}

.flipbook-thumbnail img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.flipbook-info {
    padding: 16px;
}

.flipbook-title {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 8px;
}

.flipbook-meta {
    display: flex;
    justify-content: space-between;
    font-size: 13px;
    color: var(--text-muted);
    margin-bottom: 12px;
}

.flipbook-actions {
    display: flex;
    gap: 8px;
}

/* Empty State */
.empty-state {
    text-align: center;
    padding: 60px 20px;
}

.empty-icon {
    font-size: 64px;
    margin-bottom: 16px;
}

.empty-state h2 {
    font-size: 24px;
    margin-bottom: 8px;
}

.empty-state p {
    color: var(--text-muted);
    margin-bottom: 24px;
}

/* Loading State */
.loading-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-muted);
}

.spinner {
    width: 40px;
    height: 40px;
    border: 3px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 16px;
}

/* Modal */
.modal {
    position: fixed;
    inset: 0;
    z-index: 1000;
}

.modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
}

.modal-content {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: white;
    border-radius: 16px;
    width: 90%;
    max-width: 500px;
    max-height: 90vh;
    overflow: auto;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 24px;
    border-bottom: 1px solid var(--border);
}

.modal-header h2 {
    font-size: 18px;
}

.modal-close {
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: var(--text-muted);
}

.modal-body {
    padding: 24px;
}

/* Responsive */
@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
        z-index: 100;
        transition: transform 0.3s ease;
    }

    .sidebar.show {
        transform: translateX(0);
        box-shadow: 5px 0 15px rgba(0, 0, 0, 0.1);
    }

    .main-content {
        margin-left: 0;
        padding: 20px;
    }

    .content-header h1 {
        font-size: 24px;
    }
}

.sidebar-toggle {
    display: none;
    font-size: 24px;
    padding: 8px;
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text);
    margin-right: 8px;
}

@media (max-width: 768px) {
    .sidebar-toggle {
        display: flex;
        align-items: center;
        justify-content: center;
    }
}

/* Upload page */
.upload-container {
    max-width: 600px;
}

.upload-form {
    background: var(--card-bg);
    padding: 32px;
    border-radius: 12px;
    border: 1px solid var(--border);
}

.form-hint {
    font-size: 13px;
    color: var(--text-muted);
    margin-top: 8px;
}

.form-hint a {
    color: var(--primary);
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    font-weight: normal;
}

.checkbox-label input[type="checkbox"] {
    width: 18px;
    height: 18px;
    cursor: pointer;
}

.form-actions {
    display: flex;
    gap: 12px;
    justify-content: flex-end;
    margin-top: 24px;
}

/* File upload area */
.file-upload-area {
    border: 2px dashed var(--border);
    border-radius: 12px;
    padding: 40px 20px;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s;
    position: relative;
}

.file-upload-area:hover,
.file-upload-area.drag-over {
    border-color: var(--primary);
    background: #f5f3ff;
}

.file-upload-area input[type="file"] {
    position: absolute;
    inset: 0;
    opacity: 0;
    cursor: pointer;
}

.file-icon {
    font-size: 48px;
    display: block;
    margin-bottom: 12px;
}

.file-text {
    margin-bottom: 8px;
    color: var(--text);
}

.file-browse {
    color: var(--primary);
    font-weight: 500;
}

.file-hint {
    font-size: 13px;
    color: var(--text-muted);
}

.file-selected {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
}

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

.file-remove {
    background: none;
    border: none;
    font-size: 18px;
    cursor: pointer;
    color: var(--text-muted);
    padding: 4px 8px;
}

.file-remove:hover {
    color: var(--error);
}

/* Upload progress */
.upload-progress {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-top: 16px;
}

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

.progress-fill {
    height: 100%;
    background: var(--primary);
    border-radius: 4px;
    transition: width 0.3s ease;
    width: 0;
}

.progress-text {
    font-size: 13px;
    color: var(--text-muted);
    min-width: 120px;
}

/* Settings page */
.settings-container {
    max-width: 640px;
}

.settings-section {
    background: var(--card-bg);
    padding: 28px 32px;
    border-radius: 12px;
    border: 1px solid var(--border);
    margin-bottom: 24px;
}

.settings-section h2 {
    font-size: 18px;
    margin-bottom: 20px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--border);
}

.settings-form .form-group input:disabled {
    background: var(--bg);
    color: var(--text-muted);
    cursor: not-allowed;
}

.form-actions-left {
    display: flex;
    align-items: center;
    gap: 16px;
}

.save-status {
    font-size: 14px;
    font-weight: 500;
}

/* Plan card */
.plan-card {
    background: linear-gradient(135deg, #f5f3ff, #eef2ff);
    border-radius: 10px;
    padding: 20px;
}

.plan-info {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 16px;
}

.plan-name {
    font-weight: 700;
    font-size: 20px;
    color: var(--primary);
}

.plan-desc {
    color: var(--text-muted);
    font-size: 14px;
}

.plan-usage {
    display: flex;
    align-items: center;
    gap: 12px;
}

.usage-bar-container {
    flex: 1;
    height: 8px;
    background: rgba(0, 0, 0, 0.08);
    border-radius: 4px;
    overflow: hidden;
}

.usage-bar {
    height: 100%;
    background: var(--primary);
    border-radius: 4px;
    transition: width 0.5s ease;
}

.usage-text {
    font-size: 13px;
    color: var(--text-muted);
    white-space: nowrap;
}

.account-info p {
    margin-bottom: 8px;
    color: var(--text-muted);
    font-size: 14px;
}

.account-info strong {
    color: var(--text);
}

/* Color picker */
.color-picker-row {
    display: flex;
    align-items: center;
    gap: 12px;
}

.color-picker-row input[type="color"] {
    width: 48px;
    height: 36px;
    border: 1px solid var(--border);
    border-radius: 8px;
    cursor: pointer;
    padding: 2px;
    background: var(--card-bg);
}

.color-preview-label {
    font-family: monospace;
    font-size: 14px;
    color: var(--text-muted);
}

/* Slug preview */
.slug-preview {
    display: flex;
    align-items: center;
    gap: 0;
    border: 1px solid var(--border);
    border-radius: 8px;
    overflow: hidden;
}

.slug-prefix {
    padding: 10px 12px;
    background: var(--bg);
    color: var(--text-muted);
    font-size: 14px;
    font-family: monospace;
    white-space: nowrap;
    border-right: 1px solid var(--border);
}

.slug-preview input {
    border: none !important;
    border-radius: 0 !important;
    font-family: monospace;
    font-size: 14px;
}

/* Downgrade Banner */
.downgrade-banner {
    display: flex;
    align-items: flex-start;
    gap: 16px;
    background-color: #fffbeb;
    border: 1px solid #fcd34d;
    border-radius: 8px;
    padding: 16px;
    margin-bottom: 24px;
}

.downgrade-icon {
    font-size: 24px;
}

.downgrade-content h3 {
    margin: 0 0 8px 0;
    color: #92400e;
    font-size: 16px;
    font-weight: 600;
}

.downgrade-content p {
    margin: 0 0 8px 0;
    color: #b45309;
    font-size: 14px;
    line-height: 1.5;
}

/* Locked Flipbook Card */
.flipbook-card.flipbook-locked {
    position: relative;
}

.flipbook-card.flipbook-locked .flipbook-thumbnail {
    position: relative;
    filter: grayscale(1);
}

.lock-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.6);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: 500;
    gap: 8px;
    z-index: 10;
}

.lock-icon {
    font-size: 24px;
}

.lock-text {
    font-size: 14px;
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.5);
}