/* ============================================================
   DUTYBOARD - SHARED STYLES
   Used across all pages
   ============================================================ */

:root {
    --primary: #1a5f7a;
    --primary-light: #2c7a9e;
    --primary-dark: #0f4158;
    --accent: #d97706;
    --accent-light: #f59e0b;
    --bg-main: #f8fafc;
    --bg-elevated: #ffffff;
    --text-primary: #0f172a;
    --text-secondary: #475569;
    --text-muted: #94a3b8;
    --border: #e2e8f0;
    --success: #059669;
    --danger: #dc2626;
    --warning: #d97706;
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
}

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

body {
    font-family: 'Source Sans 3', sans-serif;
    background: var(--bg-main);
    color: var(--text-primary);
    line-height: 1.6;
}

h1, h2, h3, h4, h5, h6 {
    font-family: 'Montserrat', sans-serif;
    font-weight: 700;
    line-height: 1.2;
}

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

/* ========== SIDEBAR ========== */
.sidebar {
    width: 280px;
    background: var(--primary-dark);
    color: white;
    display: flex;
    flex-direction: column;
    box-shadow: var(--shadow-xl);
    position: fixed;
    height: 100vh;
    z-index: 100;
}

.sidebar-header {
    padding: 32px 24px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.logo {
    font-size: 28px;
    font-weight: 800;
    font-family: 'Montserrat', sans-serif;
    letter-spacing: -0.5px;
}

.logo-subtitle {
    font-size: 12px;
    color: rgba(255, 255, 255, 0.6);
    margin-top: 4px;
    font-weight: 500;
    letter-spacing: 0.5px;
    text-transform: uppercase;
}

.sidebar-nav {
    flex: 1;
    padding: 24px 0;
    overflow-y: auto;
}

.nav-section-title {
    padding: 8px 24px;
    font-size: 11px;
    font-weight: 600;
    color: rgba(255, 255, 255, 0.5);
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-top: 16px;
}

.nav-item {
    padding: 12px 24px;
    display: flex;
    align-items: center;
    gap: 12px;
    color: rgba(255, 255, 255, 0.8);
    cursor: pointer;
    transition: all 0.2s;
    border-left: 3px solid transparent;
    font-weight: 500;
    text-decoration: none;
}

.nav-item:hover {
    background: rgba(255, 255, 255, 0.05);
    color: white;
}

.nav-item.active {
    background: rgba(255, 255, 255, 0.1);
    color: white;
    border-left-color: var(--accent);
}

.nav-icon {
    font-size: 18px;
    width: 24px;
    text-align: center;
}

.sidebar-user {
    padding: 20px 24px;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.user-info {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 12px;
    cursor: pointer;
    transition: all 0.2s;
    padding: 8px;
    border-radius: 8px;
    text-decoration: none;
    color: white;
}

.user-info:hover {
    background: rgba(255, 255, 255, 0.05);
}

.user-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--accent);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 14px;
    overflow: hidden;
    flex-shrink: 0;
}

.user-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.user-details {
    flex: 1;
    min-width: 0;
}

.user-name {
    font-weight: 600;
    font-size: 14px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.user-role {
    font-size: 12px;
    color: rgba(255, 255, 255, 0.6);
    text-transform: capitalize;
}

/* ========== MAIN CONTENT ========== */
.main-content {
    flex: 1;
    margin-left: 280px;
    display: flex;
    flex-direction: column;
}

/* ========== TOPBAR ========== */
.topbar {
    background: white;
    padding: 24px 32px;
    box-shadow: var(--shadow-sm);
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: sticky;
    top: 0;
    z-index: 50;
}

.topbar-title {
    font-size: 28px;
    font-weight: 700;
}

.topbar-actions {
    display: flex;
    gap: 12px;
    align-items: center;
}

/* ========== CONTENT AREA ========== */
.content {
    padding: 32px;
    flex: 1;
}

/* ========== CARDS ========== */
.card {
    background: white;
    border-radius: 12px;
    padding: 24px;
    box-shadow: var(--shadow-md);
    margin-bottom: 24px;
}

.card-title {
    font-size: 18px;
    font-weight: 700;
    margin-bottom: 20px;
    color: var(--text-primary);
}

/* ========== STATS GRID ========== */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 24px;
    margin-bottom: 32px;
}

.stat-card {
    background: white;
    border-radius: 12px;
    padding: 24px;
    box-shadow: var(--shadow-md);
    border-top: 4px solid var(--primary);
    transition: all 0.2s;
}

.stat-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

