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

:root {
    --primary: #4F46E5;
    --primary-hover: #4338CA;
    --primary-light: #EEF2FF;
    --gray-50: #F9FAFB;
    --gray-100: #F3F4F6;
    --gray-200: #E5E7EB;
    --gray-300: #D1D5DB;
    --gray-400: #9CA3AF;
    --gray-500: #6B7280;
    --gray-600: #4B5563;
    --gray-700: #374151;
    --gray-800: #1F2937;
    --gray-900: #111827;
    --red: #EF4444;
    --red-light: #FEE2E2;
    --green: #10B981;
    --green-light: #D1FAE5;
    --yellow: #F59E0B;
    --yellow-light: #FEF3C7;
    --blue: #3B82F6;
    --shadow-sm: 0 1px 2px rgba(0,0,0,0.05);
    --shadow: 0 1px 3px rgba(0,0,0,0.1), 0 1px 2px rgba(0,0,0,0.06);
    --shadow-md: 0 4px 6px rgba(0,0,0,0.1), 0 2px 4px rgba(0,0,0,0.06);
    --shadow-lg: 0 10px 15px rgba(0,0,0,0.1), 0 4px 6px rgba(0,0,0,0.05);
    --radius: 8px;
    --radius-lg: 12px;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--gray-50);
    color: var(--gray-900);
    line-height: 1.6;
    min-height: 100vh;
}

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

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

.auth-card {
    background: #fff;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    padding: 40px;
}

.auth-header {
    text-align: center;
    margin-bottom: 32px;
}

.auth-header h1 {
    font-size: 32px;
    font-weight: 800;
    color: var(--primary);
    letter-spacing: -0.5px;
}

.auth-header p {
    color: var(--gray-500);
    margin-top: 4px;
    font-size: 14px;
}

#auth-tabs {
    display: flex;
    background: var(--gray-100);
    border-radius: var(--radius);
    padding: 4px;
    margin-bottom: 24px;
}

#auth-tabs .tab {
    flex: 1;
    padding: 10px;
    border: none;
    background: transparent;
    color: var(--gray-500);
    font-size: 14px;
    font-weight: 600;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s;
}

#auth-tabs .tab.active {
    background: #fff;
    color: var(--gray-900);
    box-shadow: var(--shadow-sm);
}

.auth-form {
    display: none;
}

.auth-form.active {
    display: block;
}

.form-group {
    margin-bottom: 16px;
}

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

.form-group input,
.form-group textarea,
.form-group select {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid var(--gray-300);
    border-radius: var(--radius);
    font-size: 14px;
    font-family: inherit;
    transition: border-color 0.2s, box-shadow 0.2s;
    background: #fff;
    color: var(--gray-900);
}

.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(79, 70, 229, 0.1);
}

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

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

.form-success {
    color: var(--green);
    font-size: 13px;
    margin-bottom: 12px;
    min-height: 20px;
}

.btn-primary {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 20px;
    background: var(--primary);
    color: #fff;
    border: none;
    border-radius: var(--radius);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s, transform 0.1s;
    text-decoration: none;
    font-family: inherit;
}

.btn-primary:hover { background: var(--primary-hover); }
.btn-primary:active { transform: scale(0.98); }

.btn-secondary {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 20px;
    background: #fff;
    color: var(--gray-700);
    border: 1px solid var(--gray-300);
    border-radius: var(--radius);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    text-decoration: none;
    font-family: inherit;
}

.btn-secondary:hover {
    background: var(--gray-50);
    border-color: var(--gray-400);
}

.btn-danger {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 20px;
    background: var(--red);
    color: #fff;
    border: none;
    border-radius: var(--radius);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    font-family: inherit;
}

.btn-danger:hover { background: #DC2626; }

.btn-full { width: 100%; }

.btn-sm {
    padding: 6px 12px;
    font-size: 13px;
}

.btn-icon {
    padding: 8px;
    background: transparent;
    border: none;
    color: var(--gray-500);
    cursor: pointer;
    border-radius: var(--radius);
    transition: all 0.2s;
}

.btn-icon:hover {
    background: var(--gray-100);
    color: var(--gray-700);
}

.admin-layout {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    width: 260px;
    background: #fff;
    border-right: 1px solid var(--gray-200);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 40;
    transition: transform 0.3s;
}

.sidebar-brand {
    padding: 20px 24px;
    border-bottom: 1px solid var(--gray-200);
    display: flex;
    align-items: center;
    gap: 12px;
}

.sidebar-brand .logo {
    width: 36px;
    height: 36px;
    background: var(--primary);
    border-radius: var(--radius);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-weight: 800;
    font-size: 18px;
}

.sidebar-brand h2 {
    font-size: 18px;
    font-weight: 700;
    color: var(--gray-900);
}

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

.nav-section {
    margin-bottom: 24px;
}

.nav-section-title {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--gray-400);
    padding: 0 12px;
    margin-bottom: 8px;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    border-radius: var(--radius);
    color: var(--gray-600);
    text-decoration: none;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.15s;
    margin-bottom: 2px;
}

