/* ============================================
   WIBMEX — Premium Design System
   ============================================ */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&display=swap');

:root {
    --primary: #a855f7;
    --primary-dim: rgba(168, 85, 247, 0.15);
    --primary-border: rgba(168, 85, 247, 0.3);
    --accent: #CC33FF;
    --accent-dim: rgba(204, 51, 255, 0.12);
    --bg: #080812;
    --surface: #100e20;
    --bg-surface: rgba(16, 14, 32, 0.9);
    --bg-card: rgba(22, 20, 42, 0.75);
    --bg-card-hover: rgba(30, 28, 55, 0.9);
    --text: #f0eeff;
    --text-muted: #8b8aa8;
    --text-dim: #4a4870;
    --border: rgba(255, 255, 255, 0.07);
    --border-accent: rgba(168, 85, 247, 0.25);
    --success: #22c55e;
    --success-dim: rgba(34, 197, 94, 0.12);
    --warning: #f59e0b;
    --warning-dim: rgba(245, 158, 11, 0.12);
    --danger: #ef4444;
    --danger-dim: rgba(239, 68, 68, 0.12);
    --radius: 16px;
    --radius-lg: 24px;
    --radius-xl: 32px;
    --shadow: 0 20px 60px rgba(0, 0, 0, 0.6);
    --shadow-sm: 0 4px 20px rgba(0, 0, 0, 0.4);
    --glow: 0 0 40px rgba(168, 85, 247, 0.12);
}

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

html { scroll-behavior: smooth; }

body {
    font-family: 'Inter', -apple-system, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    min-height: 100vh;
}

/* ── Global Mesh Background ── */
body::before {
    content: '';
    position: fixed;
    inset: 0;
    background:
        radial-gradient(ellipse 80% 60% at 20% -10%, rgba(168,85,247,0.12) 0%, transparent 60%),
        radial-gradient(ellipse 60% 50% at 80% 110%, rgba(99,102,241,0.08) 0%, transparent 60%),
        linear-gradient(180deg, #0a0818 0%, #080812 100%);
    z-index: -1;
    pointer-events: none;
}

/* ══════════════════════════════════════════
   TYPOGRAPHY
══════════════════════════════════════════ */
h1 { font-size: 1.75rem; font-weight: 700; line-height: 1.2; color: var(--text); }
h2 { font-size: 1.35rem; font-weight: 700; color: var(--text); }
h3 { font-size: 1.1rem; font-weight: 600; color: var(--text); }
p  { color: var(--text-muted); }

/* ══════════════════════════════════════════
   CARDS & GLASS
══════════════════════════════════════════ */
.glass-card {
    background: var(--bg-card);
    backdrop-filter: blur(16px);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    padding: 2rem;
    transition: border-color 0.3s, box-shadow 0.3s;
}
.glass-card:hover { border-color: var(--border-accent); box-shadow: var(--glow); }

/* ══════════════════════════════════════════
   LOGIN PAGE
══════════════════════════════════════════ */
.login-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 2rem;
}

.login-container {
    width: 100%;
    max-width: 420px;
    animation: slideUp 0.6s cubic-bezier(0.16, 1, 0.3, 1) both;
}

@keyframes slideUp {
    from { opacity: 0; transform: translateY(32px); }
    to   { opacity: 1; transform: translateY(0); }
}

.login-container .glass-card {
    padding: 3rem;
    border-color: var(--border-accent);
}

.logo-wrap {
    display: flex;
    justify-content: center;
    margin-bottom: 2.5rem;
}
.logo-wrap img, .logo-wrap svg { height: 36px; width: auto; }

.login-title {
    font-size: 1.5rem;
    font-weight: 700;
    text-align: center;
    margin-bottom: 0.5rem;
}

.login-sub {
    text-align: center;
    font-size: 0.9rem;
    margin-bottom: 2rem;
    color: var(--text-muted);
}

/* ══════════════════════════════════════════
   FORMS
══════════════════════════════════════════ */
.form-group { margin-bottom: 1.5rem; }

.form-group label {
    display: block;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.6px;
    margin-bottom: 0.5rem;
}

.form-control, input[type="text"], input[type="email"], input[type="password"],
input[type="number"], textarea, select {
    width: 100%;
    background: rgba(10, 8, 24, 0.6);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 0.75rem 1rem;
    color: var(--text);
    font-family: inherit;
    font-size: 0.95rem;
    transition: border-color 0.3s, box-shadow 0.3s, background 0.3s;
    outline: none;
    -webkit-appearance: none;
}

.form-control:focus, input:focus, textarea:focus, select:focus {
    border-color: var(--primary);
    background: rgba(10, 8, 24, 0.9);
    box-shadow: 0 0 0 4px rgba(168, 85, 247, 0.15);
}

