/* =============================================
   SMS Gateway — Base CSS
   Font: Roboto | Palette: Neutral
   ============================================= */

/* --- Google Fonts --- */
@import url('https://fonts.googleapis.com/css2?family=Roboto:wght@300;400;500;700&display=swap');

/* --- CSS Reset --- */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

/* --- CSS Variables (Design Tokens) --- */
:root {
    /* Colors - Neutral palette */
    --color-bg: #f5f6f8;
    --color-surface: #ffffff;
    --color-surface-hover: #f9fafb;
    --color-border: #e2e5e9;
    --color-border-light: #eef0f3;
    --color-text: #1a1d23;
    --color-text-secondary: #6b7280;
    --color-text-muted: #9ca3af;
    --color-text-inverse: #ffffff;

    /* Accent (subtle blue-gray) */
    --color-primary: #3b5998;
    --color-primary-hover: #2d4a7a;
    --color-primary-light: #e8edf5;
    --color-primary-text: #ffffff;

    /* Status */
    --color-success: #22c55e;
    --color-success-bg: #f0fdf4;
    --color-warning: #f59e0b;
    --color-warning-bg: #fffbeb;
    --color-danger: #ef4444;
    --color-danger-bg: #fef2f2;
    --color-info: #3b82f6;
    --color-info-bg: #eff6ff;

    /* Online/Offline */
    --color-online: #22c55e;
    --color-offline: #d1d5db;

    /* Typography */
    --font-family: 'Roboto', -apple-system, BlinkMacSystemFont, sans-serif;
    --font-size-xs: 0.6875rem;    /* 11px */
    --font-size-sm: 0.75rem;      /* 12px */
    --font-size-base: 0.8125rem;  /* 13px */
    --font-size-md: 0.875rem;     /* 14px */
    --font-size-lg: 1rem;         /* 16px */
    --font-size-xl: 1.25rem;      /* 20px */
    --font-size-2xl: 1.5rem;      /* 24px */

    /* Spacing */
    --space-1: 0.25rem;
    --space-2: 0.5rem;
    --space-3: 0.75rem;
    --space-4: 1rem;
    --space-5: 1.25rem;
    --space-6: 1.5rem;
    --space-8: 2rem;
    --space-10: 2.5rem;
    --space-12: 3rem;

    /* Radius */
    --radius-sm: 4px;
    --radius: 6px;
    --radius-lg: 10px;
    --radius-xl: 16px;
    --radius-full: 9999px;

    /* Shadows */
    --shadow-sm: 0 1px 2px rgba(0,0,0,0.04);
    --shadow: 0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
    --shadow-md: 0 4px 6px rgba(0,0,0,0.05), 0 2px 4px rgba(0,0,0,0.04);
    --shadow-lg: 0 10px 15px rgba(0,0,0,0.06), 0 4px 6px rgba(0,0,0,0.04);

    /* Transitions */
    --transition: 150ms ease;
    --transition-slow: 250ms ease;
}

/* --- Base --- */
html {
    font-size: 16px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    font-family: var(--font-family);
    font-size: var(--font-size-base);
    font-weight: 400;
    color: var(--color-text);
    background: var(--color-bg);
    line-height: 1.5;
    min-height: 100vh;
}

a {
    color: var(--color-primary);
    text-decoration: none;
    transition: color var(--transition);
}
a:hover {
    color: var(--color-primary-hover);
}

img { max-width: 100%; height: auto; }

/* --- Typography --- */
h1, h2, h3, h4 {
    font-weight: 500;
    color: var(--color-text);
    line-height: 1.3;
}
h1 { font-size: var(--font-size-2xl); }
h2 { font-size: var(--font-size-xl); }
h3 { font-size: var(--font-size-lg); }
h4 { font-size: var(--font-size-md); }

.text-secondary { color: var(--color-text-secondary); }
.text-muted { color: var(--color-text-muted); }
.text-sm { font-size: var(--font-size-sm); }
.text-xs { font-size: var(--font-size-xs); }