.nav-item:hover {
    background: var(--gray-50);
    color: var(--gray-900);
}

.nav-item.active {
    background: var(--primary-light);
    color: var(--primary);
}

.nav-item svg {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
}

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

.plan-badge {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.plan-free { background: var(--gray-100); color: var(--gray-600); }
.plan-pro { background: var(--primary-light); color: var(--primary); }
.plan-enterprise { background: #FEF3C7; color: #92400E; }

.usage-bar {
    margin-top: 12px;
}

.usage-label {
    font-size: 12px;
    color: var(--gray-500);
    margin-bottom: 4px;
    display: flex;
    justify-content: space-between;
}

.usage-progress {
    height: 6px;
    background: var(--gray-200);
    border-radius: 3px;
    overflow: hidden;
}

.usage-fill {
    height: 100%;
    background: var(--primary);
    border-radius: 3px;
    transition: width 0.3s;
}

.main-content {
    flex: 1;
    margin-left: 260px;
    min-width: 0;
}

.topbar {
    background: #fff;
    border-bottom: 1px solid var(--gray-200);
    padding: 0 24px;
    height: 64px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 30;
}

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

.sidebar-toggle {
    display: none;
    padding: 8px;
    background: transparent;
    border: none;
    color: var(--gray-500);
    cursor: pointer;
    border-radius: var(--radius);
}

.sidebar-toggle:hover { background: var(--gray-100); }

.topbar-right {
    display: flex;
    align-items: center;
    gap: 16px;
}

.user-menu {
    position: relative;
}

.user-menu-btn {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 6px 12px;
    background: transparent;
    border: 1px solid var(--gray-200);
    border-radius: var(--radius);
    cursor: pointer;
    font-family: inherit;
    font-size: 14px;
    color: var(--gray-700);
    transition: all 0.2s;
}

.user-menu-btn:hover { background: var(--gray-50); }

.user-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--primary);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    font-weight: 600;
}

.user-dropdown {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    background: #fff;
    border: 1px solid var(--gray-200);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    min-width: 220px;
    padding: 8px;
    display: none;
    z-index: 50;
}

.user-dropdown.show { display: block; }

.user-dropdown-header {
    padding: 12px;
    border-bottom: 1px solid var(--gray-200);
    margin-bottom: 4px;
}

.user-dropdown-header .name {
    font-weight: 600;
    font-size: 14px;
    color: var(--gray-900);
}

.user-dropdown-header .email {
    font-size: 12px;
    color: var(--gray-500);
}

.dropdown-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border-radius: 6px;
    color: var(--gray-700);
    text-decoration: none;
    font-size: 14px;
    transition: all 0.15s;
    cursor: pointer;
    border: none;
    background: none;
    width: 100%;
    text-align: left;
    font-family: inherit;
}

.dropdown-item:hover { background: var(--gray-50); }
.dropdown-item.danger { color: var(--red); }
.dropdown-item.danger:hover { background: var(--red-light); }

.page-content {
    padding: 24px;
}

.page-header {
    margin-bottom: 24px;
}

.page-header h1 {
    font-size: 24px;
    font-weight: 700;
    color: var(--gray-900);
}

.page-header p {
    color: var(--gray-500);
    font-size: 14px;
    margin-top: 4px;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.stat-card {
    background: #fff;
    border: 1px solid var(--gray-200);
    border-radius: var(--radius-lg);
    padding: 20px;
}

.stat-card .stat-icon {
    width: 40px;
    height: 40px;
    border-radius: var(--radius);
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 12px;
}

.stat-card .stat-value {
    font-size: 28px;
    font-weight: 700;
    color: var(--gray-900);
}

.stat-card .stat-label {
    font-size: 13px;
    color: var(--gray-500);
    margin-top: 2px;
}

.card {
    background: #fff;
    border: 1px solid var(--gray-200);
    border-radius: var(--radius-lg);
    padding: 24px;
    margin-bottom: 24px;
}

.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--gray-100);
}

.card-header h2 {
    font-size: 18px;
    font-weight: 600;
    color: var(--gray-900);
}