.form-control::placeholder, input::placeholder { color: var(--text-dim); }

select option { background: #1a1733; color: var(--text); }

textarea.form-control { min-height: 120px; resize: vertical; }

/* ══════════════════════════════════════════
   BUTTONS
══════════════════════════════════════════ */
.btn-primary {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    width: 100%;
    background: linear-gradient(135deg, #a855f7, #7c3aed);
    color: white;
    border: none;
    border-radius: var(--radius);
    padding: 0.85rem 1.5rem;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
    text-decoration: none;
    letter-spacing: 0.2px;
}
.btn-primary:hover {
    background: linear-gradient(135deg, #b97cf8, #8b5cf6);
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(168, 85, 247, 0.4);
}
.btn-primary:active { transform: translateY(0); }

.btn-ghost {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.65rem 1.25rem;
    background: rgba(255,255,255,0.05);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text-muted);
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s;
    text-decoration: none;
}
.btn-ghost:hover { background: rgba(255,255,255,0.1); color: var(--text); border-color: var(--border-accent); }

.btn-danger {
    background: var(--danger-dim);
    border: 1px solid rgba(239,68,68,0.3);
    color: var(--danger);
    padding: 0.5rem 1rem;
    border-radius: 10px;
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s;
    text-decoration: none;
}
.btn-danger:hover { background: rgba(239,68,68,0.2); }

/* ══════════════════════════════════════════
   ALERTS
══════════════════════════════════════════ */
.alert {
    padding: 0.9rem 1.25rem;
    border-radius: var(--radius);
    font-size: 0.875rem;
    margin-bottom: 1.5rem;
}
.alert-success { background: var(--success-dim); color: var(--success); border: 1px solid rgba(34,197,94,0.2); }
.alert-danger  { background: var(--danger-dim);  color: var(--danger);  border: 1px solid rgba(239,68,68,0.2); }
.alert-warning { background: var(--warning-dim); color: var(--warning); border: 1px solid rgba(245,158,11,0.2); }

/* ══════════════════════════════════════════
   BADGES
══════════════════════════════════════════ */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 4px 12px;
    border-radius: 99px;
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.5px;
    text-transform: uppercase;
}
.badge::before { content: '●'; font-size: 0.6rem; }
.badge-active  { background: var(--success-dim); color: var(--success); border: 1px solid rgba(34,197,94,0.25); }
.badge-pending { background: var(--warning-dim); color: var(--warning); border: 1px solid rgba(245,158,11,0.25); }
.badge-overdue { background: rgba(249,115,22,0.12); color: #f97316; border: 1px solid rgba(249,115,22,0.25); }
.badge-blocked { background: var(--danger-dim);  color: var(--danger);  border: 1px solid rgba(239,68,68,0.25); }
.badge-trial   { background: rgba(99,102,241,0.12); color: #818cf8; border: 1px solid rgba(99,102,241,0.25); }

/* ══════════════════════════════════════════
   ADMIN LAYOUT
══════════════════════════════════════════ */
.admin-body { display: flex; min-height: 100vh; }
.dashboard-layout { display: flex; width: 100%; min-height: 100vh; }

.sidebar {
    width: 260px;
    background: rgba(12, 10, 28, 0.95);
    backdrop-filter: blur(20px);
    border-right: 1px solid var(--border);
    padding: 0;
    position: fixed;
    height: 100vh;
    display: flex;
    flex-direction: column;
    z-index: 100;
}

.sidebar-logo {
    padding: 1.75rem 1.5rem 1.5rem;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
}
.sidebar-logo img, .sidebar-logo svg { height: 28px; width: auto; }

.sidebar-nav {
    flex: 1;
    padding: 1.25rem 1rem;
    overflow-y: auto;
}

.nav-section-label {
    font-size: 0.65rem;
    font-weight: 700;
    letter-spacing: 1.5px;
    text-transform: uppercase;
    color: var(--text-dim);
    padding: 0.5rem 1rem;
    margin-top: 0.5rem;
    margin-bottom: 0.25rem;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 0.875rem;
    padding: 0.7rem 1rem;
    color: var(--text-muted);
    text-decoration: none;
    border-radius: 12px;
    margin-bottom: 2px;
    font-size: 0.9rem;
    font-weight: 500;
    transition: all 0.2s;
    position: relative;
}
.nav-item i { width: 18px; font-size: 0.9rem; flex-shrink: 0; }
.nav-item:hover { background: rgba(255,255,255,0.06); color: var(--text); }
.nav-item.active {
    background: var(--primary-dim);
    color: white;
    border: 1px solid var(--primary-border);
}
.nav-item.active::before {
    content: '';
    position: absolute;
    left: 0; top: 50%; transform: translateY(-50%);
    width: 3px; height: 60%;
    background: var(--accent);
    border-radius: 0 4px 4px 0;
}
.nav-item.logout { color: var(--danger); margin-top: 0.5rem; }
.nav-item.logout:hover { background: var(--danger-dim); }

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

.main-content {
    flex: 1;
    margin-left: 260px;
    padding: 2.5rem;
    min-height: 100vh;
}

/* ══════════════════════════════════════════
   PAGE HEADER
══════════════════════════════════════════ */
.page-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 2rem;
    gap: 1rem;
}
.page-header h1 { font-size: 1.6rem; }
.page-header p { font-size: 0.875rem; margin-top: 0.25rem; }
.header-action { display: flex; justify-content: space-between; align-items: center; margin-bottom: 2rem; gap: 1rem; }

/* ══════════════════════════════════════════
   STAT CARDS
══════════════════════════════════════════ */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1.25rem;
    margin-bottom: 2rem;
}

.stat-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    transition: all 0.3s;
}
.stat-card:hover { border-color: var(--border-accent); transform: translateY(-2px); }
.stat-card .label { color: var(--text-muted); font-size: 0.8rem; font-weight: 500; text-transform: uppercase; letter-spacing: 0.5px; }
.stat-card .value { font-size: 2rem; font-weight: 700; color: var(--text); }
.stat-card .icon { font-size: 1.5rem; margin-bottom: 0.5rem; }

