/**
 * Admin Dashboard Theme - 2025 White SaaS Style
 * Stripe / Supabase-inspired. No yellow, no black backgrounds.
 * All class names and IDs preserved for zero functionality change.
 */

/* -------------------------------------------------------------------------
   DESIGN TOKENS
   ------------------------------------------------------------------------- */
.admin-layout,
body.admin-login-page {
    --admin-bg: #F8FAFC;
    --admin-card: #FFFFFF;
    --admin-primary: #2563EB;
    --admin-primary-hover: #1d4ed8;
    --admin-success: #22C55E;
    --admin-success-bg: #DCFCE7;
    --admin-danger: #EF4444;
    --admin-danger-bg: #FEE2E2;
    --admin-warning-bg: #FEF3C7;
    --admin-warning-text: #92400E;
    --admin-text: #0F172A;
    --admin-text-muted: #64748B;
    --admin-border: #E2E8F0;
    --admin-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.08), 0 1px 2px -1px rgba(0, 0, 0, 0.06);
    --admin-shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
}

/* Override legacy variables so inline styles (e.g. footer, detail views) resolve correctly */
.admin-layout { 
    --text-gray: #64748B; 
    --border-color: #E2E8F0; 
    /* Ensure any legacy var(--text-white) text renders dark on white cards */
    --text-white: #0F172A;
}
body.admin-login-page { 
    --text-gray: #64748B; 
    --border-color: #E2E8F0; 
    --text-white: #0F172A;
}

/* -------------------------------------------------------------------------
   LAYOUT & GLOBAL
   ------------------------------------------------------------------------- */
.admin-layout {
    min-height: 100vh;
    background: var(--admin-bg);
}

.admin-dashboard {
    padding: 28px 0 32px;
}

/* No flashy animations - minimal motion only */
.admin-layout .fade-in-on-scroll {
    animation: none;
    opacity: 1;
}
.admin-layout [style*="animation-delay"] {
    animation: none;
    opacity: 1;
}

/* -------------------------------------------------------------------------
   NAVBAR
   ------------------------------------------------------------------------- */
.admin-header {
    background: var(--admin-card);
    border-bottom: 1px solid var(--admin-border);
    padding: 0 0;
    position: sticky;
    top: 0;
    z-index: 1000;
    box-shadow: var(--admin-shadow-sm);
}

.admin-nav {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 16px;
    min-height: 64px;
    position: relative;
}

.admin-brand {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--admin-primary);
    text-decoration: none;
}

.admin-brand:hover {
    color: var(--admin-primary-hover);
}

.admin-nav-menu {
    display: flex;
    list-style: none;
    gap: 4px;
    margin: 0;
    padding: 0;
    flex-wrap: wrap;
    align-items: center;
}

.admin-nav-menu li a {
    color: var(--admin-text-muted);
    text-decoration: none;
    font-weight: 500;
    font-size: 0.9375rem;
    padding: 8px 14px;
    border-radius: 8px;
    transition: background 0.15s ease, color 0.15s ease;
}

.admin-nav-menu li a:hover {
    color: var(--admin-primary);
    background: #EFF6FF;
}

.admin-nav-menu li a.active {
    color: var(--admin-primary);
    background: #EFF6FF;
}

.admin-user-info {
    display: flex;
    align-items: center;
    gap: 12px;
}

.admin-username {
    color: var(--admin-text);
    font-weight: 500;
    font-size: 0.9375rem;
}

/* -------------------------------------------------------------------------
   PAGE HEADERS
   ------------------------------------------------------------------------- */
.admin-page-header {
    margin-bottom: 24px;
}

.admin-page-header h1 {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--admin-text);
    margin: 0 0 4px 0;
    line-height: 1.3;
}

.admin-page-subtitle {
    color: var(--admin-text-muted);
    font-size: 1rem;
    margin: 0;
    line-height: 1.5;
}

/* -------------------------------------------------------------------------
   CARDS & SECTIONS
   ------------------------------------------------------------------------- */
.admin-summary-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 20px;
    margin-bottom: 32px;
}

@media (min-width: 1400px) {
    .admin-summary-cards {
        grid-template-columns: repeat(4, 1fr);
    }
}

