/* QRSMS — Styles */
:root {
    --primary: #2563eb;
    --primary-dark: #1d4ed8;
    --danger: #dc2626;
    --success: #16a34a;
    --warning: #f59e0b;
    --gray-50: #f9fafb;
    --gray-100: #f3f4f6;
    --gray-200: #e5e7eb;
    --gray-300: #d1d5db;
    --gray-500: #6b7280;
    --gray-700: #374151;
    --gray-900: #111827;
    --sidebar-width: 220px;
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--gray-50);
    color: var(--gray-900);
    line-height: 1.5;
}

/* Login page */
.login-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
}

.login-container {
    background: white;
    padding: 2rem;
    border-radius: 12px;
    box-shadow: 0 4px 24px rgba(0,0,0,0.15);
    width: 100%;
    max-width: 380px;
    text-align: center;
}

.login-container h1 { font-size: 2rem; margin-bottom: 0.25rem; }
.login-container .subtitle { color: var(--gray-500); margin-bottom: 1.5rem; }

/* Sidebar */
.sidebar {
    position: fixed;
    top: 0;
    left: 0;
    width: var(--sidebar-width);
    height: 100vh;
    background: var(--gray-900);
    color: white;
    display: flex;
    flex-direction: column;
    z-index: 100;
}

.sidebar-brand {
    padding: 1.25rem;
    border-bottom: 1px solid var(--gray-700);
}

.sidebar-brand h1 { font-size: 1.25rem; }

.sidebar-nav {
    list-style: none;
    flex: 1;
    padding: 0.5rem 0;
}

.sidebar-nav a {
    display: block;
    padding: 0.75rem 1.25rem;
    color: var(--gray-300);
    text-decoration: none;
    transition: background 0.15s;
}

.sidebar-nav a:hover,
.sidebar-nav a.active {
    background: var(--gray-700);
    color: white;
}

.sidebar-footer {
    padding: 1rem 1.25rem;
    border-top: 1px solid var(--gray-700);
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 0.875rem;
}

/* Content */
.content {
    margin-left: var(--sidebar-width);
    padding: 1.5rem 2rem;
    min-height: 100vh;
}

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

.stat-card {
    background: white;
    padding: 1.25rem;
    border-radius: 8px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
    text-align: center;
}

.stat-number { font-size: 2rem; font-weight: 700; color: var(--primary); }
.stat-label { font-size: 0.85rem; color: var(--gray-500); margin-top: 0.25rem; }
.stat-warning .stat-number { color: var(--danger); }

/* Tables */
.data-table {
    width: 100%;
    border-collapse: collapse;
    background: white;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}

.data-table th {
    background: var(--gray-100);
    padding: 0.75rem 1rem;
    text-align: left;
    font-size: 0.8rem;
    text-transform: uppercase;
    color: var(--gray-500);
    font-weight: 600;
}

.data-table td {
    padding: 0.75rem 1rem;
    border-top: 1px solid var(--gray-200);
    font-size: 0.9rem;
}

.data-table tr:hover td { background: var(--gray-50); }