/* ══════════════════════════════════════════
   TABLES
══════════════════════════════════════════ */
.table-container {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    overflow: hidden;
    overflow-x: auto;
}
.data-table { width: 100%; border-collapse: collapse; }
.data-table th {
    text-align: left;
    padding: 1rem 1.25rem;
    color: var(--text-muted);
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.7px;
    background: rgba(0,0,0,0.2);
    border-bottom: 1px solid var(--border);
}
.data-table td {
    padding: 0.9rem 1.25rem;
    border-bottom: 1px solid var(--border);
    font-size: 0.9rem;
    vertical-align: middle;
}
.data-table tr:last-child td { border-bottom: none; }
.data-table tr:hover td { background: rgba(255,255,255,0.02); }

/* ══════════════════════════════════════════
   ACTION BUTTONS (table)
══════════════════════════════════════════ */
.action-bar { display: flex; align-items: center; gap: 0.5rem; }
.btn-icon {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.4rem 0.75rem;
    border-radius: 8px;
    font-size: 0.78rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    text-decoration: none;
    border: 1px solid transparent;
}
.btn-icon-default { color: var(--text-muted); background: rgba(255,255,255,0.04); border-color: var(--border); }
.btn-icon-default:hover { color: var(--text); background: rgba(255,255,255,0.09); }
.btn-icon-primary { color: var(--primary); background: var(--primary-dim); border-color: var(--primary-border); }
.btn-icon-primary:hover { background: rgba(168,85,247,0.25); }
.btn-icon-danger  { color: var(--danger); background: var(--danger-dim); border-color: rgba(239,68,68,0.3); }
.btn-icon-danger:hover  { background: rgba(239,68,68,0.22); }

/* ══════════════════════════════════════════
   CODE SNIPPET / COPY BOX
══════════════════════════════════════════ */
.code-box {
    background: rgba(0,0,0,0.5);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 0.875rem 1rem;
    font-family: 'JetBrains Mono', 'Fira Code', 'Courier New', monospace;
    font-size: 0.78rem;
    color: #a5f3fc;
    word-break: break-all;
    position: relative;
    line-height: 1.5;
}
.copy-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.4rem 0.85rem;
    background: rgba(168,85,247,0.12);
    border: 1px solid var(--primary-border);
    color: var(--primary);
    border-radius: 8px;
    font-size: 0.78rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
}
.copy-btn:hover { background: rgba(168,85,247,0.22); }
.copy-btn.copied { color: var(--success); background: var(--success-dim); border-color: rgba(34,197,94,0.3); }

/* ══════════════════════════════════════════
   PORTAL CLIENT — Full Page
══════════════════════════════════════════ */
.portal-page {
    min-height: 100vh;
    padding: 0;
}

