/* ============================================================================
   DISPATCH - Dark Mode CSS
   ============================================================================ */

:root {
    --bg: #0F172A;
    --surface: #1E293B;
    --surface2: #334155;
    --border: #2D3748;
    --text: #F1F5F9;
    --text2: #94A3B8;
    --text3: #64748B;
    --blue: #3B82F6;
    --green: #10B981;
    --amber: #F59E0B;
    --red: #EF4444;
    --grey: #6B7280;
    --purple: #8B5CF6;
}

/* ============================================================================
   GLOBAL STYLES
   ============================================================================ */

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

html, body {
    width: 100%;
    height: 100%;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background-color: var(--bg);
    color: var(--text);
    line-height: 1.5;
}

body {
    overflow-x: hidden;
}

a {
    color: var(--blue);
    text-decoration: none;
    transition: opacity 0.2s;
}

a:hover {
    opacity: 0.8;
}

button {
    cursor: pointer;
    border: none;
    font-family: inherit;
    transition: all 0.2s;
}

input, textarea, select {
    font-family: inherit;
}

/* ============================================================================
   TYPOGRAPHY
   ============================================================================ */

h1, h2, h3, h4, h5, h6 {
    font-weight: 600;
    line-height: 1.2;
    margin-bottom: 0.5em;
}

h1 { font-size: 2rem; }
h2 { font-size: 1.5rem; }
h3 { font-size: 1.25rem; }
h4 { font-size: 1.1rem; }

