/* CAD Command Desktop Mobile PWA - Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

:root {
    --bg-dark: #0A0F1A;
    --bg-card: #1A2332;
    --bg-elevated: #242f42;
    --accent-cyan: #22D3EE;
    --priority-high: #EF4444;
    --priority-medium: #F59E0B;
    --priority-low: #22C55E;
    --text-primary: #F9FAFB;
    --text-secondary: #9CA3AF;
    --border: #30363d;
    --status-available: #34D399;
    --status-assigned: #3B82F6;
    --status-onscene: #8B5CF6;
    --status-conveying: #F59E0B;
    --status-oos: #EF4444;
    --safe-area-top: env(safe-area-inset-top, 0px);
    --safe-area-bottom: env(safe-area-inset-bottom, 0px);
}

html, body {
    height: 100%;
    overflow: hidden;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg-dark);
    color: var(--text-primary);
}

#app {
    height: 100%;
}

/* Screens */
.screen {
    display: none;
    height: 100%;
    flex-direction: column;
    padding-top: var(--safe-area-top);
}

.screen.active {
    display: flex;
}

/* ==================== LOGIN SCREEN ==================== */
#loginScreen {
    justify-content: center;
    align-items: center;
    padding: 20px;
}

.login-container {
    width: 100%;
    max-width: 400px;
}

.login-logo {
    text-align: center;
    margin-bottom: 32px;
}

.logo-icon {
    font-size: 48px;
    display: block;
    margin-bottom: 12px;
}

.login-logo h1 {
    font-size: 24px;
    font-weight: 700;
    margin-bottom: 8px;
}

.login-form {
    background: var(--bg-card);
    border-radius: 16px;
    padding: 24px;
}

.login-tabs {
    display: flex;
    margin-bottom: 20px;
    border-radius: 8px;
    background: var(--bg-dark);
    padding: 4px;
}

.login-tab {
    flex: 1;
    padding: 10px;
    border: none;
    background: transparent;
    color: var(--text-secondary);
    font-size: 13px;
    font-weight: 500;
    border-radius: 6px;
    cursor: pointer;
}

.login-tab.active {
    background: var(--bg-elevated);
    color: var(--text-primary);
}

.auth-section {
    display: none;
}

.auth-section.active {
    display: block;
}

.error-message {
    display: none;
    background: rgba(239, 68, 68, 0.15);
    border: 1px solid var(--priority-high);
    color: var(--priority-high);
    padding: 12px;
    border-radius: 8px;
    font-size: 13px;
    margin-bottom: 16px;
}

.btn-spinner {
    display: inline-block;
    width: 16px;
    height: 16px;
    border: 2px solid transparent;
    border-top-color: currentColor;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin-left: 8px;
    vertical-align: middle;
}

.login-footer {
    text-align: center;
    margin-top: 24px;
    color: var(--text-secondary);
    font-size: 12px;
}

.config-hint {
    font-size: 10px;
    color: var(--accent-cyan);
    font-weight: normal;
}

/* ==================== SIDE MENU ==================== */
.side-menu {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 1000;
    display: none;
}

.side-menu.active {
    display: block;
}

.side-menu-backdrop {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.6);
}

.side-menu-content {
    position: absolute;
    top: 0;
    left: 0;
    width: 280px;
    height: 100%;
    background: var(--bg-card);
    display: flex;
    flex-direction: column;
    padding-top: var(--safe-area-top);
}

.side-menu-header {
    padding: 24px 20px;
    border-bottom: 1px solid var(--border);
}

.user-info {
    display: flex;
    align-items: center;
    gap: 12px;
}

.user-avatar {
    width: 48px;
    height: 48px;
    background: var(--accent-cyan);
    color: var(--bg-dark);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    font-weight: 600;
}

.user-name {
    font-size: 16px;
    font-weight: 600;
}

.user-role {
    font-size: 12px;
    color: var(--text-secondary);
}

.side-menu-nav {
    flex: 1;
    padding: 12px;
}

.menu-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 16px;
    color: var(--text-primary);
    text-decoration: none;
    border-radius: 8px;
    font-size: 14px;
}

.menu-item:hover {
    background: var(--bg-elevated);
}

.menu-item.danger {
    color: var(--priority-high);
}

.menu-divider {
    height: 1px;
    background: var(--border);
    margin: 8px 0;
}

.side-menu-footer {
    padding: 16px 20px;
    border-top: 1px solid var(--border);
    font-size: 11px;
    color: var(--text-secondary);
}

/* Header */
.header {
    background: var(--bg-card);
    padding: 12px 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 12px;
}