/* --- Card --- */
.card {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    padding: var(--space-5);
    box-shadow: var(--shadow-sm);
}
.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding-bottom: var(--space-4);
    border-bottom: 1px solid var(--color-border-light);
    margin-bottom: var(--space-4);
}
.card-header h3 {
    font-size: var(--font-size-md);
    font-weight: 500;
}

/* --- Buttons --- */
.btn {
    display: inline-flex;
    align-items: center;
    gap: var(--space-2);
    padding: var(--space-2) var(--space-4);
    font-family: var(--font-family);
    font-size: var(--font-size-sm);
    font-weight: 500;
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    background: var(--color-surface);
    color: var(--color-text);
    cursor: pointer;
    transition: all var(--transition);
    white-space: nowrap;
    line-height: 1.5;
}
.btn:hover {
    background: var(--color-surface-hover);
    border-color: #d1d5db;
}
.btn-primary {
    background: var(--color-primary);
    border-color: var(--color-primary);
    color: var(--color-primary-text);
}
.btn-primary:hover {
    background: var(--color-primary-hover);
    border-color: var(--color-primary-hover);
}
.btn-danger {
    background: var(--color-danger);
    border-color: var(--color-danger);
    color: #fff;
}
.btn-danger:hover { opacity: 0.9; }
.btn-sm {
    padding: var(--space-1) var(--space-3);
    font-size: var(--font-size-xs);
}
.btn-icon {
    padding: var(--space-2);
    border: none;
    background: transparent;
    color: var(--color-text-secondary);
    cursor: pointer;
    border-radius: var(--radius);
    transition: all var(--transition);
}
.btn-icon:hover {
    background: var(--color-bg);
    color: var(--color-text);
}
.btn svg { width: 16px; height: 16px; }

/* --- Forms --- */
.form-group {
    margin-bottom: var(--space-4);
}
.form-group label {
    display: block;
    font-size: var(--font-size-sm);
    font-weight: 500;
    color: var(--color-text-secondary);
    margin-bottom: var(--space-1);
}
.form-control {
    width: 100%;
    padding: var(--space-2) var(--space-3);
    font-family: var(--font-family);
    font-size: var(--font-size-base);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    background: var(--color-surface);
    color: var(--color-text);
    transition: border-color var(--transition);
    outline: none;
}
.form-control:focus {
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px var(--color-primary-light);
}
.form-control::placeholder {
    color: var(--color-text-muted);
}
textarea.form-control {
    resize: vertical;
    min-height: 80px;
}
select.form-control {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='%236b7280' viewBox='0 0 16 16'%3E%3Cpath d='M8 11L3 6h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 10px center;
    padding-right: 32px;
}

/* --- Table --- */
.table-wrap {
    overflow-x: auto;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    background: var(--color-surface);
}
table {
    width: 100%;
    border-collapse: collapse;
    font-size: var(--font-size-sm);
}
thead th {
    text-align: left;
    padding: var(--space-3) var(--space-4);
    font-weight: 500;
    font-size: var(--font-size-xs);
    color: var(--color-text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    background: var(--color-bg);
    border-bottom: 1px solid var(--color-border);
    white-space: nowrap;
}
tbody td {
    padding: var(--space-3) var(--space-4);
    border-bottom: 1px solid var(--color-border-light);
    vertical-align: middle;
}
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: var(--color-surface-hover); }

/* --- Badge --- */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 8px;
    font-size: var(--font-size-xs);
    font-weight: 500;
    border-radius: var(--radius-full);
    line-height: 1.5;
}
.badge-success {
    background: var(--color-success-bg);
    color: #15803d;
}
.badge-warning {
    background: var(--color-warning-bg);
    color: #b45309;
}
.badge-danger {
    background: var(--color-danger-bg);
    color: #dc2626;
}
.badge-info {
    background: var(--color-info-bg);
    color: #2563eb;
}
.badge-muted {
    background: var(--color-bg);
    color: var(--color-text-secondary);
}

/* --- Status dot --- */
.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    display: inline-block;
    flex-shrink: 0;
}
.status-dot.online { background: var(--color-online); box-shadow: 0 0 0 2px rgba(34,197,94,0.2); }
.status-dot.offline { background: var(--color-offline); }

