/* =============================================================================
   ADMIN PORTAL - Modern Dashboard Design
   Forces dark theme for admin interface
   ============================================================================= */

/* Force dark mode on admin portal */
.admin-portal {
    --bg-primary: #0f172a;
    --bg-secondary: #1e293b;
    --bg-card: #1e293b;
    --bg-tertiary: #334155;
    --text-primary: #f8fafc;
    --text-secondary: #cbd5e1;
    --text-muted: #64748b;
    --border-primary: #334155;
    --brand-primary: #6366f1;
    --brand-gradient: linear-gradient(135deg, #6366f1 0%, #818cf8 100%);
    color-scheme: dark;
}

/* --- Login Screen --- */
.login-container {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem;
    background: linear-gradient(135deg, #0f172a 0%, #1e293b 100%);
}

.login-card {
    width: 100%;
    max-width: 420px;
    padding: 3rem;
    background: var(--bg-card);
    border: 1px solid var(--border-primary);
    border-radius: 24px;
    box-shadow: var(--shadow-xl);
}

.login-header {
    text-align: center;
    margin-bottom: 2rem;
}

.login-logo {
    width: 64px;
    height: 64px;
    margin-bottom: 1rem;
}

.login-header h1 {
    font-size: 1.75rem;
    margin-bottom: 0.5rem;
}

.login-card .form-group {
    margin-bottom: 1.5rem;
}

.login-card label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 600;
    font-size: 0.875rem;
    color: var(--text-secondary);
}

.login-card label i {
    margin-right: 0.5rem;
    opacity: 0.7;
}

.login-card input {
    width: 100%;
    padding: 1rem;
    font-size: 1rem;
    background: var(--bg-secondary);
    border: 1px solid var(--border-primary);
    border-radius: 12px;
    color: var(--text-primary);
    transition: all 0.2s ease;
}

.login-card input:focus {
    border-color: var(--brand-primary);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

.error-message {
    margin-top: 1rem;
    padding: 0.75rem 1rem;
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid rgba(239, 68, 68, 0.3);
    border-radius: 8px;
    color: #ef4444;
    font-size: 0.875rem;
    text-align: center;
}

/* --- Admin Layout --- */
.admin-layout {
    display: flex;
    min-height: 100vh;
    background: var(--bg-primary);
}

/* --- Sidebar --- */
.admin-sidebar {
    width: 260px;
    background: var(--bg-card);
    border-right: 1px solid var(--border-primary);
    display: flex;
    flex-direction: column;
    position: fixed;
    height: 100vh;
    z-index: 100;
    transition: transform 0.3s ease;
}

.sidebar-header {
    padding: 1.5rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    border-bottom: 1px solid var(--border-primary);
}

.sidebar-logo {
    width: 40px;
    height: 40px;
}

.sidebar-title {
    font-size: 1.25rem;
    font-weight: 800;
    background: var(--brand-gradient);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

.sidebar-nav {
    flex: 1;
    padding: 1rem 0;
}

.nav-item {
    width: 100%;
    padding: 1rem 1.5rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    background: transparent;
    border: none;
    color: var(--text-secondary);
    font-size: 0.95rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    text-align: left;
}

.nav-item i {
    width: 20px;
    text-align: center;
    font-size: 1rem;
}

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

.nav-item.active {
    background: linear-gradient(90deg, rgba(99, 102, 241, 0.15) 0%, transparent 100%);
    color: var(--brand-primary);
    border-left: 3px solid var(--brand-primary);
}

.sidebar-footer {
    padding: 1.5rem;
    border-top: 1px solid var(--border-primary);
}

.admin-user {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 1rem;
}

.user-avatar {
    width: 40px;
    height: 40px;
    background: var(--brand-gradient);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
}

.user-info {
    display: flex;
    flex-direction: column;
}

.user-name {
    font-weight: 600;
    font-size: 0.95rem;
}

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

.btn-logout {
    width: 100%;
    padding: 0.75rem;
    background: transparent;
    border: 1px solid var(--border-primary);
    border-radius: 8px;
    color: var(--text-secondary);
    font-size: 0.875rem;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-logout:hover {
    background: rgba(239, 68, 68, 0.1);
    border-color: #ef4444;
    color: #ef4444;
}

/* --- Main Content --- */
.admin-main {
    flex: 1;
    margin-left: 260px;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

.admin-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 2rem;
    background: var(--bg-card);
    border-bottom: 1px solid var(--border-primary);
    position: sticky;
    top: 0;
    z-index: 50;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.header-left h1 {
    font-size: 1.5rem;
    font-weight: 700;
    margin: 0;
}

.mobile-menu-btn {
    display: none;
    padding: 0.5rem;
    background: transparent;
    border: none;
    color: var(--text-primary);
    font-size: 1.25rem;
    cursor: pointer;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.live-badge {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.375rem 0.75rem;
    background: rgba(16, 185, 129, 0.1);
    border-radius: 50px;
    font-size: 0.75rem;
    font-weight: 600;
    color: #10b981;
    text-transform: uppercase;
}

.live-badge .dot {
    width: 8px;
    height: 8px;
    background: #10b981;
    border-radius: 50%;
    animation: pulse 2s infinite;
}

@keyframes pulse {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0.5;
    }
}

.admin-content {
    flex: 1;
    padding: 2rem;
    overflow-y: auto;
}

/* --- Tab Panels --- */
.tab-panel {
    display: none;
}

.tab-panel.active {
    display: block;
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* --- Stats Cards --- */
.stats-row {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.stat-card {
    background: var(--bg-card);
    border: 1px solid var(--border-primary);
    border-radius: 16px;
    padding: 1.5rem;
    display: flex;
    align-items: center;
    gap: 1rem;
    transition: all 0.3s ease;
}

.stat-card:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow-lg);
}

.stat-icon {
    width: 56px;
    height: 56px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
}

.stat-card.primary .stat-icon {
    background: rgba(99, 102, 241, 0.15);
    color: var(--brand-primary);
}

.stat-card.success .stat-icon {
    background: rgba(16, 185, 129, 0.15);
    color: #10b981;
}

.stat-card.info .stat-icon {
    background: rgba(59, 130, 246, 0.15);
    color: #3b82f6;
}

.stat-card.warning .stat-icon {
    background: rgba(245, 158, 11, 0.15);
    color: #f59e0b;
}

.stat-content {
    display: flex;
    flex-direction: column;
}

.stat-value {
    font-size: 1.75rem;
    font-weight: 800;
    line-height: 1;
}

.stat-label {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-top: 0.25rem;
}

/* --- Analytics Grid --- */
.analytics-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.analytics-card {
    background: var(--bg-card);
    border: 1px solid var(--border-primary);
    border-radius: 16px;
    overflow: hidden;
}

.analytics-card.full-width {
    grid-column: 1 / -1;
}

.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid var(--border-primary);
}

.card-header h3 {
    font-size: 1rem;
    font-weight: 600;
    margin: 0;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.card-header h3 i {
    color: var(--brand-primary);
}

.badge {
    padding: 0.25rem 0.5rem;
    background: var(--bg-secondary);
    border-radius: 6px;
    font-size: 0.7rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
}

.card-body {
    padding: 1rem;
}

/* --- Data Tables --- */
.data-table {
    width: 100%;
    border-collapse: collapse;
}

.data-table th,
.data-table td {
    padding: 0.875rem 1rem;
    text-align: left;
    border-bottom: 1px solid var(--border-primary);
}

.data-table th {
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    background: var(--bg-secondary);
}

.data-table tbody tr:hover {
    background: var(--bg-secondary);
}

.data-table tbody tr:last-child td {
    border-bottom: none;
}

.text-right {
    text-align: right;
}

.loading-cell {
    text-align: center;
    color: var(--text-muted);
    padding: 2rem !important;
}

/* --- Activity Feed --- */
.activity-feed {
    max-height: 300px;
    overflow-y: auto;
}

.activity-item {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0.875rem 0;
    border-bottom: 1px solid var(--border-primary);
}

.activity-item:last-child {
    border-bottom: none;
}

.activity-icon {
    width: 36px;
    height: 36px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.875rem;
}

.activity-icon.view {
    background: rgba(99, 102, 241, 0.15);
    color: var(--brand-primary);
}

.activity-icon.click {
    background: rgba(16, 185, 129, 0.15);
    color: #10b981;
}

.activity-icon.signup {
    background: rgba(245, 158, 11, 0.15);
    color: #f59e0b;
}

.activity-content {
    flex: 1;
}

.activity-text {
    font-size: 0.9rem;
}

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

/* --- Quick Actions --- */
.quick-actions {
    background: var(--bg-card);
    border: 1px solid var(--border-primary);
    border-radius: 16px;
    padding: 1.5rem;
}

.quick-actions h3 {
    font-size: 1rem;
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.quick-actions h3 i {
    color: #f59e0b;
}

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

.action-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    padding: 1.25rem;
    background: var(--bg-secondary);
    border: 1px solid var(--border-primary);
    border-radius: 12px;
    color: var(--text-primary);
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    text-decoration: none;
}

.action-btn i {
    font-size: 1.25rem;
    color: var(--brand-primary);
}

.action-btn:hover {
    background: var(--bg-card);
    border-color: var(--brand-primary);
    transform: translateY(-2px);
}

/* --- Editor Card --- */
.editor-card,
.posts-card,
.leads-card,
.settings-card {
    background: var(--bg-card);
    border: 1px solid var(--border-primary);
    border-radius: 16px;
    margin-bottom: 1.5rem;
    overflow: hidden;
}

.post-form {
    padding: 1.5rem;
}

.form-row {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 1.5rem;
}

.form-group {
    margin-bottom: 1.5rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 600;
    font-size: 0.875rem;
}

.form-group input,
.form-group textarea,
.form-group select {
    width: 100%;
    padding: 0.875rem 1rem;
    background: var(--bg-secondary);
    border: 1px solid var(--border-primary);
    border-radius: 10px;
    color: var(--text-primary);
    font-size: 0.95rem;
    transition: all 0.2s ease;
}

.form-group input:focus,
.form-group textarea:focus {
    border-color: var(--brand-primary);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
    outline: none;
}

.char-counter {
    float: right;
    font-size: 0.75rem;
    font-weight: 400;
    color: var(--text-muted);
}

.field-hint {
    display: block;
    margin-top: 0.375rem;
    font-size: 0.75rem;
    color: var(--text-muted);
}

/* --- Image Upload --- */
.image-upload-tabs {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.tab-btn {
    flex: 1;
    padding: 0.75rem;
    background: var(--bg-secondary);
    border: 1px solid var(--border-primary);
    border-radius: 8px;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    color: var(--text-secondary);
}

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

.image-tab-content {
    display: none;
}

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

.upload-dropzone {
    border: 2px dashed var(--border-primary);
    border-radius: 12px;
    padding: 2rem;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s ease;
}

.upload-dropzone:hover {
    border-color: var(--brand-primary);
    background: rgba(99, 102, 241, 0.05);
}

.upload-dropzone i {
    font-size: 2.5rem;
    color: var(--text-muted);
    margin-bottom: 0.75rem;
}

.upload-dropzone p {
    margin-bottom: 0.5rem;
    color: var(--text-secondary);
}

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

.image-preview {
    margin-top: 1rem;
    border-radius: 12px;
    overflow: hidden;
    border: 1px solid var(--border-primary);
    position: relative;
}

.image-preview img {
    width: 100%;
    max-height: 200px;
    object-fit: cover;
}

.image-preview button {
    position: absolute;
    top: 0.5rem;
    right: 0.5rem;
}

/* --- Form Actions --- */
.form-actions {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding-top: 1rem;
    border-top: 1px solid var(--border-primary);
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
    font-size: 0.9rem;
}

.checkbox-label input[type="checkbox"] {
    width: 18px;
    height: 18px;
    accent-color: var(--brand-primary);
}

/* --- Posts Table --- */
.posts-table .post-info {
    display: flex;
    flex-direction: column;
}

.posts-table .post-title {
    font-weight: 600;
}

.posts-table .post-slug {
    font-size: 0.75rem;
    color: var(--text-muted);
    font-family: monospace;
}

.status-pill {
    display: inline-block;
    padding: 0.25rem 0.75rem;
    border-radius: 50px;
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
}

.status-pill.live {
    background: rgba(16, 185, 129, 0.15);
    color: #10b981;
}

.status-pill.draft {
    background: rgba(245, 158, 11, 0.15);
    color: #f59e0b;
}

.action-icon {
    padding: 0.5rem;
    background: transparent;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    color: var(--text-secondary);
    transition: all 0.2s ease;
}

.action-icon:hover {
    background: var(--bg-secondary);
    color: var(--brand-primary);
}

.action-icon.delete:hover {
    color: #ef4444;
    background: rgba(239, 68, 68, 0.1);
}

.post-count {
    font-size: 0.85rem;
    color: var(--text-muted);
}

/* --- Leads Section --- */
.leads-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
    gap: 1rem;
}

.leads-stats {
    display: flex;
    gap: 2rem;
}

.lead-stat {
    display: flex;
    flex-direction: column;
}

.lead-stat-value {
    font-size: 2rem;
    font-weight: 800;
    background: var(--brand-gradient);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

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

.leads-actions {
    display: flex;
    gap: 0.75rem;
}

.search-box {
    position: relative;
}

.search-box i {
    position: absolute;
    left: 1rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
}

.search-box input {
    padding: 0.5rem 1rem 0.5rem 2.5rem;
    background: var(--bg-secondary);
    border: 1px solid var(--border-primary);
    border-radius: 8px;
    color: var(--text-primary);
    width: 200px;
}

/* --- Settings --- */
.settings-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1.5rem;
}

.setting-item {
    margin-bottom: 1.25rem;
}

.setting-item label {
    display: block;
    margin-bottom: 0.5rem;
    font-size: 0.85rem;
    color: var(--text-muted);
}

.setting-item input,
.setting-item select {
    width: 100%;
    padding: 0.75rem 1rem;
    background: var(--bg-secondary);
    border: 1px solid var(--border-primary);
    border-radius: 8px;
    color: var(--text-primary);
}

.setting-item input:disabled,
.setting-item select:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.toggle-switch {
    position: relative;
    display: inline-block;
    width: 44px;
    height: 24px;
}

.toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.toggle-slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--bg-secondary);
    border-radius: 24px;
    transition: 0.3s;
}

.toggle-slider:before {
    position: absolute;
    content: "";
    height: 18px;
    width: 18px;
    left: 3px;
    bottom: 3px;
    background: white;
    border-radius: 50%;
    transition: 0.3s;
}

.toggle-switch input:checked+.toggle-slider {
    background: var(--brand-primary);
}

.toggle-switch input:checked+.toggle-slider:before {
    transform: translateX(20px);
}

.debug-console {
    background: #0a0f1a;
    border: 1px solid var(--border-primary);
    border-radius: 8px;
    max-height: 200px;
    overflow: hidden;
}

.debug-console:not(.hidden) {
    display: block;
}

.debug-content {
    padding: 1rem;
    font-family: 'JetBrains Mono', 'Fira Code', monospace;
    font-size: 0.8rem;
    color: #10b981;
    max-height: 180px;
    overflow-y: auto;
}

.debug-entry {
    margin-bottom: 0.25rem;
    padding-bottom: 0.25rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.system-info {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.info-row {
    display: flex;
    justify-content: space-between;
    padding: 0.5rem 0;
    border-bottom: 1px solid var(--border-primary);
    font-size: 0.9rem;
}

.info-row:last-child {
    border-bottom: none;
}

.info-value {
    color: var(--text-muted);
}

/* --- Quill Editor Override --- */
#editor-container {
    background: var(--bg-secondary);
    border: 1px solid var(--border-primary);
    border-radius: 10px;
    min-height: 300px;
}

#editor-container .ql-toolbar {
    border: none;
    border-bottom: 1px solid var(--border-primary);
    background: var(--bg-card);
    border-radius: 10px 10px 0 0;
}

#editor-container .ql-container {
    border: none;
    font-size: 1rem;
}

#editor-container .ql-editor {
    min-height: 250px;
    color: var(--text-primary);
}

#editor-container .ql-editor.ql-blank::before {
    color: var(--text-muted);
    font-style: normal;
}