.stat-label {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.stat-value {
    font-size: 36px;
    font-weight: 800;
    color: var(--primary);
    margin: 8px 0;
}

/* ========== BUTTONS ========== */
.btn {
    padding: 12px 24px;
    border-radius: 8px;
    font-weight: 600;
    font-size: 14px;
    cursor: pointer;
    border: none;
    transition: all 0.2s;
    font-family: 'Montserrat', sans-serif;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

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

.btn-primary:hover:not(:disabled) {
    background: var(--primary-dark);
    transform: translateY(-1px);
    box-shadow: var(--shadow-lg);
}

.btn-primary:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn-secondary {
    background: var(--bg-main);
    color: var(--text-primary);
    border: 1px solid var(--border);
}

.btn-secondary:hover {
    background: white;
}

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

.btn-danger:hover {
    background: #b91c1c;
}

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

.btn-success:hover {
    background: #047857;
}

/* ========== FORMS ========== */
.form-group {
    margin-bottom: 20px;
}

.form-label {
    display: block;
    font-weight: 600;
    margin-bottom: 8px;
    font-size: 14px;
    color: var(--text-primary);
}

.form-input, .form-select, .form-textarea {
    width: 100%;
    padding: 12px 16px;
    border: 2px solid var(--border);
    border-radius: 8px;
    font-size: 14px;
    transition: all 0.2s;
    font-family: 'Source Sans 3', sans-serif;
}

.form-input:focus, .form-select:focus, .form-textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(26, 95, 122, 0.1);
}

.form-textarea {
    resize: vertical;
    min-height: 100px;
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

/* ========== MESSAGES ========== */
.error-message {
    padding: 12px;
    margin-bottom: 20px;
    background: #fee2e2;
    border: 1px solid var(--danger);
    border-radius: 8px;
    color: var(--danger);
    font-size: 14px;
}

.success-message {
    padding: 12px;
    margin-bottom: 20px;
    background: #d1fae5;
    border: 1px solid var(--success);
    border-radius: 8px;
    color: var(--success);
    font-size: 14px;
}

/* ========== LOADING STATE ========== */
.loading {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 40px;
    color: var(--text-muted);
}

.spinner {
    width: 40px;
    height: 40px;
    border: 4px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* ========== EMPTY STATE ========== */
.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-muted);
}

.empty-state-icon {
    font-size: 48px;
    margin-bottom: 16px;
    opacity: 0.5;
}

/* ========== BADGES ========== */
.badge {
    display: inline-block;
    padding: 4px 12px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.badge.success {
    background: #d1fae5;
    color: #065f46;
}

.badge.warning {
    background: #fef3c7;
    color: #92400e;
}

.badge.danger {
    background: #fee2e2;
    color: #991b1b;
}

.badge.info {
    background: #dbeafe;
    color: #1e40af;
}

/* ========== TABLES ========== */
.table {
    width: 100%;
    border-collapse: collapse;
}

.table th {
    text-align: left;
    padding: 12px;
    border-bottom: 2px solid var(--border);
    font-weight: 600;
    font-size: 13px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.table td {
    padding: 12px;
    border-bottom: 1px solid var(--border);
}

.table tbody tr:hover {
    background: var(--bg-main);
}

/* ========== MODALS ========== */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.modal {
    background: white;
    border-radius: 16px;
    padding: 32px;
    max-width: 600px;
    width: 90%;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: var(--shadow-xl);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
}

.modal-title {
    font-size: 24px;
    font-weight: 700;
}

.close-button {
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: var(--text-muted);
    padding: 0;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: all 0.2s;
}

.close-button:hover {
    background: var(--bg-main);
}

/* ============================================================
   MOBILE RESPONSIVE STYLES
   Applied across all pages for consistent mobile experience
   ============================================================ */

/* Base mobile elements (hidden on desktop) */
.mobile-menu-toggle {
    display: none; /* Hidden on desktop */
}

.mobile-overlay {
    display: none;
}

/* Tablet and Mobile (≤ 768px) */
@media (max-width: 768px) {
    /* Show mobile menu button */
    .mobile-menu-toggle {
        display: block;
        position: fixed;
        top: 16px;
        left: 16px;
        z-index: 101;
        background: var(--primary);
        color: white;
        border: none;
        width: 44px;
        height: 44px;
        border-radius: 8px;
        font-size: 20px;
        cursor: pointer;
        box-shadow: var(--shadow-lg);
    }

    /* Hide sidebar by default on mobile */
    .sidebar {
        transform: translateX(-100%);
        transition: transform 0.3s ease;
    }

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

    /* Overlay for sidebar */
    .mobile-overlay {
        display: none;
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background: rgba(0, 0, 0, 0.5);
        z-index: 99;
    }

    .mobile-overlay.active {
        display: block;
    }

    /* Main content adjustments */
    .main-content {
        margin-left: 0;
        width: 100%;
    }

    .content {
        padding: 16px;
    }

    /* Topbar adjustments */
    .topbar {
        padding: 12px 16px 12px 70px; /* Extra left padding for menu button */
    }

    .topbar-title {
        font-size: 18px;
    }

    .topbar-actions {
        flex-wrap: wrap;
        gap: 8px;
    }

    /* Cards */
    .card {
        padding: 16px;
        margin-bottom: 16px;
    }

    .card-title {
        font-size: 18px;
    }

    /* Forms */
    .form-input,
    .form-select,
    .form-textarea {
        font-size: 16px; /* Prevents zoom on iOS */
    }

    /* Buttons */
    .btn {
        padding: 10px 16px;
        font-size: 14px;
    }

    .btn-sm {
        padding: 6px 12px;
        font-size: 13px;
    }

    /* Tables - Make scrollable */
    .table-container {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    table {
        min-width: 600px;
    }

    /* Modals */
    .modal-content {
        width: 95%;
        max-width: 95%;
        margin: 20px auto;
    }

    /* Stat Cards */
    .stat-card {
        padding: 16px;
    }

    .stat-icon {
        font-size: 32px;
        width: 60px;
        height: 60px;
    }

    .stat-value {
        font-size: 28px;
    }

    .stat-label {
        font-size: 13px;
    }

    /* Dashboard Grid */
    .dashboard-grid {
        grid-template-columns: 1fr;
        gap: 16px;
    }

    /* Quick Actions */
    .quick-actions-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 10px;
    }

    /* Incident Cards */
    .incident-card {
        padding: 12px;
    }

    .incident-title {
        font-size: 15px;
    }

    /* Member Cards */
    .member-card {
        padding: 12px;
    }

    /* Filters */
    .filters {
        flex-direction: column;
        gap: 12px;
    }

    .filter-tabs {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    /* Chat Messages */
    .chat-messages {
        padding: 12px;
    }

    .message-bubble {
        max-width: 85%;
    }

    /* Dispatch Grid */
    .dispatch-grid {
        grid-template-columns: 1fr;
        height: auto;
    }

    .dispatch-main {
        order: 1; /* Incidents first on mobile */
    }

    .dispatch-sidebar {
        order: 2; /* Chat second (below incidents) on mobile */
        margin-top: 20px;
    }

    .dispatch-chat {
        height: 500px; /* Taller on mobile for better usability */
    }
}

/* Small Mobile (≤ 480px) */
@media (max-width: 480px) {
    /* Even more compact spacing */
    .content {
        padding: 12px;
    }

    .topbar {
        padding: 10px 12px 10px 60px;
    }

    .topbar-title {
        font-size: 16px;
    }

    /* Cards */
    .card {
        padding: 12px;
        margin-bottom: 12px;
    }

    .card-title {
        font-size: 16px;
    }

    /* Buttons - Full width for primary actions */
    .btn-primary,
    .btn-danger {
        width: 100%;
    }

    /* Stat Cards - Vertical layout */
    .stat-card {
        flex-direction: column;
        text-align: center;
        padding: 12px;
    }

    .stat-icon {
        width: 50px;
        height: 50px;
        font-size: 28px;
    }

    .stat-value {
        font-size: 24px;
    }

    /* Quick Actions - Single column with horizontal layout */
    .quick-actions-grid {
        grid-template-columns: 1fr;
    }

    .quick-action-btn {
        flex-direction: row;
        justify-content: flex-start;
        padding: 12px 16px;
    }

    .quick-action-icon {
        font-size: 28px;
    }

    /* Forms - Stack form groups */
    .form-row {
        grid-template-columns: 1fr !important;
    }

    /* Member cards - Hide some details */
    .member-meta {
        font-size: 11px;
    }

    /* Tables - Hide less important columns */
    .hide-mobile {
        display: none;
    }

    /* Navigation items - Larger touch targets */
    .nav-item {
        padding: 14px 20px;
    }

    /* Welcome banner */
    .welcome-banner {
        padding: 16px;
    }

    .welcome-title {
        font-size: 20px;
    }

    .welcome-subtitle {
        font-size: 13px;
    }
}

/* Landscape phones (small height) */
@media (max-height: 600px) and (orientation: landscape) {
    .sidebar {
        height: 100vh;
        overflow-y: auto;
    }

    .topbar {
        padding: 8px 16px 8px 60px;
    }
}

/* Utility classes for responsive design */
.hide-desktop {
    display: none;
}

@media (max-width: 768px) {
    .hide-mobile {
        display: none;
    }

    .hide-desktop {
        display: block;
    }

    .show-mobile {
        display: block !important;
    }
}

/* Touch-friendly adjustments */
@media (hover: none) and (pointer: coarse) {
    /* Increase tap targets for touch devices */
    .btn,
    .nav-item,
    .tab-btn,
    button {
        min-height: 44px;
        min-width: 44px;
    }

    /* Remove hover effects on touch devices */
    .stat-card:hover,
    .incident-card:hover,
    .member-card:hover {
        transform: none;
    }
}