.menu-btn {
    background: none;
    border: none;
    color: var(--text-primary);
    font-size: 20px;
    padding: 4px 8px;
    cursor: pointer;
}

.header-title {
    display: flex;
    align-items: center;
    gap: 8px;
}

.title-icon {
    font-size: 20px;
}

.title-text {
    font-size: 16px;
    font-weight: 600;
}

.mode-badge {
    background: var(--accent-cyan);
    color: var(--bg-dark);
    font-size: 9px;
    font-weight: 600;
    padding: 2px 6px;
    border-radius: 4px;
    text-transform: uppercase;
}

.connection-status {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    color: var(--text-secondary);
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--text-secondary);
}

.status-dot.online {
    background: var(--status-available);
    box-shadow: 0 0 6px var(--status-available);
}

/* Tabs */
.tabs {
    display: flex;
    background: var(--bg-card);
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}

.tab {
    flex: 1;
    padding: 12px;
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    color: var(--text-secondary);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.tab.active {
    color: var(--accent-cyan);
    border-bottom-color: var(--accent-cyan);
}

/* Split Container */
.split-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* List Panel */
.list-panel {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    min-height: 150px;
}

.list-header {
    padding: 12px 16px;
    background: var(--bg-elevated);
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-shrink: 0;
}

.list-title {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.list-count {
    background: var(--accent-cyan);
    color: var(--bg-dark);
    font-size: 11px;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: 10px;
}

.list-filters {
    padding: 8px 16px;
    display: flex;
    gap: 8px;
    flex-shrink: 0;
    overflow-x: auto;
}

.filter-chip {
    background: var(--bg-card);
    border: 1px solid var(--border);
    color: var(--text-secondary);
    padding: 6px 12px;
    border-radius: 16px;
    font-size: 12px;
    cursor: pointer;
    white-space: nowrap;
    transition: all 0.2s;
}

.filter-chip.active {
    background: var(--accent-cyan);
    border-color: var(--accent-cyan);
    color: var(--bg-dark);
}

.list-content {
    flex: 1;
    overflow-y: auto;
    padding: 8px;
}

/* Incident List Item */
.incident-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 12px;
    background: var(--bg-card);
    border-radius: 10px;
    margin-bottom: 8px;
    cursor: pointer;
    transition: all 0.2s;
    border-left: 4px solid transparent;
}

.incident-item:hover,
.incident-item.selected {
    background: var(--bg-elevated);
}

.incident-item.selected {
    border-left-color: var(--accent-cyan);
}

.incident-item.high {
    border-left-color: var(--priority-high);
}

.incident-item.medium {
    border-left-color: var(--priority-medium);
}

.incident-item.low {
    border-left-color: var(--priority-low);
}

.incident-priority {
    width: 10px;
    height: 10px;
    border-radius: 2px;
    flex-shrink: 0;
}

.incident-priority.high { background: var(--priority-high); }
.incident-priority.medium { background: var(--priority-medium); }
.incident-priority.low { background: var(--priority-low); }

.incident-info {
    flex: 1;
    min-width: 0;
}

.incident-location {
    font-size: 14px;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-bottom: 4px;
}

.incident-meta {
    font-size: 12px;
    color: var(--text-secondary);
    display: flex;
    gap: 8px;
}

.incident-time {
    font-size: 11px;
    color: var(--text-secondary);
    white-space: nowrap;
}

/* Resize Handle */
.resize-handle {
    height: 24px;
    background: var(--bg-elevated);
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: ns-resize;
    flex-shrink: 0;
}

.resize-indicator {
    width: 40px;
    height: 4px;
    background: var(--border);
    border-radius: 2px;
}

/* Detail Panel */
.detail-panel {
    flex: 1;
    background: var(--bg-card);
    overflow-y: auto;
    min-height: 200px;
}

.detail-empty {
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: var(--text-secondary);
    gap: 12px;
}

.empty-icon {
    font-size: 48px;
    opacity: 0.5;
}

.empty-text {
    font-size: 14px;
}

.detail-content {
    padding: 0;
}

.detail-header {
    padding: 16px;
    border-bottom: 1px solid var(--border);
}

.detail-id {
    font-size: 11px;
    color: var(--text-secondary);
    font-family: monospace;
    margin-bottom: 4px;
}

.detail-location {
    font-size: 18px;
    font-weight: 600;
    margin-bottom: 10px;
}

.detail-badges {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.badge {
    padding: 4px 10px;
    border-radius: 6px;
    font-size: 11px;
    font-weight: 600;
}

.badge.priority-high { background: rgba(239, 68, 68, 0.2); color: var(--priority-high); }
.badge.priority-medium { background: rgba(245, 158, 11, 0.2); color: var(--priority-medium); }
.badge.priority-low { background: rgba(34, 197, 94, 0.2); color: var(--priority-low); }
.badge.status { background: rgba(34, 211, 238, 0.2); color: var(--accent-cyan); }

.detail-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    padding: 16px;
}

.grid-item {
    background: var(--bg-elevated);
    padding: 12px;
    border-radius: 8px;
}

.grid-label {
    font-size: 10px;
    color: var(--text-secondary);
    text-transform: uppercase;
    margin-bottom: 4px;
}

.grid-value {
    font-size: 13px;
    font-weight: 500;
}

.detail-section {
    padding: 16px;
    border-top: 1px solid var(--border);
}

.section-label {
    font-size: 11px;
    color: var(--text-secondary);
    text-transform: uppercase;
    margin-bottom: 8px;
}

.section-value {
    font-size: 14px;
    line-height: 1.5;
}

.detail-actions {
    padding: 16px;
    display: flex;
    gap: 10px;
    border-top: 1px solid var(--border);
}

.detail-btn {
    flex: 1;
    padding: 12px;
    border: none;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.detail-btn.primary {
    background: var(--accent-cyan);
    color: var(--bg-dark);
}

.detail-btn.secondary {
    background: var(--bg-elevated);
    color: var(--text-primary);
    border: 1px solid var(--border);
}

/* Bottom Bar */
.bottom-bar {
    padding: 12px 16px;
    padding-bottom: calc(12px + var(--safe-area-bottom));
    background: var(--bg-card);
    border-top: 1px solid var(--border);
    display: flex;
    gap: 10px;
    flex-shrink: 0;
}

.bottom-btn {
    flex: 1;
    padding: 14px;
    border: none;
    border-radius: 10px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.bottom-btn:active {
    transform: scale(0.98);
}

.bottom-btn.primary {
    background: var(--accent-cyan);
    color: var(--bg-dark);
}

.bottom-btn.secondary {
    background: var(--bg-elevated);
    color: var(--text-primary);
}

/* Modal */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 1000;
    display: none;
}

.modal.active {
    display: block;
}

.modal-backdrop {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
}

.modal-content {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--bg-card);
    border-radius: 20px 20px 0 0;
    max-height: 90vh;
    overflow-y: auto;
    padding-bottom: var(--safe-area-bottom);
}

.modal-header {
    padding: 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--border);
}