/* --- Mobile Responsive --- */
@media (max-width: 1024px) {
    .stats-row {
        grid-template-columns: repeat(2, 1fr);
    }

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

    .actions-grid {
        grid-template-columns: repeat(2, 1fr);
    }

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

@media (max-width: 768px) {
    .admin-sidebar {
        transform: translateX(-100%);
        width: 280px;
        box-shadow: 20px 0 50px rgba(0, 0, 0, 0.5);
    }

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

    .admin-main {
        margin-left: 0;
        width: 100%;
    }

    .admin-header {
        padding: 1rem;
    }

    .mobile-menu-btn {
        display: block;
    }

    .header-right .btn-sm span {
        display: none;
        /* Hide text on very small screens if any */
    }

    .admin-content {
        padding: 1rem;
    }

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

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

    /* Responsive Tables */
    .card-body {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    .data-table {
        min-width: 500px;
        /* Force scroll on very narrow screens */
    }

    .leads-header {
        flex-direction: column;
        align-items: stretch;
    }

    .leads-stats {
        flex-direction: column;
        gap: 1rem;
    }

    .leads-actions {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 0.5rem;
    }

    .leads-actions .btn {
        width: 100%;
        justify-content: center;
    }

    .search-box input {
        width: 100%;
    }

    /* Editor height on mobile */
    #editor-container {
        min-height: 200px;
    }
}

@media (max-width: 480px) {
    .stat-card {
        padding: 1rem;
    }

    .stat-value {
        font-size: 1.5rem;
    }

    .header-right {
        gap: 0.5rem;
    }

    .live-badge {
        display: none;
        /* Hide to save space */
    }
}

/* --- Hidden Utility --- */
.hidden {
    display: none !important;
}