.admin-summary-card {
    background: var(--admin-card);
    padding: 24px;
    border-radius: 12px;
    border: 1px solid var(--admin-border);
    box-shadow: var(--admin-shadow-sm);
    transition: box-shadow 0.2s ease;
}

.admin-summary-card:hover {
    box-shadow: var(--admin-shadow);
}

.admin-summary-label {
    font-size: 0.8125rem;
    color: var(--admin-text-muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin-bottom: 8px;
    font-weight: 600;
}

.admin-summary-value {
    font-size: 1.875rem;
    font-weight: 700;
    color: var(--admin-text);
    margin-bottom: 8px;
    line-height: 1.2;
}

.admin-summary-badge {
    display: inline-block;
    background: #DBEAFE;
    color: var(--admin-primary);
    padding: 4px 10px;
    border-radius: 9999px;
    font-size: 0.75rem;
    font-weight: 600;
}

.admin-summary-trends {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 8px;
}

.trend-badge {
    display: inline-block;
    background: #EFF6FF;
    color: #2563EB;
    padding: 3px 8px;
    border-radius: 6px;
    font-size: 0.6875rem;
    font-weight: 600;
    line-height: 1.3;
}

.trend-badge.success {
    background: #DCFCE7;
    color: #16A34A;
}

.trend-badge.warning {
    background: #FEF3C7;
    color: #CA8A04;
}

.trend-badge.danger {
    background: #FEE2E2;
    color: #DC2626;
}

.trend-badge.muted {
    background: #F1F5F9;
    color: #64748B;
}

/* -------------------------------------------------------------------------
   TABLE SECTIONS
   ------------------------------------------------------------------------- */
.admin-table-section {
    background: var(--admin-card);
    padding: 24px;
    border-radius: 12px;
    border: 1px solid var(--admin-border);
    box-shadow: var(--admin-shadow-sm);
    margin-bottom: 24px;
}

.admin-table-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    flex-wrap: wrap;
    gap: 12px;
}

.admin-table-header h2 {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--admin-text);
    margin: 0;
}

/* -------------------------------------------------------------------------
   TABLES
   ------------------------------------------------------------------------- */
.table-container {
    overflow-x: auto;
}

.admin-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9375rem;
}

.admin-table thead {
    background: var(--admin-bg);
    border-bottom: 1px solid var(--admin-border);
}

