/* Modern Minimalist Theme */
:root {
    --primary-color: #2563eb;
    --primary-hover: #1d4ed8;
    --background: #f3f4f6;
    --surface: #ffffff;
    --text-main: #111827;
    --text-muted: #6b7280;
    --border: #e5e7eb;
    --success: #10b981;
    --warning: #f59e0b;
    --danger: #ef4444;
}

* {
    box-sizing: border-box;
}

body {
    font-family: 'Inter', sans-serif;
    background-color: var(--background);
    color: var(--text-main);
    margin: 0;
    min-height: 100vh;
}

/* Sidebar */
.sidebar {
    width: 250px;
    background: var(--surface);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    padding: 1.5rem;
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
}

.brand {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--primary-color);
    text-decoration: none;
}

.sidebar-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
}

.mobile-menu-btn {
    display: none;
    background: none;
    border: none;
    color: var(--text-main);
    cursor: pointer;
    padding: 0.5rem;
}

.nav-links {
    list-style: none;
    padding: 0;
    margin: 0;
}

.nav-links li {
    margin-bottom: 0.5rem;
}

.nav-links a {
    display: block;
    padding: 0.75rem 1rem;
    border-radius: 0.5rem;
    color: var(--text-muted);
    text-decoration: none;
    transition: all 0.2s;
    font-weight: 500;
}

.nav-links a:hover, .nav-links a.active {
    background-color: #eff6ff;
    color: var(--primary-color);
}

/* Main Content */
.main-content {
    margin-left: 250px;
    padding: 2rem;
    min-height: 100vh;
}

header {
    margin-bottom: 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

h1 {
    font-size: 1.875rem;
    font-weight: 600;
    margin: 0;
}

/* Cards (Dashboard) */
.grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 1.5rem;
}

.card {
    background: var(--surface);
    padding: 1.5rem;
    border-radius: 0.75rem;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
    transition: transform 0.2s;
    text-decoration: none;
    color: inherit;
    border: 1px solid var(--border);
}

.card:hover {
    transform: translateY(-2px);
    border-color: var(--primary-color);
}

.card h3 {
    margin: 0 0 0.5rem 0;
    font-size: 1.1rem;
    color: var(--text-muted);
}

.card .count {
    font-size: 2rem;
    font-weight: 700;
    color: var(--text-main);
}

/* Tables */
.table-container {
    background: var(--surface);
    border-radius: 0.75rem;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
    overflow: hidden;
    border: 1px solid var(--border);
}

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

th {
    background: #f9fafb;
    text-align: left;
    padding: 0.75rem 1.5rem;
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-muted);
    border-bottom: 1px solid var(--border);
}

td {
    padding: 1rem 1.5rem;
    border-bottom: 1px solid var(--border);
    font-size: 0.875rem;
}

tr:last-child td {
    border-bottom: none;
}

tr:hover {
    background-color: #f9fafb;
}

/* status badges */
.badge {
    padding: 0.25rem 0.75rem;
    border-radius: 9999px;
    font-size: 0.75rem;
    font-weight: 500;
    text-transform: capitalize;
}

