/* ==============================================================================
   FixMySERP Global Payments Management System — Modern SaaS Admin Design System
   ============================================================================== */

:root {
    --bg-canvas: #090d16;
    --bg-surface: #111827;
    --bg-elevated: #1e293b;
    --bg-hover: #263349;
    --border-subtle: #1f2937;
    --border-strong: #334155;
    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    --brand-primary: #6366f1;
    --brand-hover: #4f46e5;
    --brand-glow: rgba(99, 102, 241, 0.16);
    --emerald: #10b981;
    --emerald-bg: rgba(16, 185, 129, 0.12);
    --amber: #f59e0b;
    --amber-bg: rgba(245, 158, 11, 0.14);
    --rose: #f43f5e;
    --rose-bg: rgba(244, 63, 94, 0.14);
    --sky: #0ea5e9;
    --sky-bg: rgba(14, 165, 233, 0.14);
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 14px;
    --sidebar-width: 265px;
    --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    --font-mono: 'JetBrains Mono', 'Fira Code', Consolas, monospace;
}

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

body {
    margin: 0;
    background-color: var(--bg-canvas);
    color: var(--text-primary);
    font-family: var(--font-sans);
    font-size: 14px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

a {
    color: var(--brand-primary);
    text-decoration: none;
    transition: color 0.15s ease;
}

a:hover {
    color: #818cf8;
}

/* App Shell */
.app-shell {
    display: flex;
    min-height: 100vh;
}

/* Sidebar */
.sidebar {
    width: var(--sidebar-width);
    background: var(--bg-surface);
    border-right: 1px solid var(--border-subtle);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    z-index: 50;
    transition: transform 0.25s ease;
}

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

.brand-logo {
    width: 36px;
    height: 36px;
    border-radius: 9px;
    background: linear-gradient(135deg, #6366f1 0%, #0ea5e9 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
    font-size: 16px;
    color: #fff;
    box-shadow: 0 6px 16px rgba(99, 102, 241, 0.35);
    flex-shrink: 0;
}

.brand-meta h1 {
    font-size: 15px;
    font-weight: 700;
    margin: 0;
    color: var(--text-primary);
    letter-spacing: -0.01em;
}

.brand-meta span {
    font-size: 11px;
    color: var(--text-secondary);
    display: block;
}

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

.nav-section-title {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-muted);
    padding: 10px 12px 6px;
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 11px;
    padding: 9px 12px;
    margin-bottom: 3px;
    border-radius: var(--radius-md);
    color: var(--text-secondary);
    font-weight: 500;
    font-size: 13.5px;
    transition: all 0.15s ease;
}

.nav-link:hover {
    background: rgba(255, 255, 255, 0.04);
    color: var(--text-primary);
}

.nav-link.active {
    background: var(--brand-glow);
    color: #818cf8;
    font-weight: 600;
    border: 1px solid rgba(99, 102, 241, 0.28);
}

.nav-icon {
    width: 18px;
    height: 18px;
    opacity: 0.85;
    flex-shrink: 0;
}

.sidebar-footer {
    padding: 14px 16px;
    border-top: 1px solid var(--border-subtle);
    background: rgba(15, 23, 42, 0.5);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.admin-profile {
    overflow: hidden;
}

.admin-profile strong {
    display: block;
    font-size: 13px;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.admin-profile small {
    font-size: 11px;
    color: var(--text-secondary);
}

/* Main Content Area */
.main-wrapper {
    flex: 1;
    margin-left: var(--sidebar-width);
    display: flex;
    flex-direction: column;
    min-width: 0;
}

/* Topbar */
.topbar {
    height: 64px;
    background: rgba(17, 24, 39, 0.85);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border-subtle);
    padding: 0 28px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 40;
}

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

.mobile-menu-btn {
    display: none;
    background: var(--bg-elevated);
    border: 1px solid var(--border-strong);
    color: var(--text-primary);
    padding: 6px 10px;
    border-radius: var(--radius-sm);
    cursor: pointer;
}

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

.website-switcher {
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--bg-elevated);
    border: 1px solid var(--border-strong);
    padding: 5px 12px;
    border-radius: var(--radius-md);
}

.website-switcher label {
    font-size: 11.5px;
    color: var(--text-secondary);
    font-weight: 600;
}

.website-switcher select {
    background: transparent;
    border: none;
    color: var(--text-primary);
    font-weight: 600;
    font-size: 13px;
    cursor: pointer;
    outline: none;
}

.website-switcher select option {
    background: var(--bg-surface);
    color: var(--text-primary);
}

/* Page Container */
.page-container {
    padding: 28px;
    max-width: 1480px;
    width: 100%;
    margin: 0 auto;
}

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

.page-header h2 {
    margin: 0 0 4px;
    font-size: 22px;
    font-weight: 700;
    letter-spacing: -0.02em;
}

.page-header p {
    margin: 0;
    color: var(--text-secondary);
    font-size: 13.5px;
}

/* KPI Grid */
.kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
    gap: 18px;
    margin-bottom: 24px;
}

