/* ===== Reset & Base ===== */
* { margin: 0; padding: 0; box-sizing: border-box; }
body { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif; background: #f0f2f5; color: #333; }
a { text-decoration: none; color: inherit; }

/* ===== Login Page ===== */
.login-container {
    display: flex; align-items: center; justify-content: center;
    min-height: 100vh; background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
}
.login-box {
    background: #fff; border-radius: 12px; padding: 48px 40px; width: 400px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.3);
}
.login-box h1 { text-align: center; color: #1a1a2e; margin-bottom: 8px; font-size: 24px; }
.login-box p.subtitle { text-align: center; color: #888; margin-bottom: 32px; font-size: 14px; }
.login-box .form-group { margin-bottom: 20px; }
.login-box label { display: block; font-size: 13px; font-weight: 600; color: #555; margin-bottom: 6px; }
.login-box input[type="text"],
.login-box input[type="password"] {
    width: 100%; padding: 12px 14px; border: 1px solid #ddd; border-radius: 8px;
    font-size: 14px; transition: border-color 0.2s;
}
.login-box input:focus { outline: none; border-color: #0381FE; }
.login-box .btn-login {
    width: 100%; padding: 14px; background: #0381FE; color: #fff; border: none;
    border-radius: 8px; font-size: 15px; font-weight: 600; cursor: pointer; transition: background 0.2s;
}
.login-box .btn-login:hover { background: #026fdb; }
.login-error { color: #e74c3c; font-size: 13px; margin-top: 12px; text-align: center; display: none; }

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

/* Sidebar */
.sidebar {
    width: 260px; background: #1a1a2e; color: #fff; display: flex; flex-direction: column;
    position: fixed; top: 0; left: 0; bottom: 0; z-index: 100;
}
.sidebar-header {
    padding: 24px 20px; border-bottom: 1px solid rgba(255,255,255,0.08);
}
.sidebar-header h2 { font-size: 18px; font-weight: 700; }
.sidebar-header span { font-size: 12px; color: rgba(255,255,255,0.5); }
.sidebar-nav { flex: 1; padding: 12px 0; }
.sidebar-nav .nav-item {
    display: flex; align-items: center; padding: 12px 20px; cursor: pointer;
    color: rgba(255,255,255,0.6); font-size: 14px; transition: all 0.2s; border-left: 3px solid transparent;
}
.sidebar-nav .nav-item:hover { background: rgba(255,255,255,0.05); color: #fff; }
.sidebar-nav .nav-item.active {
    background: rgba(3,129,254,0.15); color: #0381FE; border-left-color: #0381FE;
}
.sidebar-nav .nav-item .icon { width: 24px; margin-right: 12px; text-align: center; font-size: 16px; }
.sidebar-footer {
    padding: 16px 20px; border-top: 1px solid rgba(255,255,255,0.08);
}
.sidebar-footer .btn-logout {
    width: 100%; padding: 10px; background: rgba(255,255,255,0.08); color: rgba(255,255,255,0.7);
    border: none; border-radius: 6px; cursor: pointer; font-size: 13px; transition: all 0.2s;
}
.sidebar-footer .btn-logout:hover { background: rgba(231,76,60,0.3); color: #e74c3c; }

/* Main Content */
.main-content { flex: 1; margin-left: 260px; padding: 24px 32px; }
.page-header { margin-bottom: 24px; }
.page-header h1 { font-size: 24px; font-weight: 700; color: #1a1a2e; }
.page-header p { font-size: 14px; color: #888; margin-top: 4px; }

/* ===== Cards ===== */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 20px; margin-bottom: 24px; }
.stat-card {
    background: #fff; border-radius: 12px; padding: 24px; box-shadow: 0 2px 8px rgba(0,0,0,0.06);
    position: relative; overflow: hidden;
}
.stat-card::before {
    content: ''; position: absolute; top: 0; left: 0; width: 4px; height: 100%;
}
.stat-card.blue::before { background: #0381FE; }
.stat-card.green::before { background: #27ae60; }
.stat-card.orange::before { background: #f39c12; }
.stat-card.purple::before { background: #8e44ad; }
.stat-card .stat-icon { font-size: 28px; margin-bottom: 12px; }
.stat-card .stat-value { font-size: 28px; font-weight: 700; color: #1a1a2e; }
.stat-card .stat-label { font-size: 13px; color: #888; margin-top: 4px; }

/* ===== Card (generic) ===== */
.card {
    background: #fff; border-radius: 12px; padding: 24px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.06); margin-bottom: 24px;
}
.card-title { font-size: 16px; font-weight: 700; color: #1a1a2e; margin-bottom: 16px; }

/* ===== Tables ===== */
.table-wrapper { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
thead th {
    background: #f8f9fa; padding: 12px 14px; text-align: left; font-weight: 600;
    color: #555; border-bottom: 2px solid #e9ecef; white-space: nowrap;
}
tbody td { padding: 12px 14px; border-bottom: 1px solid #f0f0f0; }
tbody tr:nth-child(even) { background: #fafbfc; }
tbody tr:hover { background: #f0f5ff; cursor: pointer; }
tbody tr.no-hover:hover { background: inherit; cursor: default; }

/* ===== Badges ===== */
.badge {
    display: inline-block; padding: 4px 10px; border-radius: 12px; font-size: 11px; font-weight: 600;
}
.badge-active { background: #e8f8f0; color: #27ae60; }
.badge-suspended { background: #fdf0ef; color: #e74c3c; }
.badge-completed { background: #e8f8f0; color: #27ae60; }
.badge-pending { background: #fff8e6; color: #f39c12; }
.badge-failed { background: #fdf0ef; color: #e74c3c; }
.badge-free { background: #f0f0f0; color: #666; }
.badge-paid { background: #e6f0ff; color: #0381FE; }
.badge-premium { background: #f5e6ff; color: #8e44ad; }

/* ===== Buttons ===== */
.btn {
    padding: 8px 16px; border: none; border-radius: 6px; font-size: 13px;
    font-weight: 600; cursor: pointer; transition: all 0.2s;
}
.btn-primary { background: #0381FE; color: #fff; }
.btn-primary:hover { background: #026fdb; }
.btn-secondary { background: #f0f2f5; color: #555; }
.btn-secondary:hover { background: #e0e3e8; }
.btn-danger { background: #fdf0ef; color: #e74c3c; }
.btn-danger:hover { background: #f9d6d3; }
.btn-sm { padding: 5px 10px; font-size: 12px; }

/* ===== Forms / Inputs ===== */
.form-row { display: flex; gap: 12px; align-items: center; margin-bottom: 16px; flex-wrap: wrap; }
.form-row label { font-size: 13px; font-weight: 600; color: #555; white-space: nowrap; }
.input {
    padding: 8px 12px; border: 1px solid #ddd; border-radius: 6px; font-size: 13px;
}
.input:focus { outline: none; border-color: #0381FE; }
select.input { cursor: pointer; }

/* ===== Modal ===== */
.modal-overlay {
    display: none; position: fixed; top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.5); z-index: 200; align-items: center; justify-content: center;
}
.modal-overlay.show { display: flex; }
.modal {
    background: #fff; border-radius: 12px; padding: 32px; width: 560px; max-width: 90vw;
    max-height: 80vh; overflow-y: auto; box-shadow: 0 20px 60px rgba(0,0,0,0.3);
}
.modal-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 24px; }
.modal-header h2 { font-size: 18px; font-weight: 700; }
.modal-close { background: none; border: none; font-size: 24px; cursor: pointer; color: #888; }
.modal-close:hover { color: #333; }
.modal-body .detail-row { display: flex; padding: 10px 0; border-bottom: 1px solid #f0f0f0; }
.modal-body .detail-label { width: 120px; font-size: 13px; color: #888; font-weight: 600; }
.modal-body .detail-value { flex: 1; font-size: 13px; }
.modal-actions { margin-top: 24px; display: flex; gap: 12px; }

/* ===== Chart (CSS bars) ===== */
.chart-container { margin-top: 16px; }
.chart-bar-group { display: flex; align-items: center; margin-bottom: 8px; }
.chart-label { width: 80px; font-size: 12px; color: #888; text-align: right; padding-right: 12px; }
.chart-bars { flex: 1; display: flex; gap: 2px; height: 24px; }
.chart-bar { height: 100%; border-radius: 3px; min-width: 2px; position: relative; transition: width 0.3s; }
.chart-bar.sms { background: #0381FE; }
.chart-bar.lms { background: #27ae60; }
.chart-bar.mms { background: #f39c12; }
.chart-value { font-size: 11px; color: #888; margin-left: 8px; white-space: nowrap; align-self: center; }
.chart-legend { display: flex; gap: 20px; margin-bottom: 16px; }
.chart-legend-item { display: flex; align-items: center; gap: 6px; font-size: 12px; color: #666; }
.chart-legend-dot { width: 10px; height: 10px; border-radius: 3px; }

/* ===== Config Table ===== */
.config-input {
    width: 100%; padding: 6px 10px; border: 1px solid transparent; border-radius: 4px;
    font-size: 13px; background: transparent; transition: all 0.2s;
}
.config-input:hover { border-color: #ddd; background: #fafbfc; }
.config-input:focus { outline: none; border-color: #0381FE; background: #fff; }

/* ===== Pagination ===== */
.pagination { display: flex; justify-content: center; align-items: center; gap: 8px; margin-top: 16px; }
.pagination button {
    padding: 6px 12px; border: 1px solid #ddd; background: #fff; border-radius: 6px;
    font-size: 13px; cursor: pointer;
}
.pagination button:hover { background: #f0f5ff; border-color: #0381FE; }
.pagination button:disabled { opacity: 0.4; cursor: not-allowed; }
.pagination span { font-size: 13px; color: #888; }

/* ===== Loading ===== */
.loading { text-align: center; padding: 40px; color: #888; font-size: 14px; }

/* ===== Toast ===== */
.toast-container { position: fixed; top: 20px; right: 20px; z-index: 300; }
.toast {
    padding: 14px 20px; border-radius: 8px; margin-bottom: 8px; font-size: 13px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15); animation: slideIn 0.3s ease;
}
.toast-success { background: #27ae60; color: #fff; }
.toast-error { background: #e74c3c; color: #fff; }
@keyframes slideIn { from { transform: translateX(100%); opacity: 0; } to { transform: translateX(0); opacity: 1; } }

/* ===== Responsive ===== */
@media (max-width: 768px) {
    .sidebar { width: 60px; }
    .sidebar-header h2, .sidebar-header span, .nav-item span, .sidebar-footer { display: none; }
    .sidebar-nav .nav-item { justify-content: center; padding: 14px 0; }
    .sidebar-nav .nav-item .icon { margin-right: 0; }
    .main-content { margin-left: 60px; padding: 16px; }
    .stats-grid { grid-template-columns: repeat(2, 1fr); }
    .modal { width: 95vw; padding: 20px; }
}