.portal-header {
    padding: 1.5rem 2.5rem;
    border-bottom: 1px solid var(--border);
    background: rgba(12,10,28,0.95);
    backdrop-filter: blur(20px);
    position: sticky;
    top: 0;
    z-index: 50;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.portal-body {
    max-width: 900px;
    margin: 0 auto;
    padding: 3rem 2rem;
}

.portal-welcome {
    margin-bottom: 2.5rem;
    padding: 2rem;
    background: linear-gradient(135deg, rgba(168,85,247,0.08), rgba(99,102,241,0.05));
    border: 1px solid var(--border-accent);
    border-radius: var(--radius-xl);
    display: flex;
    align-items: center;
    gap: 1.5rem;
}

.portal-avatar {
    width: 64px; height: 64px;
    background: linear-gradient(135deg, #a855f7, #7c3aed);
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-size: 1.5rem; font-weight: 800; color: white;
    flex-shrink: 0;
}

.portal-service-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    overflow: hidden;
    transition: all 0.3s;
    margin-bottom: 1.25rem;
}

.portal-service-card:hover { border-color: var(--border-accent); box-shadow: var(--glow); }

.service-card-top {
    padding: 1.5rem;
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 1rem;
}

.service-card-body { padding: 0 1.5rem 1.5rem; }

.service-card-footer {
    padding: 1rem 1.5rem;
    background: rgba(0,0,0,0.2);
    border-top: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.service-price {
    font-size: 1.75rem;
    font-weight: 800;
    background: linear-gradient(135deg, #a855f7, #6366f1);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.service-detail-item {
    display: flex;
    align-items: flex-start;
    gap: 0.5rem;
    font-size: 0.875rem;
    color: var(--text-muted);
    padding: 0.4rem 0;
}

.portal-payment-section {
    margin-top: 2.5rem;
    padding: 2rem;
    background: linear-gradient(135deg, rgba(168,85,247,0.07), rgba(99,102,241,0.04));
    border: 1px solid var(--primary-border);
    border-radius: var(--radius-xl);
}

.payment-total {
    font-size: 2.5rem;
    font-weight: 800;
    background: linear-gradient(135deg, #a855f7, #6366f1);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

/* ══════════════════════════════════════════
   MISC
══════════════════════════════════════════ */
.divider { height: 1px; background: var(--border); margin: 1.5rem 0; }
.text-muted { color: var(--text-muted); }
.text-success { color: var(--success); }
.text-danger  { color: var(--danger); }
.text-warning { color: var(--warning); }

.settings-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1.5rem; }

/* ══════════════════════════════════════════
   MOBILE TOP BAR & SIDEBAR OVERLAY
══════════════════════════════════════════ */
.mobile-topbar {
    display: none;
    align-items: center;
    gap: .75rem;
    padding: .75rem 1rem;
    margin: -1.25rem -1rem 1.25rem;
    background: rgba(12,10,28,.9);
    border-bottom: 1px solid var(--border);
    backdrop-filter: blur(12px);
    position: sticky;
    top: 0;
    z-index: 90;
}
.mobile-topbar button {
    background: rgba(255,255,255,.06);
    border: 1px solid var(--border);
    border-radius: 8px;
    width: 38px;
    height: 38px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text);
    font-size: 1rem;
    cursor: pointer;
    flex-shrink: 0;
}
.mobile-topbar button:hover { background: var(--primary-dim); }

.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.6);
    z-index: 150;
    backdrop-filter: blur(2px);
}
.sidebar-overlay.active { display: block; }

/* ══════════════════════════════════════════
   RESPONSIVE
══════════════════════════════════════════ */
@media (max-width: 900px) {
    .settings-grid { grid-template-columns: 1fr; }
}

@media (max-width: 768px) {
    /* Sidebar: slide off-canvas */
    .sidebar {
        transform: translateX(-100%);
        transition: transform .25s ease;
        z-index: 200;
    }
    .sidebar.open { transform: translateX(0); }

    /* Show mobile top bar */
    .mobile-topbar { display: flex; }

    /* Main content full width, no top offset needed (topbar is sticky) */
    .main-content {
        margin-left: 0;
        padding: 1.25rem 1rem;
        overflow-x: hidden;
    }

    /* Page header stacks */
    .page-header {
        flex-direction: column;
        align-items: flex-start;
        gap: .75rem;
    }
    .page-header h1 { font-size: 1.3rem; }

    /* Glass cards full width */
    .glass-card[style*="max-width"] { max-width: 100% !important; }

    /* Tables scroll INSIDE container only */
    .table-container {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        max-width: 100%;
    }
    .data-table { min-width: 540px; }

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

    /* Automations */
    .automations-grid { grid-template-columns: 1fr !important; }

    /* Portal */
    .portal-body { padding: 1.5rem 1rem; }
    .portal-header { padding: 1rem 1.25rem; }
}

@media (max-width: 480px) {
    .stats-grid { grid-template-columns: 1fr; }
    .data-table { min-width: 460px; }
}