.badge-sent { background: #d1fae5; color: #065f46; }
.badge-failed { background: #fee2e2; color: #991b1b; }
.badge-pending { background: #fef3c7; color: #92400e; }
.badge-default { background: #e5e7eb; color: #374151; }

/* Filter Bar */
.filter-bar {
    display: flex;
    gap: 1rem;
    margin-bottom: 1.5rem;
    background: var(--surface);
    padding: 1rem;
    border-radius: 0.75rem;
    box-shadow: 0 1px 2px rgba(0,0,0,0.05);
    border: 1px solid var(--border);
    flex-wrap: wrap;
    align-items: center;
}

.filter-bar input, .filter-bar select {
    padding: 0.5rem 1rem;
    border: 1px solid var(--border);
    border-radius: 0.375rem;
    outline: none;
}

.filter-bar input:focus, .filter-bar select:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.1);
}

.filter-bar .active-filter {
    border-color: var(--primary-color);
    background-color: var(--primary-hover);
    color: white;
}

.btn {
    padding: 0.5rem 1rem;
    border-radius: 0.375rem;
    border: none;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.2s;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
}

.btn-primary {
    background: var(--primary-color);
    color: white;
}

.btn-primary:hover {
    background: var(--primary-hover);
}

.btn-outline {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text-main);
}

.btn-outline:hover {
    background: #f9fafb;
}

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

.pagination a, .pagination span {
    padding: 0.5rem 1rem;
    border: 1px solid var(--border);
    border-radius: 0.375rem;
    text-decoration: none;
    color: var(--text-main);
    background: var(--surface);
}

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

/* Alerts / Messages */
.alert {
    padding: 1rem 1.5rem;
    border-radius: 0.5rem;
    margin-bottom: 1.5rem;
    font-weight: 500;
}
.alert-success {
    background: #dcfce7;
    color: #166534;
    border: 1px solid #bbf7d0;
}
.alert-error {
    background: #fee2e2;
    color: #991b1b;
    border: 1px solid #fecaca;
}

/* Forms */
.form-card {
    background: var(--surface);
    padding: 2rem;
    border-radius: 0.75rem;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
    border: 1px solid var(--border);
    max-width: 600px;
}
.form-field { margin-bottom: 1.5rem; }
.form-field label { display: block; margin-bottom: 0.5rem; font-weight: 500; font-size: 0.875rem; }
.form-field input[type="text"], 
.form-field input[type="password"], 
.form-field input[type="email"],
.form-field select { 
    width: 100%; padding: 0.75rem; border: 1px solid var(--border); border-radius: 0.5rem; box-sizing: border-box; outline: none; transition: border 0.2s;
}
.form-field input:focus, .form-field select:focus { border-color: var(--primary-color); }
.form-field .help { font-size: 0.75rem; color: var(--text-muted); margin-top: 0.25rem; }
.form-field label input[type="checkbox"] { margin-right: 0.5rem; width: auto; }
.form-errors { color: var(--danger); font-size: 0.875rem; margin-bottom: 1.5rem; list-style: none; padding: 0; }

/* Modal */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    backdrop-filter: blur(4px);
}

.modal {
    background: var(--surface);
    padding: 2rem;
    border-radius: 1rem;
    width: 90%;
    max-width: 800px;
    max-height: 80vh;
    overflow-y: auto;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1);
    position: relative;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
    border-bottom: 1px solid var(--border);
    padding-bottom: 1rem;
}

.modal-title {
    font-size: 1.25rem;
    font-weight: 600;
}

.modal-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--text-muted);
}

.modal-body pre {
    background: #1e293b;
    color: #f8fafc;
    padding: 1.5rem;
    border-radius: 0.5rem;
    overflow-x: auto;
    font-family: 'Courier New', Courier, monospace;
    font-size: 0.875rem;
    line-height: 1.5;
    max-width: 100%;
    word-break: break-all;
    white-space: pre-wrap;
}

.btn-sm {
    padding: 0.25rem 0.5rem;
    font-size: 0.75rem;
}

