/* =========================================
   CSS VARIABLES & RESET
   ========================================= */
:root {
    --primary: #4f46e5;
    --primary-dark: #3730a3;
    --secondary: #64748b;
    --bg-body: #f8fafc;
    --bg-card: #ffffff;
    --text-main: #0f172a;
    --text-muted: #64748b;
    --border: #e2e8f0;
    --danger: #ef4444;
    --success: #10b981;
    --warning: #f59e0b;
    
    --font-sans: 'Inter', sans-serif;
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    --radius: 0.75rem;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: var(--font-sans); background-color: var(--bg-body); color: var(--text-main); height: 100vh; overflow: hidden; }
button, input, select, textarea { font-family: inherit; }

/* =========================================
   AUTH SCREEN
   ========================================= */
#auth-screen {
    position: fixed; inset: 0; background: linear-gradient(135deg, #1e1b4b 0%, #4f46e5 100%);
    display: flex; align-items: center; justify-content: center; z-index: 5000;
}

.auth-container {
    background: white; padding: 3rem; border-radius: 1rem; width: 100%; max-width: 450px;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
}

.brand-logo {
    text-align: center; margin-bottom: 2rem;
}
.brand-logo h1 { font-size: 2rem; font-weight: 800; color: var(--primary); letter-spacing: -1px; }
.brand-logo p { color: var(--text-muted); margin-top: 0.5rem; }

.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; margin-bottom: 1rem; }

.form-group { margin-bottom: 1.25rem; }
.form-group label { display: block; font-size: 0.85rem; font-weight: 600; color: var(--text-secondary); margin-bottom: 0.5rem; text-transform: uppercase; letter-spacing: 0.5px; }
.form-control {
    width: 100%; padding: 0.875rem 1rem; border: 1px solid var(--border); border-radius: 0.5rem;
    background: #f8fafc; transition: all 0.2s;
}
.form-control:focus { outline: none; border-color: var(--primary); background: white; box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1); }

