/* ============================================================
   LJ SMS Gateway — Dashboard Styles
   Premium SaaS-style design system
   ============================================================ */

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

/* ---- CSS Variables ---- */
:root {
    --bg-primary: #0f1117;
    --bg-secondary: #161822;
    --bg-card: #1c1e2e;
    --bg-card-hover: #232540;
    --bg-input: #1c1e2e;
    --bg-sidebar: #0d0e14;
    --border-color: #2a2d3e;
    --border-focus: #6366f1;
    --text-primary: #e8eaed;
    --text-secondary: #9ca3af;
    --text-muted: #6b7280;
    --accent-primary: #6366f1;
    --accent-primary-hover: #818cf8;
    --accent-gradient: linear-gradient(135deg, #6366f1, #8b5cf6);
    --success: #10b981;
    --success-bg: rgba(16, 185, 129, 0.12);
    --warning: #f59e0b;
    --warning-bg: rgba(245, 158, 11, 0.12);
    --danger: #ef4444;
    --danger-bg: rgba(239, 68, 68, 0.12);
    --info: #3b82f6;
    --info-bg: rgba(59, 130, 246, 0.12);
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 10px 30px rgba(0, 0, 0, 0.5);
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 16px;
    --transition: 0.2s ease;
}

/* ---- Reset ---- */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

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

a {
    color: var(--accent-primary);
    text-decoration: none;
    transition: color var(--transition);
}

a:hover {
    color: var(--accent-primary-hover);
}

/* ---- Layout ---- */
.app-layout {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    width: 260px;
    background: var(--bg-sidebar);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 100;
    transition: transform 0.3s ease;
}

.sidebar-logo {
    padding: 24px 20px;
    border-bottom: 1px solid var(--border-color);
}

.sidebar-logo h1 {
    font-size: 18px;
    font-weight: 700;
    background: var(--accent-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    letter-spacing: -0.3px;
}

.sidebar-logo span {
    font-size: 11px;
    color: var(--text-muted);
    font-weight: 400;
    display: block;
    margin-top: 2px;
}

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

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 14px;
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    font-size: 14px;
    font-weight: 500;
    transition: all var(--transition);
    margin-bottom: 2px;
}

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

.nav-item.active {
    background: rgba(99, 102, 241, 0.15);
    color: var(--accent-primary);
}

.nav-item svg {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
}

.sidebar-footer {
    padding: 16px 12px;
    border-top: 1px solid var(--border-color);
}

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

.page-header {
    padding: 24px 32px;
    border-bottom: 1px solid var(--border-color);
    background: var(--bg-secondary);
}

.page-header h2 {
    font-size: 22px;
    font-weight: 700;
    letter-spacing: -0.3px;
}

.page-body {
    padding: 24px 32px;
}

/* ---- Cards ---- */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 20px;
    transition: all var(--transition);
}

.card:hover {
    border-color: rgba(99, 102, 241, 0.3);
}

.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
}

.card-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* ---- Metric Cards ---- */
.metrics-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.metric-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 20px;
    position: relative;
    overflow: hidden;
}

.metric-card::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: var(--accent-gradient);
    opacity: 0;
    transition: opacity var(--transition);
}

.metric-card:hover::after {
    opacity: 1;
}

.metric-label {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 8px;
}

.metric-value {
    font-size: 28px;
    font-weight: 800;
    letter-spacing: -1px;
    line-height: 1;
}

.metric-value.success { color: var(--success); }
.metric-value.danger { color: var(--danger); }
.metric-value.warning { color: var(--warning); }
.metric-value.info { color: var(--info); }

/* ---- Badges ---- */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.badge-online, .badge-active, .badge-sent, .badge-delivered {
    background: var(--success-bg);
    color: var(--success);
}

.badge-offline, .badge-disabled, .badge-failed, .badge-revoked {
    background: var(--danger-bg);
    color: var(--danger);
}

.badge-queued, .badge-claimed, .badge-sending, .badge-pending {
    background: var(--info-bg);
    color: var(--info);
}

.badge-retry, .badge-warning {
    background: var(--warning-bg);
    color: var(--warning);
}