/* JSON Viewer */
.json-null { color: #f43f5e; }
.json-boolean { color: #8b5cf6; font-weight: bold; }
.json-number { color: #0ea5e9; }
.json-string { color: #10b981; }
.json-key { color: #f59e0b; font-weight: 500; }
.json-array { margin-left: 0; }
.json-object { margin-left: 0; }
.json-item { margin-left: 1.5rem; border-left: 1px dotted rgba(255,255,255,0.2); padding-left: 0.5rem; }

/* Responsive Layout */
@media (max-width: 768px) {
    .sidebar {
        position: fixed;
        top: 0;
        left: 0;
        bottom: 0;
        width: 280px;
        height: 100vh;
        z-index: 1000;
        transform: translateX(-100%);
        transition: transform 0.3s ease;
        background: var(--surface);
        border-right: 1px solid var(--border);
        box-shadow: 4px 0 15px rgba(0,0,0,0.05);
    }

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

    /* Hide the old toggle button since we use the new one */
    .mobile-menu-btn {
        display: none !important;
    }

    .nav-links {
        display: flex;
        flex-direction: column;
        width: 100%;
    }

    .nav-links li {
        margin-bottom: 0;
        margin-top: 0 !important;
        padding-top: 0 !important;
    }

    .main-content {
        margin-left: 0;
        padding: 1rem;
    }

    header {
        display: flex;
        flex-direction: row;
        flex-wrap: wrap;
        align-items: center;
        gap: 1rem;
    }

    header > h1, header > h2 {
        display: flex;
        align-items: center;
        gap: 0.75rem;
        flex: 1;
        margin: 0; /* Override any bottom margin for alignment */
    }

    header .btn {
        width: 100%;
        margin-top: 0.5rem;
    }

    .filter-bar {
        flex-direction: column;
        align-items: stretch;
    }

    .filter-bar > div, .date-filter-group {
        flex-direction: column;
        align-items: stretch;
        gap: 0.5rem;
    }

    .filter-bar input, .filter-bar select, .filter-bar .btn {
        width: 100%;
    }

    .table-container {
        overflow-x: auto;
    }

    .mobile-menu-toggle {
        display: inline-flex !important;
        background: none;
        border: none;
        color: var(--text-main);
        cursor: pointer;
        padding: 0.25rem;
        align-items: center;
        justify-content: center;
    }
}

@media (max-width: 480px) {
    .grid {
        grid-template-columns: 1fr;
    }
    .modal {
        padding: 1rem;
        width: 95%;
    }
}

/* Utility & Component Classes Replacing Inline Styles */
.text-muted { color: var(--text-muted); }
.text-muted-xs { font-size: 0.8em; color: var(--text-muted); }
.text-center { text-align: center; }
.text-danger { color: var(--danger) !important; }
.text-main { color: var(--text-main); }
.page-subtitle { color: var(--text-muted); font-size: 1rem; font-weight: 400; }

.date-filter-group { display: flex; gap: 0.5rem; align-items: center; flex-wrap: wrap; }
.filter-label { font-size: 0.8rem; color: var(--text-muted); }
.btn-clear-filter { border: none; color: var(--danger); }

.badge-staff { background: #e0e7ff; color: #3730a3; }

.brand-logo-container { display: flex; align-items: center; justify-content: center; width: 100%; margin-bottom: 1.5rem; }
.brand-logo-img { max-height: 48px; max-width: 100%; height: auto; border-radius: 8px; object-fit: contain; }
.nav-divider { margin-top: 1rem; border-top: 1px solid var(--border); padding-top: 1rem; }
.nav-footer-divider { margin-top: auto; border-top: 1px solid var(--border); padding-top: 1rem; }
.nav-user-info { padding: 0.5rem 1rem; font-size: 0.85rem; color: var(--text-muted); }
.nav-logout-btn { color: var(--danger); font-size: 0.85rem; padding: 0.5rem 1rem; display: block; text-decoration: none; }
.nav-admin-item { padding-top: 0.5rem; }
.nav-admin-link { font-size: 0.85rem; }
.empty-table-msg { text-align: center; color: var(--text-muted); padding: 2rem; }
.table-responsive-wrapper { overflow-x: auto; }

.mobile-menu-toggle { display: none; } /* Hidden on desktop */
.sidebar-overlay { 
    display: none; 
    position: fixed; 
    top: 0; left: 0; right: 0; bottom: 0; 
    background: rgba(0,0,0,0.5); 
    z-index: 999; 
    opacity: 0;
    transition: opacity 0.3s ease;
}
.sidebar-overlay.show {
    opacity: 1;
}