.dispatch-wordmark {
    font-size: 2.5rem;
    font-weight: 700;
    letter-spacing: -0.05em;
    background: linear-gradient(135deg, var(--blue) 0%, var(--purple) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.dispatch-logo {
    font-size: 1.5rem;
    font-weight: 700;
    letter-spacing: -0.05em;
    color: var(--blue);
}

.text-center {
    text-align: center;
}

.text-secondary {
    color: var(--text2);
    font-size: 0.9rem;
}

/* ============================================================================
   BUTTONS
   ============================================================================ */

.btn {
    padding: 0.75rem 1.5rem;
    border-radius: 0.5rem;
    font-size: 1rem;
    font-weight: 500;
    transition: all 0.2s;
    cursor: pointer;
    border: none;
    text-decoration: none;
    display: inline-block;
    text-align: center;
    min-height: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

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

.btn-primary:hover {
    background-color: #2563EB;
    box-shadow: 0 0 20px rgba(59, 130, 246, 0.3);
}

.btn-primary:active {
    background-color: #1D4ED8;
}

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

.btn-danger:hover {
    background-color: #DC2626;
}

.btn-ghost {
    background-color: transparent;
    color: var(--text2);
    border: 1px solid var(--border);
}

.btn-ghost:hover {
    background-color: var(--surface);
    color: var(--text);
    border-color: var(--surface2);
}

.btn-sm {
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
}

.btn-block {
    width: 100%;
    display: block;
}

.btn-quick-add {
    width: 100%;
    padding: 1rem;
    background-color: var(--surface2);
    color: var(--text2);
    border-radius: 0.5rem;
    margin-top: auto;
}

.btn-quick-add:hover {
    background-color: var(--blue);
    color: white;
}

/* ============================================================================
   FORMS
   ============================================================================ */

.form-group {
    margin-bottom: 1.5rem;
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
    margin-bottom: 1.5rem;
}

.form-row .form-group {
    margin-bottom: 0;
}

.flex-1 {
    flex: 1;
}

label {
    display: block;
    margin-bottom: 0.5rem;
    color: var(--text);
    font-weight: 500;
    font-size: 0.9rem;
}

.form-input,
.form-textarea {
    width: 100%;
    padding: 0.75rem;
    background-color: var(--surface);
    border: 1px solid var(--border);
    border-radius: 0.5rem;
    color: var(--text);
    font-size: 1rem;
    transition: all 0.2s;
    min-height: 44px;
}

.form-input:focus,
.form-textarea:focus {
    outline: none;
    border-color: var(--blue);
    background-color: var(--surface2);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.form-textarea {
    resize: vertical;
    min-height: 4rem;
}

/* Date input — force visibility on dark theme */
input[type="date"].form-input {
    color-scheme: dark;
    color: var(--text);
    background-color: var(--surface);
}

input[type="date"].form-input::-webkit-calendar-picker-indicator {
    filter: invert(0.8) brightness(1.4);
    cursor: pointer;
    opacity: 0.8;
    padding: 2px;
    border-radius: 3px;
}

input[type="date"].form-input::-webkit-calendar-picker-indicator:hover {
    opacity: 1;
    background-color: var(--surface2);
}

.char-count {
    font-size: 0.8rem;
    color: var(--text3);
    margin-left: 0.5rem;
}

/* ============================================================================
   AUTH PAGES
   ============================================================================ */

.auth-container {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 2rem;
    background-color: var(--bg);
}

.auth-card {
    width: 100%;
    max-width: 400px;
    background-color: var(--surface);
    border: 1px solid var(--border);
    border-radius: 1rem;
    padding: 2rem;
}

.auth-header {
    text-align: center;
    margin-bottom: 2rem;
}

.auth-tagline {
    color: var(--text2);
    font-size: 0.95rem;
    margin-top: 0.5rem;
}

.auth-form {
    margin-bottom: 1.5rem;
}

.auth-form .form-group {
    margin-bottom: 1.5rem;
}

.auth-footer {
    text-align: center;
    color: var(--text2);
    font-size: 0.9rem;
}

.auth-footer .link {
    color: var(--blue);
}

/* ============================================================================
   LEGAL PAGES
   ============================================================================ */

.legal-container {
    min-height: 100vh;
    padding: 2rem;
    background-color: var(--bg);
}

.legal-content {
    max-width: 800px;
    margin: 0 auto;
    background-color: var(--surface);
    border: 1px solid var(--border);
    border-radius: 1rem;
    padding: 2rem;
}

.legal-content h1 {
    margin-top: 0;
    color: var(--blue);
}

.legal-date {
    color: var(--text2);
    font-size: 0.9rem;
    margin-bottom: 2rem;
}

.legal-content section {
    margin-bottom: 2rem;
}

.legal-content section h2 {
    color: var(--text);
    margin-top: 1.5rem;
    margin-bottom: 1rem;
}

.legal-content section h3 {
    font-size: 1rem;
    color: var(--text2);
    margin-top: 1rem;
    margin-bottom: 0.5rem;
}

.legal-content section ul {
    margin-left: 1.5rem;
    color: var(--text2);
}

.legal-content section li {
    margin-bottom: 0.5rem;
}

.legal-content section p {
    color: var(--text2);
    margin-bottom: 1rem;
}

.legal-content .link {
    display: inline-block;
    margin-top: 2rem;
}

/* ============================================================================
   APP LAYOUT
   ============================================================================ */

.app-container {
    display: flex;
    flex-direction: column;
    height: 100vh;
    background-color: var(--bg);
}

.app-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 2rem;
    padding: 1rem 2rem;
    background-color: var(--surface);
    border-bottom: 1px solid var(--border);
    flex-wrap: wrap;
}

.header-left {
    flex-shrink: 0;
}

.header-center {
    flex: 1;
    min-width: 300px;
    max-width: 500px;
}

.header-right {
    flex-shrink: 0;
}

.user-menu {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.user-email {
    font-size: 0.9rem;
    color: var(--text2);
}

/* ============================================================================
   DISPATCH BAR (HERO ELEMENT)
   ============================================================================ */

.dispatch-bar-wrapper {
    position: relative;
    display: flex;
    gap: 0.5rem;
}

.dispatch-input {
    flex: 1;
    padding: 1rem;
    font-size: 1rem;
    font-weight: 500;
    background-color: var(--surface2);
    border: 2px solid var(--border);
    border-radius: 0.75rem;
    color: var(--text);
    transition: all 0.3s;
    outline: none;
    min-height: 44px;
    display: flex;
    align-items: center;
}

.dispatch-input:focus {
    border-color: var(--blue);
    background-color: var(--bg);
    box-shadow: 0 0 0 4px rgba(59, 130, 246, 0.2), 0 0 20px rgba(59, 130, 246, 0.3);
}

.dispatch-input::placeholder {
    color: var(--text3);
}

.dispatch-parse-btn {
    padding: 1rem 1.5rem;
    background-color: var(--blue);
    color: white;
    border-radius: 0.75rem;
    font-weight: 600;
    font-size: 1.2rem;
    transition: all 0.2s;
    min-height: 44px;
    min-width: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.dispatch-parse-btn:hover {
    background-color: #2563EB;
    box-shadow: 0 0 15px rgba(59, 130, 246, 0.4);
}

.dispatch-preview {
    position: absolute;
    top: calc(100% + 0.5rem);
    left: 0;
    right: 0;
    background-color: var(--surface2);
    border: 1px solid var(--blue);
    border-radius: 0.75rem;
    padding: 1rem;
    z-index: 200;
    box-shadow: 0 8px 32px rgba(0,0,0,0.4);
    min-width: 320px;
}

.dispatch-preview.hidden {
    display: none;
}

.dispatch-preview-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.5rem;
}

.dispatch-preview-item:last-child {
    margin-bottom: 0;
}

.dispatch-preview-label {
    color: var(--text3);
    font-size: 0.85rem;
}

.dispatch-preview-value {
    color: var(--text);
    font-weight: 500;
}

.dispatch-preview-buttons {
    display: flex;
    gap: 0.5rem;
    margin-top: 1rem;
    border-top: 1px solid var(--border);
    padding-top: 1rem;
}

.dispatch-preview-buttons .btn {
    flex: 1;
}

/* ============================================================================
   STATS ROW
   ============================================================================ */

.stats-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: 1rem;
    padding: 1.5rem 2rem;
    border-bottom: 1px solid var(--border);
    background-color: var(--bg);
}

.stat {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.stat-label {
    font-size: 0.8rem;
    color: var(--text3);
    font-weight: 500;
}

.stat-value {
    font-size: 1.8rem;
    font-weight: 700;
    color: var(--blue);
}

/* ============================================================================
   FILTER BAR
   ============================================================================ */

.filter-bar {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1rem 2rem;
    background-color: var(--surface);
    border-bottom: 1px solid var(--border);
    flex-wrap: wrap;
}

.filter-input {
    padding: 0.5rem 1rem;
    background-color: var(--surface2);
    border: 1px solid var(--border);
    border-radius: 0.5rem;
    color: var(--text);
    font-size: 0.9rem;
}

.filter-input:focus {
    outline: none;
    border-color: var(--blue);
    background-color: var(--bg);
}

.filter-search {
    flex: 1;
    min-width: 150px;
}

.filter-select {
    min-width: 120px;
}

.view-toggle {
    display: flex;
    gap: 0.5rem;
    margin-left: auto;
}

.view-btn {
    padding: 0.5rem 1rem;
    background-color: var(--surface2);
    color: var(--text2);
    border: 1px solid var(--border);
    border-radius: 0.5rem;
    font-size: 0.9rem;
    transition: all 0.2s;
}

.view-btn:hover {
    background-color: var(--border);
}

.view-btn-active {
    background-color: var(--blue);
    color: white;
    border-color: var(--blue);
}

/* ============================================================================
   MAIN CONTENT
   ============================================================================ */

.main-content {
    flex: 1;
    overflow-y: auto;
    padding: 2rem;
    background-color: var(--bg);
}

/* ============================================================================
   KANBAN BOARD
   ============================================================================ */

.board-view {
    display: block;
}

.kanban-container {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 1.5rem;
}

.kanban-column {
    display: flex;
    flex-direction: column;
    background-color: var(--surface);
    border: 1px solid var(--border);
    border-radius: 0.75rem;
    min-height: 500px;
    overflow: hidden;
}

.column-header {
    padding: 1rem;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    background-color: var(--surface2);
}

.column-header h3 {
    margin: 0;
    font-size: 1rem;
}

.column-count {
    background-color: var(--border);
    color: var(--text2);
    font-size: 0.8rem;
    padding: 0.25rem 0.75rem;
    border-radius: 1rem;
}

.column-content {
    flex: 1;
    padding: 1rem;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.task-card {
    background-color: var(--surface2);
    border: 1px solid var(--border);
    border-radius: 0.5rem;
    padding: 1rem;
    cursor: grab;
    transition: all 0.2s;
}

.task-card:hover {
    border-color: var(--blue);
    background-color: var(--bg);
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.15);
}

.task-card.dragging {
    opacity: 0.5;
    cursor: grabbing;
}

.task-id {
    font-size: 0.75rem;
    color: var(--text3);
    margin-bottom: 0.5rem;
}

.task-name {
    font-weight: 600;
    color: var(--text);
    margin-bottom: 0.75rem;
    font-size: 0.95rem;
}

.task-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-bottom: 0.75rem;
}

.chip {
    display: inline-block;
    padding: 0.25rem 0.75rem;
    border-radius: 1rem;
    font-size: 0.75rem;
    font-weight: 500;
}

.chip-category {
    background-color: rgba(139, 92, 246, 0.2);
    color: var(--purple);
}

.chip-priority {
    background-color: rgba(59, 130, 246, 0.2);
    color: var(--blue);
}

.chip-priority.high {
    background-color: rgba(239, 68, 68, 0.2);
    color: var(--red);
}

.chip-priority.low {
    background-color: rgba(107, 114, 128, 0.2);
    color: var(--grey);
}

.chip-recurrence {
    background-color: rgba(16, 185, 129, 0.2);
    color: var(--green);
}

.task-due {
    font-size: 0.8rem;
    color: var(--text2);
    margin-bottom: 0.5rem;
}

.task-due.overdue {
    color: var(--red);
    font-weight: 600;
}

.task-subtasks {
    margin-top: 0.75rem;
    padding-top: 0.75rem;
    border-top: 1px solid var(--border);
}

.subtask-progress {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.8rem;
    color: var(--text2);
}

.progress-bar {
    flex: 1;
    height: 4px;
    background-color: var(--border);
    border-radius: 2px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background-color: var(--green);
    transition: width 0.3s;
}

.task-actions {
    margin-top: 0.75rem;
    display: flex;
    gap: 0.5rem;
}

.task-btn {
    flex: 1;
    padding: 0.4rem 0.5rem;
    font-size: 0.75rem;
    background-color: var(--border);
    color: var(--text2);
    border-radius: 0.3rem;
    transition: all 0.2s;
}

.task-btn:hover {
    background-color: var(--blue);
    color: white;
}

/* ============================================================================
   LIST VIEW
   ============================================================================ */

.list-view {
    overflow-x: auto;
}

.list-view.hidden {
    display: none;
}

.tasks-table {
    width: 100%;
    border-collapse: collapse;
    background-color: var(--surface);
    border: 1px solid var(--border);
    border-radius: 0.75rem;
    overflow: hidden;
}

.tasks-table thead {
    background-color: var(--surface2);
    border-bottom: 1px solid var(--border);
}

.tasks-table th {
    padding: 1rem;
    text-align: left;
    font-weight: 600;
    font-size: 0.9rem;
    color: var(--text2);
}

.tasks-table td {
    padding: 1rem;
    border-bottom: 1px solid var(--border);
    color: var(--text);
}

.tasks-table tr:hover {
    background-color: var(--surface2);
}

.tasks-table tbody tr:last-child td {
    border-bottom: none;
}

.col-id {
    width: 60px;
}

.col-task {
    width: 25%;
}

.col-category {
    width: 12%;
}

.col-status {
    width: 12%;
}

.col-priority {
    width: 10%;
}

.col-due {
    width: 12%;
}

.col-next-action {
    width: 15%;
}

.col-subtasks {
    width: 10%;
}

.col-actions {
    width: 80px;
}

.table-chip {
    display: inline-block;
    padding: 0.25rem 0.5rem;
    border-radius: 0.3rem;
    font-size: 0.75rem;
    font-weight: 500;
    background-color: var(--border);
    color: var(--text2);
}

.table-btn {
    padding: 0.25rem 0.75rem;
    margin-right: 0.25rem;
    font-size: 0.75rem;
    background-color: var(--border);
    color: var(--text2);
    border-radius: 0.3rem;
    transition: all 0.2s;
}

.table-btn:hover {
    background-color: var(--blue);
    color: white;
}

/* ============================================================================
   HISTORY VIEW
   ============================================================================ */

.history-view {
    max-width: 900px;
}

.history-view.hidden {
    display: none;
}

.history-date {
    font-weight: 600;
    color: var(--blue);
    margin-top: 2rem;
    margin-bottom: 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--border);
}

.history-date:first-child {
    margin-top: 0;
}

.history-entry {
    display: flex;
    gap: 1.5rem;
    padding: 1rem;
    background-color: var(--surface);
    border-left: 3px solid var(--border);
    margin-bottom: 0.75rem;
    border-radius: 0.5rem;
    transition: all 0.2s;
}

.history-entry:hover {
    border-left-color: var(--blue);
    background-color: var(--surface2);
}

.history-icon {
    flex-shrink: 0;
    width: 2rem;
    height: 2rem;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 0.5rem;
    font-size: 0.9rem;
    background-color: var(--border);
}

.history-entry.created .history-icon {
    background-color: rgba(16, 185, 129, 0.2);
    color: var(--green);
}

.history-entry.updated .history-icon {
    background-color: rgba(59, 130, 246, 0.2);
    color: var(--blue);
}

.history-entry.completed .history-icon {
    background-color: rgba(16, 185, 129, 0.2);
    color: var(--green);
}

.history-entry.deleted .history-icon {
    background-color: rgba(239, 68, 68, 0.2);
    color: var(--red);
}

.history-content {
    flex: 1;
}

.history-title {
    font-weight: 600;
    color: var(--text);
    margin-bottom: 0.25rem;
}

.history-details {
    font-size: 0.9rem;
    color: var(--text2);
    margin-bottom: 0.25rem;
}

.history-timestamp {
    font-size: 0.8rem;
    color: var(--text3);
}

.history-source {
    display: inline-block;
    margin-left: 0.5rem;
    padding: 0.1rem 0.5rem;
    background-color: var(--border);
    border-radius: 0.2rem;
    font-size: 0.7rem;
    color: var(--text3);
}

/* ============================================================================
   MODALS
   ============================================================================ */

.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 2rem;
}

.modal.hidden {
    display: none;
}

.modal-content {
    background-color: var(--surface);
    border: 1px solid var(--border);
    border-radius: 1rem;
    max-height: 90vh;
    overflow-y: auto;
    width: 100%;
}

.modal-sm {
    max-width: 400px;
}

.modal-lg {
    max-width: 700px;
}

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

.modal-header h2 {
    margin: 0;
}

.modal-close {
    background: none;
    color: var(--text2);
    font-size: 1.5rem;
    cursor: pointer;
    transition: all 0.2s;
    padding: 0;
    width: 2rem;
    height: 2rem;
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-close:hover {
    color: var(--text);
    background-color: var(--border);
    border-radius: 0.5rem;
}

.modal-body {
    padding: 1.5rem;
}

.modal-footer {
    padding: 1.5rem;
    border-top: 1px solid var(--border);
    display: flex;
    gap: 1rem;
    justify-content: flex-end;
}

.spacer {
    flex: 1;
}

/* Task Form Specific */

.subtasks-container {
    margin-bottom: 1rem;
}

.subtask-item {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 0.75rem;
    align-items: center;
}

.subtask-input {
    flex: 1;
    padding: 0.5rem;
    background-color: var(--surface2);
    border: 1px solid var(--border);
    border-radius: 0.3rem;
    color: var(--text);
}

.subtask-check {
    width: 1.25rem;
    height: 1.25rem;
    cursor: pointer;
}

.subtask-delete {
    padding: 0.25rem 0.5rem;
    background-color: var(--border);
    color: var(--text2);
    border-radius: 0.3rem;
    font-size: 0.8rem;
}

.subtask-delete:hover {
    background-color: var(--red);
    color: white;
}

/* Settings Modal */

.settings-section {
    margin-bottom: 2rem;
}

.settings-section-header {
    margin-bottom: 1rem;
}

.settings-section-header h3 {
    margin-bottom: 0.25rem;
    color: var(--text);
}

.settings-hint {
    font-size: 0.85rem;
    color: var(--text3);
}

.mt-1 { margin-top: 1rem; }

/* Category cards */
.category-item {
    background-color: var(--surface2);
    border: 1px solid var(--border);
    border-radius: 0.5rem;
    padding: 0.75rem 1rem;
    margin-bottom: 0.75rem;
}

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

.category-name {
    font-weight: 600;
    color: var(--text);
    font-size: 0.95rem;
}

/* Subcategory row */
.subcats-row {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
    align-items: center;
    min-height: 28px;
}

/* Subcategory chips */
.subcat-chip {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    background-color: var(--surface);
    border: 1px solid var(--border);
    border-radius: 1rem;
    padding: 0.2rem 0.6rem;
    font-size: 0.8rem;
    color: var(--text2);
}

.subcat-remove {
    background: none;
    border: none;
    color: var(--text3);
    cursor: pointer;
    font-size: 0.9rem;
    line-height: 1;
    padding: 0 0 0 0.1rem;
    transition: color 0.15s;
}

.subcat-remove:hover {
    color: var(--red);
}

/* Inline add-subcategory form */
.add-subcat-inline {
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.add-subcat-inline .subcat-input {
    width: 140px;
    min-height: 32px;
    padding: 0.25rem 0.5rem;
    font-size: 0.85rem;
}

/* Add category form */
.add-category-form {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-top: 0.75rem;
    margin-bottom: 0.5rem;
}

.add-category-form .form-input {
    max-width: 220px;
    min-height: 36px;
    padding: 0.4rem 0.75rem;
}

/* Extra small button */
.btn-xs {
    padding: 0.25rem 0.6rem;
    font-size: 0.78rem;
    min-height: 28px;
}

/* ============================================================================
   FLASH MESSAGES
   ============================================================================ */

.flash {
    position: fixed;
    top: 1rem;
    right: 1rem;
    padding: 1rem 1.5rem;
    background-color: var(--surface);
    border: 1px solid var(--border);
    border-radius: 0.5rem;
    z-index: 2000;
    display: flex;
    align-items: center;
    gap: 1rem;
    animation: slideIn 0.3s ease-out;
}

@keyframes slideIn {
    from {
        transform: translateX(400px);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

.flash-error {
    border-color: var(--red);
    color: var(--red);
}

.flash-success {
    border-color: var(--green);
    color: var(--green);
}

.flash-close {
    background: none;
    border: none;
    color: inherit;
    font-size: 1.5rem;
    cursor: pointer;
    padding: 0;
}

/* ============================================================================
   TOAST NOTIFICATIONS
   ============================================================================ */

.toast-container {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    z-index: 2000;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.toast {
    background-color: var(--surface);
    border: 1px solid var(--border);
    border-radius: 0.5rem;
    padding: 1rem 1.5rem;
    color: var(--text);
    animation: slideUp 0.3s ease-out;
}

@keyframes slideUp {
    from {
        transform: translateY(100px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.toast.success {
    border-color: var(--green);
    color: var(--green);
}

.toast.error {
    border-color: var(--red);
    color: var(--red);
}

/* ============================================================================
   RESPONSIVE DESIGN
   ============================================================================ */

@media (max-width: 900px) {
    .app-header {
        flex-direction: column;
        align-items: stretch;
    }

    .header-left,
    .header-right {
        width: 100%;
    }

    .header-center {
        max-width: none;
    }

    .user-menu {
        justify-content: space-between;
    }

    .kanban-container {
        grid-template-columns: 1fr;
    }

    .kanban-column {
        min-height: 400px;
    }

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

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

    .view-toggle {
        margin-left: 0;
        width: 100%;
    }

    .view-btn {
        flex: 1;
    }

    .form-row {
        grid-template-columns: 1fr;
    }

    .tasks-table {
        font-size: 0.85rem;
    }

    .tasks-table th,
    .tasks-table td {
        padding: 0.75rem;
    }
}

@media (max-width: 600px) {
    .dispatch-logo {
        font-size: 1.2rem;
    }

    .dispatch-input {
        padding: 0.75rem;
        font-size: 0.95rem;
    }

    .dispatch-parse-btn {
        padding: 0.75rem 1rem;
        font-size: 1rem;
    }

    .stats-row {
        grid-template-columns: repeat(2, 1fr);
        gap: 0.75rem;
        padding: 1rem;
    }

    .stat-value {
        font-size: 1.5rem;
    }

    .filter-bar {
        padding: 0.75rem;
    }

    .main-content {
        padding: 1rem;
    }

    .modal {
        padding: 1rem;
    }

    .modal-sm,
    .modal-lg {
        max-width: 100%;
    }

    .toast-container {
        left: 1rem;
        right: 1rem;
        bottom: 1rem;
    }

    .toast {
        padding: 0.75rem 1rem;
        font-size: 0.9rem;
    }

    .flash {
        left: 1rem;
        right: 1rem;
    }

    .tasks-table {
        font-size: 0.75rem;
    }

    .tasks-table th,
    .tasks-table td {
        padding: 0.5rem;
    }

    .col-next-action {
        width: 0;
        display: none;
    }

    .col-actions {
        width: 60px;
    }

    .task-card {
        padding: 0.75rem;
    }

    .task-name {
        font-size: 0.9rem;
    }

    .chip {
        padding: 0.2rem 0.5rem;
        font-size: 0.7rem;
    }
}

/* ============================================================================
   UTILITY CLASSES
   ============================================================================ */

.hidden {
    display: none !important;
}

.link {
    color: var(--blue);
    cursor: pointer;
}

.link:hover {
    text-decoration: underline;
}

/* ============================================================================
   DISPATCH HELP BUTTON
   ============================================================================ */

.dispatch-help-btn {
    padding: 1rem 0.75rem;
    background-color: var(--surface2);
    color: var(--text2);
    border-radius: 0.75rem;
    font-weight: 600;
    font-size: 1rem;
    transition: all 0.2s;
    border: 1px solid var(--border);
    min-width: 44px;
    min-height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.dispatch-help-btn:hover {
    background-color: var(--border);
    color: var(--text);
    border-color: var(--text2);
}

.dispatch-help-example {
    background-color: var(--surface);
    border-left: 3px solid var(--blue);
    padding: 1rem;
    border-radius: 0.5rem;
    margin: 0.5rem 0;
}

.dispatch-help-example code {
    color: var(--blue);
    font-family: 'Monaco', 'Courier New', monospace;
    font-size: 0.9rem;
}

.dispatch-help-examples {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.dispatch-help-item {
    background-color: var(--surface);
    padding: 0.75rem 1rem;
    border-left: 2px solid var(--amber);
    border-radius: 0.25rem;
    font-size: 0.85rem;
    color: var(--text2);
    font-style: italic;
}

/* Dispatch hint grid inside help modal */
.dispatch-hint-chip-info {
    background-color: var(--surface);
    border: 1px solid var(--border);
    border-radius: 0.5rem;
    padding: 0.6rem 0.75rem;
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
}

.dispatch-hint-label {
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--blue);
}

.dispatch-hint-example {
    font-size: 0.8rem;
    color: var(--text2);
}

/* ============================================================================
   PWA STANDALONE MODE
   ============================================================================ */

@supports (display: standalone) {
    @media (display-mode: standalone) {
        body {
            padding-top: env(safe-area-inset-top);
            padding-bottom: env(safe-area-inset-bottom);
        }
    }
}

/* ============================================================================
   MOBILE BOTTOM NAV
   ============================================================================ */

.mobile-bottom-nav {
    display: none;
}

@media (max-width: 768px) {
    .mobile-bottom-nav {
        display: flex;
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        height: 60px;
        background: var(--surface);
        border-top: 1px solid var(--border);
        align-items: center;
        justify-content: space-around;
        z-index: 500;
        padding-bottom: env(safe-area-inset-bottom, 0);
    }

    /* Add bottom padding to app-container so content doesn't hide behind nav */
    .app-container {
        padding-bottom: 68px;
    }

    .mob-nav-item {
        display: flex;
        flex-direction: column;
        align-items: center;
        gap: 2px;
        background: none;
        border: none;
        color: var(--text3);
        font-family: inherit;
        font-size: 0;
        cursor: pointer;
        padding: 0.4rem 0.75rem;
        border-radius: 8px;
        transition: color 0.15s;
        flex: 1;
    }

    .mob-nav-item:hover,
    .mob-nav-item.active {
        color: var(--blue);
    }

    .mob-nav-icon {
        font-size: 1.35rem;
        line-height: 1;
    }

    .mob-nav-label {
        font-size: 0.62rem;
        font-weight: 600;
        letter-spacing: 0.02em;
    }

    /* Center FAB (+) button */
    .mob-nav-fab {
        display: flex;
        align-items: center;
        justify-content: center;
        width: 50px;
        height: 50px;
        border-radius: 50%;
        background: linear-gradient(135deg, var(--blue), var(--purple));
        border: none;
        color: white;
        cursor: pointer;
        box-shadow: 0 4px 16px rgba(59, 130, 246, 0.45);
        flex-shrink: 0;
        margin-bottom: 8px;
        transition: transform 0.15s, box-shadow 0.15s;
    }

    .mob-nav-fab:hover {
        transform: scale(1.06);
        box-shadow: 0 6px 20px rgba(59, 130, 246, 0.6);
    }

    /* Hide the desktop header view-toggle buttons on mobile — bottom nav takes over */
    .view-toggle-btn {
        display: none;
    }
}