.kpi-card {
    background: var(--bg-surface);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    padding: 20px;
    position: relative;
    overflow: hidden;
}

.kpi-card::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 2px;
    background: linear-gradient(90deg, var(--brand-primary), var(--sky));
    opacity: 0.65;
}

.kpi-label {
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-secondary);
    margin-bottom: 8px;
}

.kpi-value {
    font-size: 26px;
    font-weight: 800;
    color: var(--text-primary);
    letter-spacing: -0.02em;
    margin-bottom: 6px;
}

.kpi-sub {
    font-size: 12px;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    gap: 6px;
}

/* Cards & Grid Layouts */
.card {
    background: var(--bg-surface);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    margin-bottom: 24px;
    overflow: hidden;
}

.card-header {
    padding: 16px 22px;
    border-bottom: 1px solid var(--border-subtle);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
}

.card-header h3 {
    margin: 0;
    font-size: 15.5px;
    font-weight: 700;
}

.card-body {
    padding: 22px;
}

.grid-2 {
    display: grid;
    grid-template-columns: 1.75fr 1fr;
    gap: 22px;
}

.grid-equal {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(380px, 1fr));
    gap: 22px;
}

/* Responsive Tables */
.table-responsive {
    width: 100%;
    overflow-x: auto;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    text-align: left;
}

.data-table th {
    padding: 12px 18px;
    font-size: 11.5px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-secondary);
    background: rgba(15, 23, 42, 0.55);
    border-bottom: 1px solid var(--border-subtle);
    white-space: nowrap;
}

.data-table td {
    padding: 13px 18px;
    border-bottom: 1px solid var(--border-subtle);
    font-size: 13.5px;
    vertical-align: middle;
}

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

.data-table tbody tr:hover {
    background: rgba(255, 255, 255, 0.02);
}

/* Status Badges */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 3px 9px;
    border-radius: 999px;
    font-size: 11.5px;
    font-weight: 600;
    text-transform: capitalize;
    white-space: nowrap;
}

.badge-success, .badge-active, .badge-completed, .badge-processed, .badge-live {
    background: var(--emerald-bg);
    color: #34d399;
    border: 1px solid rgba(16, 185, 129, 0.25);
}

.badge-warning, .badge-pending, .badge-trialing, .badge-past_due, .badge-paused, .badge-sandbox, .badge-partially_refunded {
    background: var(--amber-bg);
    color: #fbbf24;
    border: 1px solid rgba(245, 158, 11, 0.28);
}

.badge-danger, .badge-failed, .badge-canceled, .badge-expired, .badge-refunded {
    background: var(--rose-bg);
    color: #fb7185;
    border: 1px solid rgba(244, 63, 94, 0.28);
}

.badge-info, .badge-free, .badge-ignored {
    background: var(--sky-bg);
    color: #38bdf8;
    border: 1px solid rgba(14, 165, 233, 0.25);
}

