/* ==============================================================================
   SOS Service - Modern Dashboard Styles
   ============================================================================== */

:root {
    --primary: #6366f1;
    --primary-hover: #4f46e5;
    --success: #22c55e;
    --warning: #f59e0b;
    --danger: #ef4444;
    --info: #3b82f6;

    --bg-dark: #0f172a;
    --bg-card: rgba(30, 41, 59, 0.7);
    --bg-light: #334155;
    --border: rgba(71, 85, 105, 0.4);

    --text: #f1f5f9;
    --text-muted: #94a3b8;
    --text-dim: #64748b;

    --radius: 8px;
    --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.3);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg-dark);
    color: var(--text);
    line-height: 1.6;
}

/* Navbar */
.navbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 1.5rem;
    background: rgba(30, 41, 59, 0.8);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border);
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 100;
    height: 60px;
}

.nav-brand {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.nav-brand .logo {
    font-size: 1.5rem;
}

.nav-brand .brand-text {
    font-weight: 600;
    font-size: 1.1rem;
}

.nav-brand .version {
    background: var(--primary);
    color: white;
    padding: 0.1rem 0.4rem;
    border-radius: 4px;
    font-size: 0.7rem;
}

.nav-actions {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.session-timer {
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.85rem;
    color: var(--text-muted);
}

.session-timer.warning {
    color: var(--warning);
}

.user-info {
    color: var(--text-muted);
    font-size: 0.9rem;
}

/* Dashboard Layout */
.dashboard-layout {
    display: flex;
    padding-top: 60px;
    min-height: 100vh;
}

/* Sidebar */
.sidebar {
    width: 220px;
    background: rgba(30, 41, 59, 0.5);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    border-right: 1px solid var(--border);
    position: fixed;
    top: 60px;
    left: 0;
    bottom: 0;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
}

.nav-menu {
    list-style: none;
    padding: 1rem 0;
    flex: 1;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1.25rem;
    color: var(--text-muted);
    cursor: pointer;
    transition: all 0.2s;
    border-left: 3px solid transparent;
}

.nav-item:hover {
    background: rgba(99, 102, 241, 0.1);
    color: var(--text);
}

.nav-item.active {
    background: rgba(99, 102, 241, 0.15);
    color: var(--primary);
    border-left-color: var(--primary);
}

.nav-icon {
    font-size: 1.1rem;
}

.sidebar-footer {
    padding: 1rem;
    border-top: 1px solid var(--border);
}

.api-docs-link {
    display: block;
    text-align: center;
    color: var(--text-muted);
    text-decoration: none;
    font-size: 0.9rem;
}

.api-docs-link:hover {
    color: var(--primary);
}

/* Main Content */
.main-content {
    flex: 1;
    margin-left: 220px;
    padding: 1.5rem;
}

.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
}

.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
}

.page-header h1 {
    font-size: 1.5rem;
    font-weight: 600;
}

.header-actions {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

.search-input {
    width: 250px;
    padding: 0.4rem 0.8rem;
    background: var(--bg-dark);
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text);
    font-size: 0.85rem;
}

.search-input:focus {
    outline: none;
    border-color: var(--primary);
}

.search-input::placeholder {
    color: var(--text-dim);
}

/* Stats Grid */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.stat-card {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1.25rem;
    background: var(--bg-card);
    backdrop-filter: blur(10px);
    border-radius: var(--radius);
    border: 1px solid var(--border);
    border-left: 4px solid;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.stat-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.3);
}

.stat-card.stat-primary {
    border-color: var(--primary);
}

.stat-card.stat-success {
    border-color: var(--success);
}

.stat-card.stat-warning {
    border-color: var(--warning);
}

.stat-card.stat-info {
    border-color: var(--info);
}

.stat-icon {
    font-size: 2rem;
}

.stat-value {
    display: block;
    font-size: 1.75rem;
    font-weight: 700;
}

.stat-label {
    color: var(--text-muted);
    font-size: 0.85rem;
}

/* Grid */
.grid-2 {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1rem;
}

@media (max-width: 1024px) {
    .grid-2 {
        grid-template-columns: 1fr;
    }
}

/* Cards */
.card {
    background: var(--bg-card);
    backdrop-filter: blur(10px);
    border-radius: var(--radius);
    border: 1px solid var(--border);
    overflow: hidden;
    box-shadow: var(--shadow);
}

.card-header {
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--border);
}

.card-header h2 {
    font-size: 1rem;
    font-weight: 600;
}

.card-body {
    padding: 1rem 1.25rem;
}

/* Tables */
.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}

.data-table th,
.data-table td {
    padding: 0.75rem 1rem;
    text-align: left;
    border-bottom: 1px solid var(--border);
}

.data-table th {
    background: rgba(0, 0, 0, 0.2);
    color: var(--text-muted);
    font-weight: 500;
    font-size: 0.8rem;
    text-transform: uppercase;
}