.badge-cancelled, .badge-expired, .badge-used {
    background: rgba(107, 114, 128, 0.15);
    color: var(--text-muted);
}

.badge-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: currentColor;
    animation: pulse-dot 2s ease-in-out infinite;
}

@keyframes pulse-dot {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.4; }
}

/* ---- Tables ---- */
.table-container {
    overflow-x: auto;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
}

table {
    width: 100%;
    border-collapse: collapse;
}

th {
    padding: 12px 16px;
    text-align: left;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border-color);
    white-space: nowrap;
}

td {
    padding: 12px 16px;
    font-size: 13px;
    border-bottom: 1px solid rgba(42, 45, 62, 0.5);
    color: var(--text-secondary);
}

tr:hover td {
    background: rgba(99, 102, 241, 0.04);
}

td .mono {
    font-family: 'JetBrains Mono', 'Fira Code', monospace;
    font-size: 12px;
    color: var(--text-primary);
}

td .truncate {
    max-width: 250px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* ---- Buttons ---- */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-weight: 600;
    border: none;
    cursor: pointer;
    transition: all var(--transition);
    text-decoration: none;
    white-space: nowrap;
}

.btn-primary {
    background: var(--accent-gradient);
    color: white;
    box-shadow: 0 2px 8px rgba(99, 102, 241, 0.3);
}

.btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.4);
    color: white;
}

.btn-secondary {
    background: var(--bg-card);
    color: var(--text-secondary);
    border: 1px solid var(--border-color);
}

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

.btn-danger {
    background: var(--danger-bg);
    color: var(--danger);
    border: 1px solid rgba(239, 68, 68, 0.2);
}

.btn-danger:hover {
    background: rgba(239, 68, 68, 0.2);
}

.btn-sm {
    padding: 5px 10px;
    font-size: 12px;
}

.btn-group {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

/* ---- Forms ---- */
.form-group {
    margin-bottom: 16px;
}

.form-label {
    display: block;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 6px;
}

.form-input, .form-select {
    width: 100%;
    padding: 10px 14px;
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 14px;
    font-family: inherit;
    transition: border-color var(--transition);
}

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

.form-input::placeholder {
    color: var(--text-muted);
}

/* ---- Filter Bar ---- */
.filter-bar {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    align-items: flex-end;
    margin-bottom: 20px;
    padding: 16px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
}

.filter-bar .form-group {
    margin-bottom: 0;
    min-width: 150px;
}

/* ---- Gateway Status Card ---- */
.gateway-status-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 24px;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    margin-bottom: 24px;
}

.gateway-status-card .status-main {
    grid-column: 1 / -1;
    display: flex;
    align-items: center;
    gap: 16px;
}

.status-indicator {
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: var(--success);
    box-shadow: 0 0 10px rgba(16, 185, 129, 0.5);
    animation: pulse-glow 2s ease-in-out infinite;
}

.status-indicator.offline {
    background: var(--danger);
    box-shadow: 0 0 10px rgba(239, 68, 68, 0.5);
    animation: none;
}

@keyframes pulse-glow {
    0%, 100% { box-shadow: 0 0 10px rgba(16, 185, 129, 0.5); }
    50% { box-shadow: 0 0 20px rgba(16, 185, 129, 0.8); }
}

.status-info dt {
    font-size: 11px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 4px;
}

.status-info dd {
    font-size: 14px;
    color: var(--text-primary);
    font-weight: 500;
}

/* ---- Timeline ---- */
.timeline {
    position: relative;
    padding-left: 28px;
}

.timeline::before {
    content: '';
    position: absolute;
    left: 8px;
    top: 4px;
    bottom: 4px;
    width: 2px;
    background: var(--border-color);
}

.timeline-item {
    position: relative;
    padding-bottom: 20px;
}

.timeline-item::before {
    content: '';
    position: absolute;
    left: -24px;
    top: 6px;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--border-color);
    border: 2px solid var(--bg-card);
}

.timeline-item.active::before {
    background: var(--accent-primary);
    box-shadow: 0 0 8px rgba(99, 102, 241, 0.5);
}