.table-container {
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
}

table th, table td {
    padding: 12px 16px;
    text-align: left;
    border-bottom: 1px solid var(--gray-100);
    font-size: 14px;
}

table th {
    font-weight: 600;
    color: var(--gray-500);
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    background: var(--gray-50);
}

table tbody tr:hover { background: var(--gray-50); }

.badge {
    display: inline-block;
    padding: 2px 10px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 500;
}

.badge-published { background: var(--green-light); color: #065F46; }
.badge-draft { background: var(--yellow-light); color: #92400E; }
.badge-archived { background: var(--gray-100); color: var(--gray-600); }

.actions-cell {
    display: flex;
    gap: 4px;
}

.empty-state {
    text-align: center;
    padding: 48px 24px;
    color: var(--gray-500);
}

.empty-state svg {
    width: 64px;
    height: 64px;
    margin-bottom: 16px;
    opacity: 0.4;
}

.empty-state h3 {
    font-size: 18px;
    font-weight: 600;
    color: var(--gray-700);
    margin-bottom: 8px;
}

.empty-state p {
    font-size: 14px;
    margin-bottom: 20px;
}

.modal-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.5);
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.modal {
    background: #fff;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    width: 100%;
    max-width: 640px;
    max-height: 90vh;
    overflow-y: auto;
}

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

.modal-header h3 {
    font-size: 18px;
    font-weight: 600;
}

.modal-body {
    padding: 24px;
}

.modal-footer {
    padding: 16px 24px;
    border-top: 1px solid var(--gray-200);
    display: flex;
    justify-content: flex-end;
    gap: 12px;
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

.form-inline {
    display: flex;
    gap: 12px;
    align-items: end;
}

.color-picker {
    display: flex;
    align-items: center;
    gap: 10px;
}

.color-picker input[type="color"] {
    width: 40px;
    height: 40px;
    border: 1px solid var(--gray-300);
    border-radius: var(--radius);
    cursor: pointer;
    padding: 2px;
}

.toast {
    position: fixed;
    bottom: 24px;
    right: 24px;
    background: var(--gray-900);
    color: #fff;
    padding: 12px 20px;
    border-radius: var(--radius);
    font-size: 14px;
    font-weight: 500;
    z-index: 200;
    opacity: 0;
    transform: translateY(10px);
    transition: all 0.3s;
    pointer-events: none;
}

.toast.show {
    opacity: 1;
    transform: translateY(0);
}

.toast.success { background: var(--green); }
.toast.error { background: var(--red); }

.loading-spinner {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 2px solid rgba(255,255,255,0.3);
    border-top-color: #fff;
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}

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

.loading-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(255,255,255,0.8);
    z-index: 150;
    display: flex;
    align-items: center;
    justify-content: center;
}

.loading-overlay .loading-spinner {
    width: 40px;
    height: 40px;
    border-color: rgba(79, 70, 229, 0.2);
    border-top-color: var(--primary);
}

.social-links-editor {
    margin-top: 16px;
}

.social-link-row {
    display: flex;
    gap: 12px;
    align-items: center;
    padding: 12px;
    background: var(--gray-50);
    border-radius: var(--radius);
    margin-bottom: 8px;
}

.social-link-row select,
.social-link-row input {
    padding: 8px 12px;
    border: 1px solid var(--gray-300);
    border-radius: 6px;
    font-size: 13px;
    font-family: inherit;
}

.social-link-row select { width: 140px; flex-shrink: 0; }
.social-link-row input { flex: 1; }

.template-preview {
    border: 2px solid var(--gray-200);
    border-radius: var(--radius-lg);
    padding: 20px;
    margin-top: 16px;
    background: var(--gray-50);
}

.template-selector {
    display: flex;
    gap: 16px;
    margin-bottom: 20px;
}

.template-option {
    flex: 1;
    padding: 20px;
    border: 2px solid var(--gray-200);
    border-radius: var(--radius-lg);
    text-align: center;
    cursor: pointer;
    transition: all 0.2s;
    background: #fff;
}

.template-option:hover { border-color: var(--primary); }
.template-option.selected {
    border-color: var(--primary);
    background: var(--primary-light);
}

.template-option .template-letter {
    font-size: 36px;
    font-weight: 800;
    color: var(--primary);
    margin-bottom: 8px;
}

.template-option .template-desc {
    font-size: 13px;
    color: var(--gray-500);
}

.region-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 8px;
    max-height: 400px;
    overflow-y: auto;
    padding: 4px;
}

.region-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    border: 1px solid var(--gray-200);
    border-radius: var(--radius);
    cursor: pointer;
    transition: all 0.15s;
    font-size: 13px;
}