.msg-preview { max-width: 300px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Badges */
.badge {
    display: inline-block;
    padding: 0.2rem 0.6rem;
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 600;
}

.badge-pending { background: #fef3c7; color: #92400e; }
.badge-assigned { background: #dbeafe; color: #1e40af; }
.badge-sent { background: #dcfce7; color: #166534; }
.badge-failed { background: #fee2e2; color: #991b1b; }

/* Buttons */
.btn {
    display: inline-block;
    padding: 0.6rem 1.2rem;
    border: none;
    border-radius: 6px;
    font-size: 0.9rem;
    cursor: pointer;
    text-decoration: none;
    transition: background 0.15s;
    font-weight: 500;
}

.btn-primary { background: var(--primary); color: white; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-danger { background: var(--danger); color: white; }
.btn-outline { background: transparent; border: 1px solid var(--gray-300); color: var(--gray-700); }
.btn-outline:hover { background: var(--gray-100); }
.btn-small { padding: 0.35rem 0.75rem; font-size: 0.8rem; }
.btn-block { width: 100%; }

/* Forms */
.form-group {
    margin-bottom: 1rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.35rem;
    font-weight: 500;
    font-size: 0.9rem;
}

input[type="text"],
input[type="password"],
input[type="email"],
input[type="datetime-local"],
input[type="file"],
select,
textarea {
    width: 100%;
    padding: 0.6rem 0.75rem;
    border: 1px solid var(--gray-300);
    border-radius: 6px;
    font-size: 0.9rem;
    font-family: inherit;
}

input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

/* Alerts */
.alert {
    padding: 0.75rem 1rem;
    border-radius: 6px;
    margin-bottom: 1rem;
    font-size: 0.9rem;
}

.alert-success { background: #dcfce7; color: #166534; }
.alert-error { background: #fee2e2; color: #991b1b; }

/* Filters */
.filters { margin-bottom: 1rem; }
.filter-form { display: flex; gap: 0.5rem; align-items: center; flex-wrap: wrap; }
.filter-form input, .filter-form select { width: auto; flex: 1; min-width: 150px; }

/* Inline forms */
.inline { display: inline; }
.inline-form { display: flex; gap: 0.5rem; align-items: end; flex-wrap: wrap; padding: 1rem; margin-top: 0.5rem; background: var(--gray-50); border-radius: 8px; }
.inline-form input { flex: 1; min-width: 140px; }

.add-form-toggle { margin-bottom: 1rem; }
.add-form-toggle summary { cursor: pointer; }

/* Page header */
.page-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 1rem; }

/* Gateways */
.gateways-list { display: grid; gap: 1rem; }

.gateway-card {
    background: white;
    padding: 1.25rem;
    border-radius: 8px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}

.gateway-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 0.75rem; }
.gateway-header h3 { font-size: 1.1rem; }

.gateway-status {
    padding: 0.2rem 0.75rem;
    border-radius: 999px;
    font-size: 0.8rem;
    font-weight: 600;
}

.gateway-online { background: #dcfce7; color: #166534; }
.gateway-offline { background: #fef3c7; color: #92400e; }
.gateway-disabled { background: var(--gray-200); color: var(--gray-500); }

.gateway-info { margin-bottom: 0.75rem; font-size: 0.9rem; color: var(--gray-700); }
.gateway-info p { margin-bottom: 0.25rem; }

.gateway-qr { margin-bottom: 0.75rem; }
.qr-container { text-align: center; padding: 1rem; background: white; border: 1px solid var(--gray-200); border-radius: 8px; margin-top: 0.5rem; }
.qr-hint { font-size: 0.8rem; color: var(--gray-500); margin-top: 0.5rem; }

.gateway-actions { display: flex; gap: 0.5rem; flex-wrap: wrap; }

/* Pagination */
.pagination { display: flex; gap: 0.25rem; margin-top: 1rem; justify-content: center; }

/* Compose form */
.compose-form { max-width: 600px; background: white; padding: 1.5rem; border-radius: 8px; box-shadow: 0 1px 3px rgba(0,0,0,0.08); }
.quick-groups { display: flex; gap: 0.5rem; margin-top: 0.5rem; flex-wrap: wrap; }

#char-count { float: right; font-size: 0.8rem; color: var(--gray-500); font-weight: normal; }

/* Alert form */
.alert-form { padding: 1rem; margin-top: 0.5rem; background: var(--gray-50); border-radius: 8px; max-width: 500px; }

/* Utilities */
.text-center { text-align: center; }
h2 { margin-bottom: 1rem; }

/* Responsive */
@media (max-width: 768px) {
    .sidebar { width: 100%; height: auto; position: relative; }
    .sidebar-nav { display: flex; overflow-x: auto; padding: 0; }
    .sidebar-nav a { white-space: nowrap; padding: 0.5rem 1rem; font-size: 0.85rem; }
    .content { margin-left: 0; padding: 1rem; }
    .stats-grid { grid-template-columns: repeat(2, 1fr); }
    .data-table { font-size: 0.8rem; }
    .data-table th, .data-table td { padding: 0.5rem; }
    .sidebar-footer { padding: 0.5rem 1rem; }
}