/* Buttons & Forms */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    padding: 8px 15px;
    border-radius: var(--radius-md);
    font-weight: 600;
    font-size: 13px;
    cursor: pointer;
    border: 1px solid transparent;
    transition: all 0.15s ease;
    text-decoration: none;
    white-space: nowrap;
}

.btn-primary {
    background: var(--brand-primary);
    color: #fff;
}

.btn-primary:hover {
    background: var(--brand-hover);
    color: #fff;
}

.btn-secondary {
    background: var(--bg-elevated);
    border-color: var(--border-strong);
    color: var(--text-primary);
}

.btn-secondary:hover {
    background: var(--bg-hover);
    color: #fff;
}

.btn-danger {
    background: rgba(244, 63, 94, 0.15);
    border-color: rgba(244, 63, 94, 0.35);
    color: #fb7185;
}

.btn-danger:hover {
    background: var(--rose);
    color: #fff;
}

.btn-sm {
    padding: 5px 10px;
    font-size: 12px;
    border-radius: var(--radius-sm);
}

.form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 16px;
}

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

.form-group label {
    display: block;
    font-size: 12.5px;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 6px;
}

.form-control {
    width: 100%;
    padding: 9px 12px;
    background: var(--bg-canvas);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-family: var(--font-sans);
    font-size: 13.5px;
    outline: none;
    transition: border-color 0.15s ease;
}

.form-control:focus {
    border-color: var(--brand-primary);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.2);
}

.mono {
    font-family: var(--font-mono);
    font-size: 12px;
}

.code-pill {
    font-family: var(--font-mono);
    font-size: 12px;
    background: rgba(15, 23, 42, 0.8);
    border: 1px solid var(--border-strong);
    padding: 3px 7px;
    border-radius: 5px;
    color: #cbd5e1;
}

/* Alerts */
.alert {
    padding: 13px 18px;
    border-radius: var(--radius-md);
    margin-bottom: 20px;
    font-size: 13.5px;
    font-weight: 500;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.alert-success {
    background: var(--emerald-bg);
    border: 1px solid rgba(16, 185, 129, 0.35);
    color: #6ee7b7;
}

.alert-error {
    background: var(--rose-bg);
    border: 1px solid rgba(244, 63, 94, 0.35);
    color: #fda4af;
}

/* Filter Bar */
.filter-bar {
    display: flex;
    gap: 10px;
    align-items: center;
    flex-wrap: wrap;
}

/* Chart Bars */
.bar-chart {
    display: flex;
    align-items: flex-end;
    gap: 14px;
    height: 200px;
    padding: 20px 8px 8px;
}

.bar-col {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    height: 100%;
    justify-content: flex-end;
}

.bar-fill {
    width: 100%;
    max-width: 48px;
    background: linear-gradient(180deg, #6366f1 0%, #0ea5e9 100%);
    border-radius: 6px 6px 2px 2px;
    min-height: 6px;
    transition: height 0.3s ease;
}

.bar-amount {
    font-size: 11px;
    color: var(--text-secondary);
    margin-bottom: 6px;
    font-weight: 600;
}

.bar-label {
    font-size: 11px;
    color: var(--text-muted);
    margin-top: 8px;
}

/* Modal */
.modal-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.72);
    backdrop-filter: blur(4px);
    z-index: 100;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.modal-backdrop.open {
    display: flex;
}

.modal-dialog {
    background: var(--bg-surface);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-lg);
    max-width: 680px;
    width: 100%;
    max-height: 85vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.7);
}

.modal-header {
    padding: 16px 22px;
    border-bottom: 1px solid var(--border-subtle);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.modal-body {
    padding: 20px 22px;
    overflow-y: auto;
}

@media (max-width: 992px) {
    .sidebar {
        transform: translateX(-100%);
    }
    .sidebar.open {
        transform: translateX(0);
    }
    .main-wrapper {
        margin-left: 0;
    }
    .mobile-menu-btn {
        display: inline-flex;
    }
    .grid-2 {
        grid-template-columns: 1fr;
    }
}