.data-table tbody tr:hover {
    background: rgba(99, 102, 241, 0.05);
}

.data-table .empty,
.data-table .loading {
    text-align: center;
    color: var(--text-dim);
    padding: 2rem;
}

.data-table code {
    background: rgba(0, 0, 0, 0.3);
    padding: 0.2rem 0.4rem;
    border-radius: 4px;
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.8rem;
}

.data-table .actions {
    text-align: right;
    white-space: nowrap;
}

.data-table .actions button {
    margin-left: 0.25rem;
}

/* Badges */
.badge {
    display: inline-block;
    padding: 0.2rem 0.5rem;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 500;
}

.badge-primary {
    background: var(--primary);
    color: white;
}

.badge-success {
    background: var(--success);
    color: white;
}

.badge-warning {
    background: var(--warning);
    color: black;
}

.badge-danger {
    background: var(--danger);
    color: white;
}

.badge-info {
    background: var(--info);
    color: white;
}

.badge-secondary {
    background: var(--bg-light);
    color: var(--text-muted);
}

/* Tags */
.district-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
}

.tag {
    display: inline-flex;
    align-items: center;
    padding: 0.15rem 0.5rem;
    background: rgba(99, 102, 241, 0.1);
    color: var(--primary);
    border: 1px solid rgba(99, 102, 241, 0.2);
    border-radius: 4px;
    font-size: 0.8rem;
    font-weight: 500;
}

.tag-sm {
    padding: 0.1rem 0.4rem;
    font-size: 0.75rem;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    border: none;
    border-radius: 6px;
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    text-decoration: none;
    white-space: nowrap;
    flex-shrink: 0;
}

.btn-primary {
    background: var(--primary);
    color: white;
}

.btn-primary:hover {
    background: var(--primary-hover);
}

.btn-secondary {
    background: var(--bg-light);
    color: var(--text);
}

.btn-secondary:hover {
    background: var(--border);
}

.btn-danger {
    background: var(--danger);
    color: white;
}

.btn-danger:hover {
    background: #dc2626;
}

.btn-outline {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text);
}

.btn-outline:hover {
    background: var(--bg-light);
}

.btn-sm {
    padding: 0.25rem 0.5rem;
    font-size: 0.8rem;
}

.btn-block {
    width: 100%;
}

/* Forms */
.form-group {
    margin-bottom: 1rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    color: var(--text-muted);
    font-size: 0.9rem;
}

.form-group small {
    color: var(--text-dim);
}

.form-input {
    width: 100%;
    height: 40px;
    padding: 0.6rem 0.8rem;
    background: var(--bg-dark);
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text);
    font-size: 0.9rem;
    display: block;
}

select.form-input {
    appearance: none;
    -webkit-appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2003/svg' fill='none' viewBox='0 0 24 24' stroke='%2394a3b8'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M19 9l-7 7-7-7'%3E%3C/path%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.75rem center;
    background-size: 1rem;
    padding-right: 2.5rem;
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
}

.checkbox-label input {
    width: 1rem;
    height: 1rem;
}

/* Alerts */
.alert {
    padding: 0.75rem 1rem;
    border-radius: var(--radius);
    margin-bottom: 1rem;
    font-size: 0.9rem;
}

.alert-info {
    background: rgba(59, 130, 246, 0.15);
    border-left: 4px solid var(--info);
}

.alert-success {
    background: rgba(34, 197, 94, 0.15);
    border-left: 4px solid var(--success);
}

.alert-warning {
    background: rgba(245, 158, 11, 0.15);
    border-left: 4px solid var(--warning);
}

.alert-danger {
    background: rgba(239, 68, 68, 0.15);
    border-left: 4px solid var(--danger);
}

/* Modals */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.modal-content {
    background: var(--bg-card);
    border-radius: var(--radius);
    width: 90%;
    max-width: 450px;
    box-shadow: var(--shadow);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--border);
}

.modal-header h2 {
    font-size: 1.1rem;
}

.modal-close {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 1.5rem;
    cursor: pointer;
}

.modal-body {
    padding: 1.25rem;
}

/* Key Display */
.key-display {
    display: flex;
    gap: 0.5rem;
    margin: 1rem 0;
}

.key-display code {
    flex: 1;
    padding: 0.75rem;
    background: var(--bg-dark);
    border-radius: 6px;
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.85rem;
    word-break: break-all;
}

/* Info List */
.info-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.info-row {
    display: flex;
    justify-content: space-between;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid var(--border);
}

.info-row:last-child {
    border: none;
}

/* API Docs Page */
.api-docs {
    background: var(--bg-dark);
}

.api-docs .container {
    max-width: 900px;
    margin: 0 auto;
    padding: 2rem;
}

.hero {
    text-align: center;
    padding: 3rem 0;
}

.hero h1 {
    font-size: 2.5rem;
    margin-bottom: 0.5rem;
}