/* --- Empty state --- */
.empty-state {
    text-align: center;
    padding: var(--space-12) var(--space-4);
    color: var(--color-text-muted);
}
.empty-state svg {
    width: 48px;
    height: 48px;
    margin-bottom: var(--space-4);
    opacity: 0.4;
}
.empty-state p {
    font-size: var(--font-size-sm);
}

/* --- Toast notifications --- */
.toast-container {
    position: fixed;
    top: var(--space-4);
    right: var(--space-4);
    z-index: 10000;
    display: flex;
    flex-direction: column;
    gap: var(--space-2);
}
.toast {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    padding: var(--space-3) var(--space-4);
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    font-size: var(--font-size-sm);
    animation: toast-in 250ms ease;
    max-width: 360px;
}
.toast.toast-success { border-left: 3px solid var(--color-success); }
.toast.toast-error { border-left: 3px solid var(--color-danger); }
.toast.toast-info { border-left: 3px solid var(--color-info); }

@keyframes toast-in {
    from { opacity: 0; transform: translateX(100%); }
    to { opacity: 1; transform: translateX(0); }
}

/* --- Modal --- */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.3);
    backdrop-filter: blur(2px);
    z-index: 9000;
    display: none;
    align-items: center;
    justify-content: center;
    animation: fade-in 150ms ease;
}
.modal-overlay.active { display: flex; }
.modal {
    background: var(--color-surface);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-lg);
    width: 90%;
    max-width: 500px;
    max-height: 85vh;
    overflow-y: auto;
    animation: modal-in 200ms ease;
}
.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--space-5);
    border-bottom: 1px solid var(--color-border-light);
}
.modal-header h3 { font-size: var(--font-size-md); }
.modal-body { padding: var(--space-5); }
.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: var(--space-2);
    padding: var(--space-4) var(--space-5);
    border-top: 1px solid var(--color-border-light);
}

@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes modal-in { from { opacity: 0; transform: scale(0.95); } to { opacity: 1; transform: scale(1); } }

/* --- Pagination --- */
.pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-1);
    padding: var(--space-4) 0;
}
.pagination a, .pagination span {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 32px;
    height: 32px;
    padding: 0 var(--space-2);
    font-size: var(--font-size-sm);
    border-radius: var(--radius);
    color: var(--color-text-secondary);
    transition: all var(--transition);
}
.pagination a:hover { background: var(--color-bg); color: var(--color-text); }
.pagination .active {
    background: var(--color-primary);
    color: var(--color-primary-text);
}

/* --- Search bar --- */
.search-bar {
    position: relative;
}
.search-bar input {
    padding-left: 36px;
}
.search-bar svg {
    position: absolute;
    left: 10px;
    top: 50%;
    transform: translateY(-50%);
    width: 16px;
    height: 16px;
    color: var(--color-text-muted);
    pointer-events: none;
}

/* --- Stat cards --- */
.stat-grid {
    display: grid;
    gap: var(--space-4);
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
}
.stat-card {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    padding: var(--space-5);
    display: flex;
    align-items: flex-start;
    gap: var(--space-3);
}
.stat-card .stat-icon {
    width: 40px;
    height: 40px;
    border-radius: var(--radius-lg);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}
.stat-card .stat-icon svg { width: 20px; height: 20px; }
.stat-card .stat-value {
    font-size: var(--font-size-2xl);
    font-weight: 700;
    line-height: 1;
    margin-bottom: 2px;
}
.stat-card .stat-label {
    font-size: var(--font-size-xs);
    color: var(--color-text-secondary);
}

/* --- Utils --- */
.flex { display: flex; }
.flex-between { display: flex; align-items: center; justify-content: space-between; }
.flex-center { display: flex; align-items: center; justify-content: center; }
.gap-2 { gap: var(--space-2); }
.gap-3 { gap: var(--space-3); }
.gap-4 { gap: var(--space-4); }
.mt-4 { margin-top: var(--space-4); }
.mb-4 { margin-bottom: var(--space-4); }
.hidden { display: none !important; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