.admin-table th {
    padding: 12px 16px;
    text-align: left;
    font-weight: 600;
    color: var(--admin-text-muted);
    font-size: 0.8125rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.admin-table td {
    padding: 14px 16px;
    border-bottom: 1px solid var(--admin-border);
    color: var(--admin-text);
    vertical-align: middle;
}

/* Center Actions column (last column) in admin tables */
.admin-table th:last-child,
.admin-table td:last-child {
    text-align: center;
}
.admin-table td:last-child {
    display: table-cell;
}
.admin-table td:last-child > div {
    display: inline-flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    justify-content: center;
    align-items: center;
}

.admin-table tbody tr:nth-child(even) {
    background: #FAFAFA;
}

.admin-table tbody tr:hover {
    background: #F1F5F9;
}

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

/* Empty state inside table cell */
.admin-table td.admin-empty-state {
    text-align: center;
    padding: 32px 24px;
    color: var(--admin-text-muted);
    background: var(--admin-bg) !important;
}

.admin-empty-state {
    text-align: center;
    padding: 32px 24px;
    color: var(--admin-text-muted);
}

.admin-empty-state p {
    margin: 0 0 16px 0;
    font-size: 1rem;
}

/* -------------------------------------------------------------------------
   BADGES (blue / green soft pills, no yellow)
   ------------------------------------------------------------------------- */
.admin-badge {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 9999px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.02em;
}

.admin-badge-success {
    background: var(--admin-success-bg);
    color: #166534;
}

.admin-badge-warning {
    background: var(--admin-warning-bg);
    color: var(--admin-warning-text);
}

.admin-badge-danger {
    background: var(--admin-danger-bg);
    color: #991B1B;
}

.admin-badge-secondary {
    background: #F1F5F9;
    color: var(--admin-text-muted);
}

/* -------------------------------------------------------------------------
   BUTTONS
   ------------------------------------------------------------------------- */
.admin-btn {
    padding: 8px 16px;
    border-radius: 8px;
    font-weight: 500;
    font-size: 0.875rem;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
    border: 1px solid transparent;
    cursor: pointer;
    white-space: nowrap;
    font-family: inherit;
}

.admin-btn-primary {
    background: var(--admin-primary);
    color: #FFFFFF;
    border-color: var(--admin-primary);
}

.admin-btn-primary:hover {
    background: var(--admin-primary-hover);
    border-color: var(--admin-primary-hover);
    color: #FFFFFF;
}

.admin-btn-secondary {
    background: transparent;
    color: var(--admin-text);
    border-color: var(--admin-border);
}

.admin-btn-secondary:hover {
    background: var(--admin-bg);
    border-color: #CBD5E1;
    color: var(--admin-text);
}

.admin-btn-danger {
    background: var(--admin-danger);
    color: #FFFFFF;
    border-color: var(--admin-danger);
}

.admin-btn-danger:hover {
    background: #DC2626;
    border-color: #DC2626;
    color: #FFFFFF;
}

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

/* -------------------------------------------------------------------------
   FORMS (inside admin sections)
   ------------------------------------------------------------------------- */
.admin-table-section .form-group,
.admin-login-form .form-group {
    margin-bottom: 20px;
}

.admin-table-section label,
.admin-login-form label {
    display: block;
    margin-bottom: 6px;
    font-weight: 500;
    font-size: 0.9375rem;
    color: var(--admin-text);
}

.admin-table-section input[type="text"],
.admin-table-section input[type="email"],
.admin-table-section input[type="password"],
.admin-table-section input[type="number"],
.admin-table-section input[type="date"],
.admin-table-section select,
.admin-table-section textarea,
.admin-login-form input {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid var(--admin-border);
    border-radius: 8px;
    font-size: 0.9375rem;
    background: var(--admin-card);
    color: var(--admin-text);
    font-family: inherit;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.admin-table-section input:focus,
.admin-table-section select:focus,
.admin-table-section textarea:focus,
.admin-login-form input:focus {
    outline: none;
    border-color: var(--admin-primary);
    background-color: var(--admin-card) !important;
    color: var(--admin-text) !important;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

.admin-table-section input:active,
.admin-table-section select:active,
.admin-table-section textarea:active,
.admin-login-form input:active {
    background-color: var(--admin-card) !important;
    color: var(--admin-text) !important;
}

.admin-table-section input,
.admin-table-section select,
.admin-table-section textarea,
.admin-login-form input {
    background-color: var(--admin-card) !important;
    color: var(--admin-text) !important;
}

.admin-table-section input::placeholder,
.admin-table-section textarea::placeholder {
    color: var(--admin-text-muted);
}

.admin-table-section small {
    color: var(--admin-text-muted);
    font-size: 0.875rem;
    margin-top: 4px;
    display: block;
}

.admin-table-section input[type="checkbox"] {
    width: auto;
    accent-color: var(--admin-primary);
    cursor: pointer;
}

/* -------------------------------------------------------------------------
   FOOTER
   ------------------------------------------------------------------------- */
.admin-footer {
    text-align: center;
    padding: 24px;
    margin-top: 32px;
    border-top: 1px solid var(--admin-border);
    background: var(--admin-card);
    color: var(--admin-text-muted);
    font-size: 0.875rem;
}

.admin-footer p {
    margin: 0;
}

/* -------------------------------------------------------------------------
   ADMIN LOGIN PAGE (standalone, no layout)
   ------------------------------------------------------------------------- */
body.admin-login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    background: var(--admin-bg);
}

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

.admin-login-card {
    background: var(--admin-card);
    padding: 32px;
    border-radius: 12px;
    border: 1px solid var(--admin-border);
    box-shadow: var(--admin-shadow);
}

.admin-login-header {
    text-align: center;
    margin-bottom: 24px;
}

.admin-logo {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    margin-bottom: 8px;
}

.admin-icon {
    font-size: 2.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
}

.admin-icon svg {
    width: 2.5rem;
    height: 2.5rem;
}

.admin-login-header h1 {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--admin-text);
    margin: 0;
}

.admin-subtitle {
    color: var(--admin-text-muted);
    font-size: 0.9375rem;
    margin: 0;
}

.admin-login-form {
    margin-top: 24px;
}

.admin-login-form .form-group {
    margin-bottom: 20px;
}

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

.label-icon {
    margin-right: 4px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.label-icon svg {
    width: 1.2rem;
    height: 1.2rem;
}

/* Login page uses .btn .btn-primary - style for admin context */
body.admin-login-page .btn.btn-primary {
    background: var(--admin-primary);
    color: #FFFFFF;
    border: none;
    width: 100%;
    padding: 12px 16px;
    border-radius: 8px;
    font-weight: 600;
    font-size: 1rem;
}

body.admin-login-page .btn.btn-primary:hover {
    background: var(--admin-primary-hover);
}

.admin-login-footer {
    text-align: center;
    margin-top: 24px;
    padding-top: 24px;
    border-top: 1px solid var(--admin-border);
    color: var(--admin-text-muted);
    font-size: 0.875rem;
}

.admin-login-footer p {
    margin: 0;
}

/* Alerts on admin (login + layout) */
.admin-layout .alert,
body.admin-login-page .alert {
    border-radius: 8px;
    border-left-width: 4px;
}

.admin-layout .alert-success,
body.admin-login-page .alert-success {
    background: #F0FDF4;
    border-left-color: var(--admin-success);
    color: #166534;
}

.admin-layout .alert-error,
body.admin-login-page .alert-error {
    background: #FEF2F2;
    border-left-color: var(--admin-danger);
    color: #991B1B;
}

.admin-layout .alert-info,
body.admin-login-page .alert-info {
    background: #EFF6FF;
    border-left-color: var(--admin-primary);
    color: #1E40AF;
}

/* -------------------------------------------------------------------------
   FLASH MESSAGES
   ------------------------------------------------------------------------- */
.admin-layout .flash-messages,
body.admin-login-page .flash-messages {
    padding: 0 0 16px 0;
}

/* -------------------------------------------------------------------------
   RESPONSIVENESS (desktop-first, then compact)
   ------------------------------------------------------------------------- */
/* Override per-page style blocks (e.g. settings) so theme wins */
body.admin-layout .admin-btn-primary,
body.admin-layout .admin-btn.admin-btn-primary {
    background: var(--admin-primary) !important;
    color: #FFFFFF !important;
    border-color: var(--admin-primary) !important;
}

body.admin-layout .admin-btn-primary:hover,
body.admin-layout .admin-btn.admin-btn-primary:hover {
    background: var(--admin-primary-hover) !important;
    border-color: var(--admin-primary-hover) !important;
}

body.admin-layout .admin-btn-secondary,
body.admin-layout .admin-btn.admin-btn-secondary {
    background: transparent !important;
    color: var(--admin-text) !important;
    border-color: var(--admin-border) !important;
}

body.admin-layout .admin-table-section .form-group input[type="text"],
body.admin-layout .admin-table-section .form-group input[type="email"],
body.admin-layout .admin-table-section .form-group input[type="url"],
body.admin-layout .admin-table-section .form-group input[type="tel"] {
    background: var(--admin-card) !important;
    color: var(--admin-text) !important;
    border-color: var(--admin-border) !important;
}

body.admin-layout .admin-table-section .form-group input:focus {
    border-color: var(--admin-primary) !important;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12) !important;
}

/* -------------------------------------------------------------------------
   RESPONSIVENESS (desktop-first, then compact)
   ------------------------------------------------------------------------- */
@media (max-width: 768px) {
    .admin-nav {
        flex-direction: column;
        align-items: stretch;
        min-height: auto;
        padding: 12px 0;
    }

    .admin-nav-menu {
        flex-direction: column;
        width: 100%;
        gap: 2px;
    }

    .admin-nav-menu li a {
        display: block;
        width: 100%;
        padding: 10px 14px;
    }

    .admin-summary-cards {
        grid-template-columns: 1fr;
    }

    .admin-table-section {
        padding: 20px;
    }

    .admin-table {
        font-size: 0.875rem;
    }

    .admin-table th,
    .admin-table td {
        padding: 10px 12px;
    }
}

/* -------------------------------------------------------------------------
   ADMIN NOTIFICATION SYSTEM
   ------------------------------------------------------------------------- */
.admin-notification-bell {
    position: relative;
    display: inline-flex;
    align-items: center;
    margin-right: 12px;
    z-index: 1002;
}

.notification-btn {
    position: relative;
    background: none;
    border: none;
    cursor: pointer;
    padding: 8px;
    border-radius: 8px;
    color: var(--admin-text-muted);
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.notification-btn:hover {
    background: #EFF6FF;
    color: var(--admin-primary);
}

.notification-btn svg {
    width: 20px;
    height: 20px;
}

.notification-badge {
    position: absolute;
    top: 2px;
    right: 2px;
    background: #EF4444;
    color: white;
    font-size: 11px;
    font-weight: 700;
    min-width: 20px;
    height: 20px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 6px;
    box-shadow: 0 0 0 2px var(--admin-card);
    line-height: 1;
    letter-spacing: -0.02em;
}

.notification-dropdown {
    /* Centered popup instead of header dropdown */
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 400px;
    max-width: calc(100vw - 40px);
    background: white;
    border: 1px solid var(--admin-border);
    border-radius: 16px;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
    z-index: 1003;
    max-height: 600px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.notification-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 24px;
    border-bottom: 1px solid var(--admin-border);
    flex-shrink: 0;
    background: white;
}

.notification-header h3 {
    font-size: 1rem;
    font-weight: 700;
    color: var(--admin-text);
    margin: 0;
}

.mark-all-read-btn {
    background: none;
    border: none;
    color: var(--admin-primary);
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 6px;
    transition: all 0.2s ease;
}

.mark-all-read-btn:hover {
    background: #EFF6FF;
}

.notification-list {
    overflow-y: auto;
    overflow-x: hidden;
    max-height: 520px;
    flex: 1;
    scrollbar-width: thin;
    scrollbar-color: #CBD5E1 transparent;
}

.notification-list::-webkit-scrollbar {
    width: 6px;
}

.notification-list::-webkit-scrollbar-track {
    background: transparent;
}

.notification-list::-webkit-scrollbar-thumb {
    background: #CBD5E1;
    border-radius: 3px;
}

.notification-list::-webkit-scrollbar-thumb:hover {
    background: #94A3B8;
}

.notification-item {
    display: flex;
    align-items: flex-start;
    padding: 16px 24px;
    border-bottom: 1px solid #F1F5F9;
    cursor: pointer;
    transition: all 0.2s ease;
    position: relative;
    gap: 12px;
}

.notification-item:hover {
    background: #F8FAFC;
}

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

.notification-item.unread {
    background: #EFF6FF;
    border-left: 3px solid var(--admin-primary);
    padding-left: 21px;
}

.notification-item.unread:hover {
    background: #DBEAFE;
}

.notification-icon {
    flex-shrink: 0;
    width: 44px;
    height: 44px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-right: 0;
}

.notification-icon svg {
    width: 20px;
    height: 20px;
}

.notification-icon.subscription {
    background: #DCFCE7;
    color: #16A34A;
}

.notification-icon.signal {
    background: #DBEAFE;
    color: #2563EB;
}

.notification-icon.user {
    background: #FCE7F3;
    color: #DB2777;
}

.notification-icon.system {
    background: #FEF3C7;
    color: #CA8A04;
}

.notification-content {
    flex: 1;
    min-width: 0;
    padding-right: 8px;
}

.notification-title {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--admin-text);
    margin-bottom: 6px;
    line-height: 1.3;
}

.notification-message {
    font-size: 0.8125rem;
    color: var(--admin-text-muted);
    margin-bottom: 8px;
    line-height: 1.5;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.notification-time {
    font-size: 0.75rem;
    color: #94A3B8;
    font-weight: 500;
}

.notification-unread-dot {
    flex-shrink: 0;
    width: 10px;
    height: 10px;
    background: #2563EB;
    border-radius: 50%;
    margin-top: 6px;
    box-shadow: 0 0 0 2px white;
}

.notification-loading,
.notification-error,
.notification-empty {
    padding: 48px 24px;
    text-align: center;
    color: var(--admin-text-muted);
    font-size: 0.875rem;
    line-height: 1.5;
}

.notification-error {
    color: #EF4444;
}

@media (max-width: 768px) {
    .notification-dropdown {
        width: calc(100vw - 20px);
        border-radius: 12px;
        max-height: 70vh;
    }
    
    .admin-notification-bell {
        margin-right: 0;
    }
    
    .notification-item {
        padding: 14px 20px;
    }
    
    .notification-header {
        padding: 16px 20px;
    }
}