.hero-subtitle {
    color: var(--text-muted);
    font-size: 1.2rem;
    margin-bottom: 1rem;
}

.hero-badges {
    display: flex;
    gap: 0.5rem;
    justify-content: center;
    flex-wrap: wrap;
}

.api-section {
    margin-bottom: 2rem;
}

.section-title {
    font-size: 1.25rem;
    margin-bottom: 1rem;
}

.endpoint-card {
    background: var(--bg-card);
    border-radius: var(--radius);
    margin-bottom: 0.75rem;
}

.endpoint-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
}

.method {
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 600;
    min-width: 50px;
    text-align: center;
}

.method-get {
    background: var(--success);
    color: white;
}

.method-post {
    background: var(--info);
    color: white;
}

.method-put {
    background: var(--warning);
    color: black;
}

.method-delete {
    background: var(--danger);
    color: white;
}

.method-ws {
    background: var(--primary);
    color: white;
}

.endpoint-path {
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.9rem;
}

.endpoint-desc {
    color: var(--text-muted);
    font-size: 0.85rem;
    margin-left: auto;
}

.endpoint-body {
    padding: 0.75rem 1rem;
    border-top: 1px solid var(--border);
    background: rgba(0, 0, 0, 0.2);
}

.endpoint-body pre {
    background: transparent;
    margin: 0;
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.85rem;
    white-space: pre-wrap;
}

.label {
    display: block;
    font-size: 0.75rem;
    color: var(--text-dim);
    margin-bottom: 0.5rem;
}

.code-block {
    background: var(--bg-dark);
    border-radius: 6px;
    margin: 1rem 0;
    overflow: hidden;
}

.code-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.5rem 1rem;
    background: rgba(0, 0, 0, 0.3);
}

.code-lang {
    font-size: 0.8rem;
    color: var(--text-muted);
}

.copy-btn {
    background: var(--bg-light);
    border: none;
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    color: var(--text);
    cursor: pointer;
    font-size: 0.75rem;
}

.code-block pre {
    padding: 1rem;
    margin: 0;
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.85rem;
    overflow-x: auto;
}

.hint {
    color: var(--text-dim);
    font-size: 0.85rem;
}

.hint code {
    background: var(--bg-light);
    padding: 0.1rem 0.3rem;
    border-radius: 3px;
}

.params-table {
    width: 100%;
    font-size: 0.85rem;
}

.params-table td {
    padding: 0.5rem;
    border-bottom: 1px solid var(--border);
}

/* Footer */
.footer {
    text-align: center;
    padding: 2rem;
    color: var(--text-dim);
    font-size: 0.85rem;
}

/* Login Page */
.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
}

.login-card {
    background: var(--bg-card);
    padding: 2rem;
    border-radius: var(--radius);
    width: 100%;
    max-width: 400px;
    text-align: center;
}

.login-card .logo {
    font-size: 3rem;
    margin-bottom: 1rem;
}

.login-card h1 {
    margin-bottom: 1.5rem;
}

.login-card .form-group {
    text-align: left;
}

/* ==============================================================================
   Toast Notifications
   ============================================================================== */
.toast-container {
    position: fixed;
    top: 80px;
    right: 20px;
    z-index: 2000;
    display: flex;
    flex-direction: column;
    gap: 10px;
    max-width: 400px;
}

.toast {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 18px;
    background: var(--bg-card);
    border-radius: var(--radius);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
    border-left: 4px solid;
    animation: toastSlideIn 0.3s ease-out;
    min-width: 280px;
}

.toast.toast-success {
    border-color: var(--success);
}

.toast.toast-error {
    border-color: var(--danger);
}

.toast.toast-warning {
    border-color: var(--warning);
}

.toast.toast-info {
    border-color: var(--info);
}

.toast-icon {
    font-size: 1.25rem;
    flex-shrink: 0;
}

.toast-message {
    flex: 1;
    font-size: 0.9rem;
    line-height: 1.4;
}

.toast-close {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 1.25rem;
    padding: 0;
    margin-left: 8px;
    opacity: 0.7;
    transition: opacity 0.2s;
}

.toast-close:hover {
    opacity: 1;
}

.toast.toast-exit {
    animation: toastSlideOut 0.3s ease-in forwards;
}

@keyframes toastSlideIn {
    from {
        opacity: 0;
        transform: translateX(100px);
    }

    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes toastSlideOut {
    from {
        opacity: 1;
        transform: translateX(0);
    }

    to {
        opacity: 0;
        transform: translateX(100px);
    }
}

/* ==============================================================================
   Modal Enhancements
   ============================================================================== */
.modal-sm {
    max-width: 360px;
}

.modal-actions {
    display: flex;
    gap: 10px;
    margin-top: 20px;
    justify-content: flex-end;
}

.modal-body p {
    color: var(--text-muted);
    margin-bottom: 15px;
}

/* Disabled button state */
.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}