.region-item:hover { border-color: var(--primary); background: var(--primary-light); }
.region-item.selected {
    border-color: var(--primary);
    background: var(--primary-light);
}

.region-item input[type="checkbox"] { accent-color: var(--primary); }

.ai-section {
    border: 2px dashed var(--gray-300);
    border-radius: var(--radius-lg);
    padding: 24px;
    margin-top: 20px;
}

.ai-section h3 {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 8px;
}

.ai-section p {
    font-size: 13px;
    color: var(--gray-500);
    margin-bottom: 16px;
}

.tabs {
    display: flex;
    border-bottom: 2px solid var(--gray-200);
    margin-bottom: 20px;
}

.tabs .tab-item {
    padding: 12px 20px;
    border: none;
    background: transparent;
    color: var(--gray-500);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    transition: all 0.2s;
    font-family: inherit;
}

.tabs .tab-item:hover { color: var(--gray-700); }
.tabs .tab-item.active {
    color: var(--primary);
    border-bottom-color: var(--primary);
}

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

@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
    }

    .sidebar.open {
        transform: translateX(0);
    }

    .main-content {
        margin-left: 0;
    }

    .sidebar-toggle {
        display: block;
    }

    .form-row {
        grid-template-columns: 1fr;
    }

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

    .auth-card {
        padding: 24px;
    }
}

.main-area {
    flex: 1;
    min-width: 0;
    margin-left: 260px;
    display: flex;
    flex-direction: column;
}

.main-area .content {
    padding: 24px;
    flex: 1;
}

.user-menu-trigger {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 6px 12px;
    background: transparent;
    border: 1px solid var(--gray-200);
    border-radius: var(--radius);
    cursor: pointer;
    font-family: inherit;
    font-size: 14px;
    color: var(--gray-700);
    transition: all 0.2s;
}

.user-menu-trigger:hover { background: var(--gray-50); }

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

.user-menu-trigger .chevron {
    transition: transform 0.2s;
    margin-left: 4px;
}

.user-dropdown.open { display: block; }

.user-dropdown .dropdown-header {
    padding: 12px;
    border-bottom: 1px solid var(--gray-200);
    margin-bottom: 4px;
}

.dropdown-name {
    font-weight: 600;
    font-size: 14px;
    color: var(--gray-900);
    display: block;
}

.dropdown-email {
    font-size: 12px;
    color: var(--gray-500);
}

.dropdown-logout {
    color: var(--red);
}

.dropdown-logout:hover { background: var(--red-light); }

.sidebar-logo {
    font-size: 22px;
    font-weight: 800;
    color: var(--primary);
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 10px;
}

.page-usage {
    margin-top: 12px;
}

.page-usage-label {
    font-size: 12px;
    color: var(--gray-500);
    margin-bottom: 4px;
}

.page-usage-bar {
    height: 6px;
    background: var(--gray-200);
    border-radius: 3px;
    overflow: hidden;
}

.page-usage-fill {
    height: 100%;
    background: var(--primary);
    border-radius: 3px;
    transition: width 0.3s;
}

.page-title {
    font-size: 24px;
    font-weight: 700;
    color: var(--gray-900);
}

.page-subtitle {
    color: var(--gray-500);
    font-size: 14px;
    margin-top: 4px;
}

.quick-actions {
    margin-top: 32px;
}

.section-title {
    font-size: 18px;
    font-weight: 600;
    color: var(--gray-900);
    margin-bottom: 16px;
}

.actions-row {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 16px;
}

.action-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    padding: 24px;
    background: #fff;
    border: 1px solid var(--gray-200);
    border-radius: var(--radius-lg);
    color: var(--gray-700);
    text-decoration: none;
    transition: all 0.2s;
    text-align: center;
}

.action-card:hover {
    border-color: var(--primary);
    background: var(--primary-light);
    color: var(--primary);
    transform: translateY(-2px);
    box-shadow: var(--shadow);
}

.stat-body {
    margin-top: 4px;
}

.stat-icon-pages { background: var(--primary-light); color: var(--primary); }
.stat-icon-published { background: var(--green-light); color: #065F46; }
.stat-icon-visitors { background: var(--yellow-light); color: #92400E; }

.nav-icon {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
}

.sidebar-collapsed .sidebar {
    transform: translateX(-100%);
}

.sidebar-collapsed .main-area,
.sidebar-collapsed .main-content {
    margin-left: 0;
}

@media (max-width: 768px) {
    .main-area {
        margin-left: 0;
    }
}