.btn {
    width: 100%; padding: 0.875rem; border-radius: 0.5rem; font-weight: 600; cursor: pointer;
    transition: transform 0.1s; border: none; display: flex; align-items: center; justify-content: center; gap: 0.5rem;
}
.btn-primary { background: var(--primary); color: white; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-ghost { background: transparent; color: var(--text-muted); margin-top: 1rem; font-size: 0.9rem; }
.btn-ghost:hover { color: var(--primary); text-decoration: underline; }

.auth-toggle { text-align: center; margin-top: 1.5rem; color: var(--text-muted); font-size: 0.9rem; }
.auth-toggle span { color: var(--primary); cursor: pointer; font-weight: 600; }

/* =========================================
   MAIN LAYOUT (Shared)
   ========================================= */
#main-app { display: none; height: 100vh; display: flex; flex-direction: column; }

.top-nav {
    height: 64px; background: white; border-bottom: 1px solid var(--border);
    display: flex; align-items: center; justify-content: space-between; padding: 0 2rem; flex-shrink: 0;
}
.nav-left { font-weight: 700; font-size: 1.25rem; color: var(--primary); display: flex; align-items: center; gap: 10px; }
.nav-right { display: flex; align-items: center; gap: 1.5rem; }
.user-badge { display: flex; align-items: center; gap: 10px; }
.role-badge { 
    padding: 4px 10px; border-radius: 20px; font-size: 0.75rem; font-weight: 700; text-transform: uppercase;
}
.role-subscriber { background: #e0e7ff; color: var(--primary); }
.role-manager { background: #fef3c7; color: #d97706; }
.role-admin { background: #fee2e2; color: #dc2626; }

/* =========================================
   DASHBOARD (Admin/Manager)
   ========================================= */
#dashboard-view { display: none; padding: 2rem; height: calc(100vh - 64px); overflow-y: auto; }

.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 1.5rem; margin-bottom: 2rem; }
.stat-card { background: white; padding: 1.5rem; border-radius: var(--radius); border: 1px solid var(--border); box-shadow: var(--shadow-sm); }
.stat-label { font-size: 0.875rem; color: var(--text-muted); margin-bottom: 0.5rem; }
.stat-value { font-size: 2rem; font-weight: 700; color: var(--text-main); }

.data-table-container { background: white; border-radius: var(--radius); border: 1px solid var(--border); overflow: hidden; box-shadow: var(--shadow-sm); }
.table-header { padding: 1.5rem; border-bottom: 1px solid var(--border); display: flex; justify-content: space-between; align-items: center; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 1rem 1.5rem; text-align: left; border-bottom: 1px solid var(--border); font-size: 0.9rem; }
th { background: #f8fafc; font-weight: 600; color: var(--text-muted); text-transform: uppercase; font-size: 0.75rem; }
tr:last-child td { border-bottom: none; }

.action-btn { padding: 6px 12px; border-radius: 4px; border: 1px solid var(--border); background: white; cursor: pointer; font-size: 0.8rem; }
.btn-delete { color: var(--danger); border-color: #fecaca; }
.btn-delete:hover { background: #fef2f2; }

/* =========================================
   RESUME BUILDER (Subscriber View)
   ========================================= */
#builder-view { display: none; height: calc(100vh - 64px); flex: 1; display: flex; overflow: hidden; }

.sidebar { width: 380px; background: white; border-right: 1px solid var(--border); display: flex; flex-direction: column; flex-shrink: 0; }
.sidebar-header { padding: 1.5rem; border-bottom: 1px solid var(--border); }
.sidebar-body { flex: 1; overflow-y: auto; padding: 1.5rem; }
.sidebar-footer { padding: 1rem; border-top: 1px solid var(--border); background: #f8fafc; display: flex; gap: 10px; }

.accordion-item { border: 1px solid var(--border); border-radius: 6px; margin-bottom: 1rem; overflow: hidden; }
.accordion-header { padding: 1rem; background: #f8fafc; cursor: pointer; display: flex; justify-content: space-between; font-weight: 600; font-size: 0.9rem; }
.accordion-body { padding: 1rem; display: none; }
.accordion-body.open { display: block; }

.preview-area { flex: 1; background: #525659; overflow: auto; padding: 3rem; display: flex; justify-content: center; }

/* Resume Styling */
#resume-canvas { width: 210mm; min-height: 297mm; background: white; box-shadow: 0 20px 50px rgba(0,0,0,0.3); padding: 40px; }

/* Template Styles */
.tpl-modern { font-family: 'Inter', sans-serif; display: grid; grid-template-columns: 35% 65%; height: 100%; padding: 0; }
.tpl-modern .col-left { background: #1e293b; color: white; padding: 30px; }
.tpl-modern .col-right { padding: 40px; }
.tpl-modern h1 { font-size: 2.2rem; margin: 0 0 5px 0; }
.tpl-modern h2 { font-size: 1rem; text-transform: uppercase; letter-spacing: 1px; margin-top: 25px; padding-bottom: 5px; border-bottom: 2px solid #e2e8f0; }
.tpl-modern .col-left h2 { border-color: #475569; color: #94a3b8; }

.tpl-elegant { font-family: 'Playfair Display', serif; color: #222; }
.tpl-elegant header { text-align: center; border-bottom: 1px solid #000; padding-bottom: 20px; margin-bottom: 30px; }
.tpl-elegant h1 { font-size: 3rem; margin-bottom: 10px; font-style: italic; }
.tpl-elegant h2 { font-family: 'Inter', sans-serif; font-size: 0.9rem; text-transform: uppercase; letter-spacing: 2px; color: #666; margin-top: 30px; }

/* Utility */
.hidden { display: none !important; }
.text-sm { font-size: 0.85rem; }
.toast { position: fixed; bottom: 20px; right: 20px; background: #333; color: white; padding: 12px 24px; border-radius: 8px; opacity: 0; transition: opacity 0.3s; pointer-events: none; }
.toast.show { opacity: 1; }

/* Print */
@media print {
    body, #main-app, #builder-view { height: auto; display: block; overflow: visible; background: white; }
    #auth-screen, .top-nav, .sidebar, .toast { display: none !important; }
    #builder-view { display: block; }
    .preview-area { padding: 0; background: white; display: block; }
    #resume-canvas { box-shadow: none; width: 100%; margin: 0; }
    @page { margin: 0; }
    .tpl-modern .col-left { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}