.timeline-item.success::before {
    background: var(--success);
}

.timeline-item.error::before {
    background: var(--danger);
}

.timeline-label {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-primary);
}

.timeline-time {
    font-size: 12px;
    color: var(--text-muted);
}

/* ---- Alert Box ---- */
.alert-box {
    padding: 16px 20px;
    border-radius: var(--radius-md);
    margin-bottom: 20px;
    font-size: 14px;
    border: 1px solid;
}

.alert-success {
    background: var(--success-bg);
    border-color: rgba(16, 185, 129, 0.3);
    color: var(--success);
}

.alert-warning {
    background: var(--warning-bg);
    border-color: rgba(245, 158, 11, 0.3);
    color: var(--warning);
}

.alert-danger {
    background: var(--danger-bg);
    border-color: rgba(239, 68, 68, 0.3);
    color: var(--danger);
}

.alert-info {
    background: var(--info-bg);
    border-color: rgba(59, 130, 246, 0.3);
    color: var(--info);
}

/* ---- Key Display ---- */
.key-display {
    background: var(--bg-primary);
    border: 1px solid var(--accent-primary);
    border-radius: var(--radius-sm);
    padding: 12px 16px;
    font-family: 'JetBrains Mono', 'Fira Code', monospace;
    font-size: 13px;
    color: var(--accent-primary-hover);
    word-break: break-all;
    margin: 8px 0;
}

/* ---- Pagination ---- */
.pagination {
    display: flex;
    gap: 4px;
    align-items: center;
    justify-content: center;
    margin-top: 20px;
}

.pagination a, .pagination span {
    padding: 6px 12px;
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-weight: 500;
}

.pagination a {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
}

.pagination a:hover {
    background: var(--bg-card-hover);
    color: var(--text-primary);
}

.pagination .current {
    background: var(--accent-primary);
    color: white;
}

/* ---- Modal ---- */
.modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    z-index: 200;
    display: none;
}

.modal-backdrop.show {
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 24px;
    width: 100%;
    max-width: 480px;
    box-shadow: var(--shadow-lg);
}

.modal h3 {
    font-size: 18px;
    font-weight: 700;
    margin-bottom: 16px;
}

/* ---- Toast ---- */
.toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 300;
}

.toast {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 14px 20px;
    margin-bottom: 8px;
    box-shadow: var(--shadow-lg);
    animation: slide-in 0.3s ease;
    max-width: 360px;
}

@keyframes slide-in {
    from { transform: translateX(100%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

/* ---- Responsive ---- */
@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
    }

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

    .main-content {
        margin-left: 0;
    }

    .page-header, .page-body {
        padding: 16px;
    }

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

    .gateway-status-card {
        grid-template-columns: 1fr;
    }

    .filter-bar {
        flex-direction: column;
    }
}

/* ---- Login Page ---- */
.login-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: var(--bg-primary);
}

.login-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 40px;
    width: 100%;
    max-width: 400px;
    box-shadow: var(--shadow-lg);
}

.login-card h1 {
    font-size: 24px;
    font-weight: 800;
    background: var(--accent-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    text-align: center;
    margin-bottom: 8px;
}

.login-card p {
    text-align: center;
    color: var(--text-muted);
    font-size: 14px;
    margin-bottom: 24px;
}

.login-card .btn-primary {
    width: 100%;
    justify-content: center;
    padding: 12px;
    font-size: 14px;
}

/* ---- Utility ---- */
.flex { display: flex; }
.flex-wrap { flex-wrap: wrap; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }
.gap-4 { gap: 16px; }
.mb-2 { margin-bottom: 8px; }
.mb-3 { margin-bottom: 12px; }
.mb-4 { margin-bottom: 16px; }
.mt-3 { margin-top: 12px; }
.mt-4 { margin-top: 16px; }
.text-sm { font-size: 13px; }
.text-xs { font-size: 11px; }
.text-muted { color: var(--text-muted); }
.font-mono { font-family: 'JetBrains Mono', 'Fira Code', monospace; }