.modal-header h2 {
    font-size: 18px;
    font-weight: 600;
}

.modal-close {
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 28px;
    cursor: pointer;
    padding: 0;
    line-height: 1;
}

.modal-body {
    padding: 20px;
}

.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    font-size: 12px;
    color: var(--text-secondary);
    text-transform: uppercase;
    margin-bottom: 8px;
}

.form-group input,
.form-group textarea {
    width: 100%;
    background: var(--bg-dark);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 12px;
    color: var(--text-primary);
    font-size: 14px;
}

.form-group input:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--accent-cyan);
}

.form-group textarea {
    min-height: 100px;
    resize: vertical;
}

.priority-select {
    display: flex;
    gap: 10px;
}

.priority-btn {
    flex: 1;
    padding: 12px;
    border: 2px solid var(--border);
    border-radius: 8px;
    background: var(--bg-dark);
    color: var(--text-secondary);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.priority-btn.high.active {
    border-color: var(--priority-high);
    background: rgba(239, 68, 68, 0.2);
    color: var(--priority-high);
}

.priority-btn.medium.active {
    border-color: var(--priority-medium);
    background: rgba(245, 158, 11, 0.2);
    color: var(--priority-medium);
}

.priority-btn.low.active {
    border-color: var(--priority-low);
    background: rgba(34, 197, 94, 0.2);
    color: var(--priority-low);
}

.modal-footer {
    padding: 20px;
    display: flex;
    gap: 12px;
    border-top: 1px solid var(--border);
}

.btn {
    flex: 1;
    padding: 14px;
    border: none;
    border-radius: 10px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
}

.btn.primary {
    background: var(--accent-cyan);
    color: var(--bg-dark);
}

.btn.secondary {
    background: var(--bg-elevated);
    color: var(--text-primary);
}

/* History Timeline */
.history-list {
    padding: 0;
}

.history-item {
    display: flex;
    gap: 12px;
    padding: 12px 0;
    border-bottom: 1px solid var(--border);
}

.history-item:last-child {
    border-bottom: none;
}

.history-time {
    font-size: 11px;
    color: var(--text-secondary);
    white-space: nowrap;
    min-width: 50px;
}

.history-content {
    flex: 1;
}

.history-action {
    font-size: 13px;
    font-weight: 500;
    margin-bottom: 2px;
}

.history-user {
    font-size: 11px;
    color: var(--text-secondary);
}

/* Loading State */
.loading {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 40px;
    color: var(--text-secondary);
}

.spinner {
    width: 24px;
    height: 24px;
    border: 2px solid var(--border);
    border-top-color: var(--accent-cyan);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Scrollbar */
::-webkit-scrollbar {
    width: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 3px;
}

/* ==================== TAB CONTENT ==================== */
.tab-content {
    display: none;
    flex: 1;
    overflow: hidden;
}

.tab-content.active {
    display: flex;
    flex-direction: column;
}

.list-panel.full {
    flex: 1;
    min-height: auto;
}

/* ==================== RESOURCES ==================== */
.resource-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 12px;
    background: var(--bg-card);
    border-radius: 10px;
    margin-bottom: 8px;
    cursor: pointer;
    border-left: 4px solid var(--border);
}

.resource-item:hover {
    background: var(--bg-elevated);
}

.resource-item.status-available { border-left-color: var(--status-available); }
.resource-item.status-assigned { border-left-color: var(--status-assigned); }
.resource-item.status-onscene { border-left-color: var(--status-onscene); }
.resource-item.status-conveying { border-left-color: var(--status-conveying); }
.resource-item.status-oos { border-left-color: var(--status-oos); }

.resource-callsign {
    font-size: 15px;
    font-weight: 600;
    min-width: 80px;
}

.resource-info {
    flex: 1;
}

.resource-category {
    font-size: 12px;
    color: var(--text-secondary);
}

.resource-status {
    font-size: 12px;
    color: var(--text-primary);
    margin-top: 2px;
}

.resource-mdt {
    font-size: 16px;
    opacity: 0.3;
}

.resource-mdt.connected {
    opacity: 1;
}

/* Resource Select List (for assigning) */
.resource-select-list {
    max-height: 300px;
    overflow-y: auto;
}

.resource-select-item {
    display: flex;
    justify-content: space-between;
    padding: 14px;
    background: var(--bg-elevated);
    border-radius: 8px;
    margin-bottom: 8px;
    cursor: pointer;
}

.resource-select-item:hover {
    background: var(--accent-cyan);
    color: var(--bg-dark);
}

.resource-select-item:hover .resource-category {
    color: var(--bg-dark);
}

/* Personnel List */
.personnel-list, .notes-list, .remarks-list {
    margin-top: 8px;
}

.personnel-item, .note-item, .remark-item {
    padding: 10px 12px;
    background: var(--bg-elevated);
    border-radius: 6px;
    margin-bottom: 6px;
}

.personnel-name, .note-text, .remark-text {
    font-size: 13px;
    font-weight: 500;
}

.personnel-info, .note-meta, .remark-meta {
    font-size: 11px;
    color: var(--text-secondary);
    margin-top: 4px;
}

/* Empty States */
.empty-state {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 40px 20px;
    color: var(--text-secondary);
    font-size: 14px;
}

.empty-state.small {
    padding: 16px;
    font-size: 12px;
}

/* Full Width Grid Item */
.grid-item.full {
    grid-column: 1 / -1;
}

/* Full Width Button */
.btn.full-width {
    width: 100%;
}

/* ==================== EVENT SELECT SCREEN ==================== */
.event-select-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.back-btn {
    background: none;
    border: none;
    color: var(--text-primary);
    font-size: 24px;
    padding: 4px 12px 4px 0;
    cursor: pointer;
}

.user-badge {
    background: var(--bg-elevated);
    color: var(--accent-cyan);
    padding: 6px 12px;
    border-radius: 16px;
    font-size: 12px;
    font-weight: 500;
}

.event-item {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 16px 14px;
    background: var(--bg-card);
    border-radius: 12px;
    margin-bottom: 10px;
    cursor: pointer;
    transition: all 0.2s;
}

.event-item:hover {
    background: var(--bg-elevated);
}

.event-item:active {
    transform: scale(0.98);
}

.event-icon {
    font-size: 28px;
}

.event-info {
    flex: 1;
}

.event-name {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 4px;
}

.event-meta {
    font-size: 12px;
    color: var(--text-secondary);
}

.event-arrow {
    font-size: 18px;
    color: var(--text-secondary);
}
