/* ============================================================
   Codesor Admin Panel — Backend CRM Styles
   ============================================================ */

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: #f0f2f5;
    color: #1a1d23;
}

/* ── Login Screen ──────────────────────────────────────────────────── */
.admin-login-screen {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #032f62 0%, #1e3a8a 50%, #312e81 100%);
}

.admin-login-card {
    background: white;
    border-radius: 16px;
    padding: 40px 36px;
    width: 90%;
    max-width: 400px;
    text-align: center;
    box-shadow: 0 25px 60px rgba(0, 0, 0, 0.2);
}

.admin-login-logo {
    margin-bottom: 16px;
}

.admin-login-title {
    margin: 0 0 8px;
    font-size: 24px;
    font-weight: 800;
    color: #032f62;
}

.admin-login-subtitle {
    margin: 0 0 24px;
    font-size: 14px;
    color: #6b7280;
}

.admin-login-form {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.admin-login-form input {
    padding: 14px 16px;
    border: 1.5px solid #e5e7eb;
    border-radius: 10px;
    font-size: 15px;
    font-family: inherit;
    outline: none;
    transition: border-color 0.2s;
}

.admin-login-form input:focus {
    border-color: #032f62;
}

.admin-login-btn {
    padding: 14px;
    background: #032f62;
    color: white;
    border: none;
    border-radius: 10px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s;
}

.admin-login-btn:hover {
    background: #044a8a;
}

.admin-login-error {
    color: #ef4444;
    font-size: 13px;
    min-height: 18px;
    margin: 12px 0 0;
}

.admin-login-back {
    display: inline-block;
    margin-top: 20px;
    color: #6b7280;
    text-decoration: none;
    font-size: 13px;
}

.admin-login-back:hover {
    color: #032f62;
}

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

/* ── Sidebar ───────────────────────────────────────────────────────── */
.admin-sidebar {
    width: 240px;
    background: #032f62;
    color: white;
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    position: sticky;
    top: 0;
    height: 100vh;
}

.admin-sidebar-header {
    padding: 20px 24px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.admin-sidebar-nav {
    flex: 1;
    padding: 16px 0;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.admin-nav-btn {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 24px;
    background: transparent;
    border: none;
    color: rgba(255, 255, 255, 0.7);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    font-family: inherit;
    text-align: left;
}

.admin-nav-btn:hover {
    background: rgba(255, 255, 255, 0.08);
    color: white;
}

.admin-nav-btn.active {
    background: rgba(255, 255, 255, 0.15);
    color: white;
    border-left: 3px solid #60a5fa;
}

.admin-sidebar-footer {
    padding: 16px;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.admin-logout-btn {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 16px;
    background: transparent;
    border: none;
    color: rgba(255, 255, 255, 0.7);
    font-size: 14px;
    cursor: pointer;
    border-radius: 8px;
    transition: all 0.2s;
    font-family: inherit;
}

.admin-logout-btn:hover {
    background: rgba(239, 68, 68, 0.2);
    color: #fca5a5;
}

/* ── Main Content ──────────────────────────────────────────────────── */
.admin-main {
    flex: 1;
    padding: 32px;
    overflow-y: auto;
}

.admin-page {
    display: none;
}

.admin-page.active {
    display: block;
}

.admin-page-title {
    margin: 0 0 24px;
    font-size: 28px;
    font-weight: 800;
    color: #1a1d23;
}

.admin-page-subtitle {
    margin: -16px 0 24px;
    font-size: 14px;
    color: #6b7280;
}

.admin-page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 24px;
    flex-wrap: wrap;
    gap: 16px;
}

/* ── Stats Grid ────────────────────────────────────────────────────── */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 16px;
    margin-bottom: 32px;
}

.stat-card {
    background: white;
    border-radius: 12px;
    padding: 20px;
    display: flex;
    align-items: center;
    gap: 16px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
}

.stat-icon {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.stat-icon-blue { background: #dbeafe; color: #2563eb; }
.stat-icon-green { background: #d1fae5; color: #059669; }
.stat-icon-red { background: #fee2e2; color: #dc2626; }
.stat-icon-purple { background: #ede9fe; color: #7c3aed; }
.stat-icon-cyan { background: #cffafe; color: #0891b2; }
.stat-icon-orange { background: #ffedd5; color: #ea580c; }

.stat-value {
    font-size: 28px;
    font-weight: 800;
    color: #1a1d23;
    line-height: 1;
}

.stat-label {
    font-size: 13px;
    color: #6b7280;
    margin-top: 4px;
}

/* ── Dashboard Row ─────────────────────────────────────────────────── */
.dashboard-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}

.dashboard-card {
    background: white;
    border-radius: 12px;
    padding: 24px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
}

.dashboard-card-title {
    margin: 0 0 16px;
    font-size: 16px;
    font-weight: 700;
    color: #374151;
}

/* ── Plan Distribution ─────────────────────────────────────────────── */
.plan-distribution {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

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

.plan-bar-label {
    width: 100px;
    font-size: 13px;
    font-weight: 600;
    color: #374151;
}

.plan-bar-track {
    flex: 1;
    height: 24px;
    background: #f3f4f6;
    border-radius: 6px;
    overflow: hidden;
}

.plan-bar-fill {
    height: 100%;
    border-radius: 6px;
    display: flex;
    align-items: center;
    padding-left: 8px;
    color: white;
    font-size: 12px;
    font-weight: 600;
    transition: width 0.5s ease;
}

.plan-bar-count {
    width: 40px;
    text-align: right;
    font-size: 13px;
    font-weight: 700;
    color: #1a1d23;
}

/* ── Activity List ─────────────────────────────────────────────────── */
.activity-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-height: 300px;
    overflow-y: auto;
}

.activity-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    background: #f9fafb;
    border-radius: 8px;
    font-size: 13px;
}

.activity-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}

.activity-dot-blue { background: #3b82f6; }
.activity-dot-green { background: #10b981; }
.activity-dot-red { background: #ef4444; }
.activity-dot-purple { background: #8b5cf6; }
.activity-dot-orange { background: #f59e0b; }

.activity-text {
    flex: 1;
    color: #374151;
}

.activity-text strong {
    color: #1a1d23;
}

.activity-time {
    font-size: 11px;
    color: #9ca3af;
    white-space: nowrap;
}

/* ── Search Bar ────────────────────────────────────────────────────── */
.admin-search-bar {
    display: flex;
    align-items: center;
    gap: 8px;
}

.admin-search-bar input {
    padding: 10px 14px;
    border: 1.5px solid #e5e7eb;
    border-radius: 8px;
    font-size: 14px;
    font-family: inherit;
    outline: none;
    min-width: 250px;
}

.admin-search-bar input:focus {
    border-color: #032f62;
}

.admin-search-bar button {
    padding: 10px 20px;
    background: #032f62;
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    font-family: inherit;
}

.admin-checkbox {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    color: #4b5563;
    cursor: pointer;
}

.admin-checkbox input {
    cursor: pointer;
}

/* ── Users Table ───────────────────────────────────────────────────── */
.users-table-wrapper {
    background: white;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
    overflow-x: auto;
}

.users-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}

.users-table th {
    padding: 14px 16px;
    text-align: left;
    font-size: 12px;
    font-weight: 700;
    color: #6b7280;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    background: #f9fafb;
    border-bottom: 2px solid #e5e7eb;
    white-space: nowrap;
}

.users-table td {
    padding: 12px 16px;
    border-bottom: 1px solid #f3f4f6;
    color: #374151;
    white-space: nowrap;
}

.users-table tbody tr:hover {
    background: #f9fafb;
}

.loading-cell {
    text-align: center;
    padding: 40px !important;
    color: #9ca3af;
}

/* ── Status Badges ─────────────────────────────────────────────────── */
.status-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
}

.status-active {
    background: #d1fae5;
    color: #059669;
}

.status-blocked {
    background: #fee2e2;
    color: #dc2626;
}

.status-admin {
    background: #dbeafe;
    color: #2563eb;
}

/* ── Action Buttons ────────────────────────────────────────────────── */
.admin-btn {
    padding: 8px 16px;
    border: none;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    font-family: inherit;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.admin-btn-primary {
    background: #032f62;
    color: white;
}

.admin-btn-primary:hover {
    background: #044a8a;
}

.admin-btn-danger {
    background: #ef4444;
    color: white;
}

.admin-btn-danger:hover {
    background: #dc2626;
}

.admin-btn-secondary {
    background: #f3f4f6;
    color: #4b5563;
}

.admin-btn-secondary:hover {
    background: #e5e7eb;
}

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

/* ── User Detail Modal ─────────────────────────────────────────────── */
.admin-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    pointer-events: none;
    transition: background 0.3s;
}

.admin-modal-overlay.active {
    background: rgba(0, 0, 0, 0.5);
    pointer-events: auto;
}

.admin-modal {
    background: white;
    border-radius: 16px;
    width: 90%;
    max-width: 600px;
    max-height: 85vh;
    overflow-y: auto;
    transform: scale(0.9);
    opacity: 0;
    transition: transform 0.3s, opacity 0.2s;
}

.admin-modal-overlay.active .admin-modal {
    transform: scale(1);
    opacity: 1;
}

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

.admin-modal-header h2 {
    margin: 0;
    font-size: 18px;
    font-weight: 700;
    color: #1a1d23;
}

.admin-modal-close {
    background: none;
    border: none;
    font-size: 24px;
    color: #6b7280;
    cursor: pointer;
    padding: 0;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
}

.admin-modal-close:hover {
    background: #f3f4f6;
}

.admin-modal-body {
    padding: 24px;
}

/* ── User Detail Sections ──────────────────────────────────────────── */
.user-detail-section {
    margin-bottom: 24px;
}

.user-detail-section h3 {
    margin: 0 0 12px;
    font-size: 14px;
    font-weight: 700;
    color: #374151;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.user-detail-info {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.user-detail-field {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.user-detail-field-label {
    font-size: 12px;
    color: #9ca3af;
    font-weight: 600;
}

.user-detail-field-value {
    font-size: 14px;
    color: #1a1d23;
}

/* ── Feature Access Toggles ────────────────────────────────────────── */
.feature-toggles {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.feature-toggle {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    background: #f9fafb;
    border-radius: 8px;
}

.feature-toggle-name {
    font-size: 14px;
    font-weight: 600;
    color: #374151;
    display: flex;
    align-items: center;
    gap: 8px;
}

.feature-toggle-switch {
    position: relative;
    width: 44px;
    height: 24px;
}

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

.feature-toggle-slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: #d1d5db;
    border-radius: 24px;
    transition: 0.3s;
}

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

.feature-toggle-switch input:checked + .feature-toggle-slider {
    background: #10b981;
}

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

/* ── Plans Grid ────────────────────────────────────────────────────── */
.plans-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 20px;
}

.plan-card {
    background: white;
    border-radius: 12px;
    padding: 24px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
    border: 2px solid transparent;
    transition: border-color 0.2s;
}

.plan-card:hover {
    border-color: #032f62;
}

.plan-card-name {
    font-size: 20px;
    font-weight: 800;
    color: #032f62;
    margin: 0 0 8px;
}

.plan-card-price {
    font-size: 32px;
    font-weight: 800;
    color: #1a1d23;
    margin: 0 0 4px;
}

.plan-card-period {
    font-size: 13px;
    color: #6b7280;
    margin: 0 0 16px;
}

.plan-card-features {
    list-style: none;
    padding: 0;
    margin: 0 0 20px;
    font-size: 13px;
    color: #374151;
}

.plan-card-features li {
    padding: 4px 0;
    display: flex;
    align-items: center;
    gap: 8px;
}

.plan-card-features li::before {
    content: "✓";
    color: #10b981;
    font-weight: 700;
}

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

/* ── Content Editor ────────────────────────────────────────────────── */
.content-editor {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 24px;
    background: white;
    border-radius: 12px;
    padding: 24px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
}

.content-editor-left,
.content-editor-right {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.content-label {
    font-size: 13px;
    font-weight: 600;
    color: #374151;
    margin-top: 12px;
}

.content-label:first-child {
    margin-top: 0;
}

.content-editor-left input,
.content-editor-left select,
.content-editor-left textarea {
    padding: 10px 14px;
    border: 1.5px solid #e5e7eb;
    border-radius: 8px;
    font-size: 14px;
    font-family: inherit;
    outline: none;
}

.content-editor-left input:focus,
.content-editor-left select:focus,
.content-editor-left textarea:focus {
    border-color: #032f62;
}

.content-user-results {
    max-height: 150px;
    overflow-y: auto;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    display: none;
}

.content-user-results.active {
    display: block;
}

.content-user-result {
    padding: 10px 14px;
    cursor: pointer;
    border-bottom: 1px solid #f3f4f6;
    font-size: 13px;
}

.content-user-result:hover {
    background: #f9fafb;
}

.existing-content-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.existing-content-item {
    padding: 12px;
    background: #f9fafb;
    border-radius: 8px;
    font-size: 13px;
}

.existing-content-item strong {
    color: #032f62;
}

.existing-content-item .content-value {
    color: #4b5563;
    margin-top: 4px;
    word-break: break-all;
}

.existing-content-item .content-scope {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 600;
    margin-top: 4px;
}

.content-scope-global {
    background: #dbeafe;
    color: #2563eb;
}

.content-scope-user {
    background: #d1fae5;
    color: #059669;
}

/* ── Responsive ────────────────────────────────────────────────────── */
@media (max-width: 768px) {
    .admin-dashboard {
        flex-direction: column;
    }
    .admin-sidebar {
        width: 100%;
        height: auto;
        position: relative;
    }
    .admin-sidebar-nav {
        flex-direction: row;
        overflow-x: auto;
    }
    .dashboard-row {
        grid-template-columns: 1fr;
    }
    .content-editor {
        grid-template-columns: 1fr;
    }
}
