/**
 * Operations Center Dashboard Stylesheet
 * Dark-themed dashboard with modern aesthetics
 */

:root {
    --bg-deep: #000000;
    --bg-primary: #1A0B1E;
    --bg-secondary: #2a1530;
    --bg-card: rgba(42, 21, 48, 0.8);
    --accent-primary: #7172AA;
    --accent-secondary: #596F7C;
    --accent-light: #8a8bc0;
    --text-primary: #FFFFFF;
    --text-secondary: #596F7C;
    --success: #50fa7b;
    --warning: #ffb86c;
    --error: #ff5555;
    --border: rgba(113, 114, 170, 0.3);
}

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

/* Custom Scrollbar */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}
::-webkit-scrollbar-track {
    background: var(--bg-deep);
}
::-webkit-scrollbar-thumb {
    background: var(--accent-secondary);
    border-radius: 4px;
    box-shadow: 0 0 10px var(--accent-secondary);
}
::-webkit-scrollbar-thumb:hover {
    background: var(--accent-primary);
    box-shadow: 0 0 15px var(--accent-primary);
}

body {
    font-family: 'Share Tech Mono', 'SF Mono', 'Consolas', monospace;
    background: var(--bg-deep);
    color: var(--text-primary);
    min-height: 100vh;
    line-height: 1.6;
    overflow-x: hidden;
    /* Prevent overscroll bounce on mobile */
    overscroll-behavior: none;
    /* Improve mobile scrolling */
    -webkit-overflow-scrolling: touch;
}

/* CRT Scanline Effect */
body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: repeating-linear-gradient(
        0deg,
        rgba(0, 0, 0, 0.1),
        rgba(0, 0, 0, 0.1) 1px,
        transparent 1px,
        transparent 2px
    );
    pointer-events: none;
    z-index: 1000;
    opacity: 0.15;
}

/* Vignette Effect */
body::after {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: radial-gradient(ellipse at center, transparent 0%, rgba(0,0,0,0.4) 100%);
    pointer-events: none;
    z-index: 999;
}

.is-hidden {
    display: none !important;
}

.version-info {
    font-size: 0.75rem;
    color: var(--text-secondary);
}

.table-empty {
    text-align: center;
    color: var(--text-secondary);
}

.table-error {
    text-align: center;
    color: var(--error);
}

.modal-actions {
    display: flex;
    gap: 0.5rem;
    margin-top: 1.5rem;
    justify-content: flex-end;
}

.empty-state-note {
    margin-top: 0.5rem;
    font-size: 0.875rem;
    color: var(--text-secondary);
}

.input-error {
    border-color: var(--error) !important;
}

.input-warning {
    border-color: var(--warning) !important;
}

.validation-error {
    color: var(--error);
    font-size: 0.75rem;
    margin-top: 0.25rem;
}

.stat-card-chart {
    margin-top: 0.5rem;
}

.clipboard-textarea {
    position: fixed;
    opacity: 0;
    top: -1000px;
    left: -1000px;
    pointer-events: none;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 1rem;
    position: relative;
    z-index: 1;
}

@media (min-width: 768px) {
    .container {
        padding: 2rem;
    }
}

/* Header */
.header {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
    margin-bottom: 2rem;
    text-align: center;
}

@media (min-width: 768px) {
    .header {
        flex-direction: row;
        text-align: left;
    }
}

/* Header action buttons (desktop only) */
.header-actions {
    display: none;
    gap: 0.5rem;
    margin-left: auto;
}

@media (min-width: 1024px) {
    .header-actions {
        display: flex;
    }
}

.mascot {
    width: 100px;
    height: 100px;
    border-radius: 50%;
    border: 3px solid var(--accent-secondary);
    box-shadow: 0 0 20px var(--accent-secondary), 0 0 40px rgba(89, 111, 124, 0.3);
    animation: pulse-glow 2s ease-in-out infinite;
    object-fit: cover;
}

@keyframes pulse-glow {
    0%, 100% {
        box-shadow: 0 0 20px var(--accent-secondary), 0 0 40px rgba(89, 111, 124, 0.3);
    }
    50% {
        box-shadow: 0 0 30px var(--accent-primary), 0 0 60px rgba(113, 114, 170, 0.4);
    }
}

@media (min-width: 768px) {
    .mascot {
        width: 120px;
        height: 120px;
    }
}

h1 {
    font-family: 'VT323', monospace;
    font-size: 2rem;
    text-transform: uppercase;
    letter-spacing: 2px;
    color: var(--accent-primary);
    text-shadow: 0 0 4px rgba(113, 114, 170, 0.4);
    animation: glitch 3s infinite;
}

@media (min-width: 768px) {
    h1 {
        font-size: 3rem;
    }
}

@media (min-width: 1024px) {
    h1 {
        font-size: 3.5rem;
    }
}

@keyframes glitch {
    0%, 90%, 100% {
        transform: translate(0);
    }
    91% {
        transform: translate(-2px, 1px);
    }
    92% {
        transform: translate(2px, -1px);
    }
    93% {
        transform: translate(-1px, 2px);
    }
    94% {
        transform: translate(1px, -2px);
    }
}

.subtitle {
    font-size: 0.875rem;
    color: var(--accent-light);
    text-transform: uppercase;
    letter-spacing: 3px;
}

/* Auth Section */
.auth-section {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    margin-bottom: 2rem;
    padding: 1.5rem;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 0.5rem;
    position: relative;
    backdrop-filter: blur(2px);
}

.auth-section::before,
.auth-section::after {
    content: '';
    position: absolute;
    width: 20px;
    height: 20px;
    border: 2px solid var(--accent-primary);
}

.auth-section::before {
    top: -2px;
    left: -2px;
    border-right: none;
    border-bottom: none;
}

.auth-section::after {
    bottom: -2px;
    right: -2px;
    border-left: none;
    border-top: none;
}

@media (min-width: 768px) {
    .auth-section {
        flex-direction: row;
        flex-wrap: wrap;
        align-items: center;
    }
}

.auth-fields {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    flex: 1;
    min-width: 0;
    align-items: stretch;
}

@media (min-width: 640px) {
    .auth-fields {
        flex-direction: row;
        flex-wrap: wrap;
    }
}

.auth-fields > input {
    flex: 1;
    min-width: 12rem;
}

.auth-fields > button {
    align-self: stretch;
}

select, input[type="text"], input[type="password"], input[type="email"], input[type="number"], input[type="datetime-local"] {
    padding: 0.75rem 1rem;
    border-radius: 0.375rem;
    border: 1px solid var(--border);
    background: var(--bg-deep);
    color: var(--text-primary);
    font-family: inherit;
    font-size: 0.875rem;
    transition: all 0.2s;
    width: 100%;
}

select:focus, input:focus {
    outline: none;
    border-color: var(--accent-primary);
    box-shadow: 0 0 10px rgba(113, 114, 170, 0.3);
}

.password-wrapper {
    position: relative;
    display: flex;
    flex: 1;
    min-width: 12rem;
    align-items: stretch;
}

.password-wrapper input {
    flex: 1;
    padding-right: 2.5rem;
    height: 100%;
}

.password-toggle {
    position: absolute;
    right: 0.5rem;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 0.25rem;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color 0.2s;
}

.password-toggle:hover,
.password-toggle:focus,
.password-toggle:active {
    color: var(--accent-primary);
    background: none;
    box-shadow: none;
    transform: translateY(-50%);
}

button {
    padding: 0.75rem 1.5rem;
    border-radius: 0.375rem;
    border: 2px solid var(--accent-primary);
    background: transparent;
    color: var(--accent-primary);
    cursor: pointer;
    font-family: 'VT323', monospace;
    font-size: 1.125rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 2px;
    transition: all 0.3s;
    white-space: nowrap;
}

button:hover {
    background: var(--accent-primary);
    color: var(--bg-deep);
    box-shadow: 0 0 20px var(--accent-primary), 0 0 40px rgba(113, 114, 170, 0.3);
    transform: translateY(-2px);
}

button.secondary {
    border-color: var(--accent-secondary);
    color: var(--accent-secondary);
}

button.secondary:hover {
    background: var(--accent-secondary);
    color: var(--bg-deep);
    box-shadow: 0 0 20px var(--accent-secondary), 0 0 40px rgba(89, 111, 124, 0.3);
}

button.danger {
    border-color: var(--error);
    color: var(--error);
}

button.danger:hover {
    background: var(--error);
    color: var(--bg-deep);
    box-shadow: 0 0 20px var(--error);
}

.action-buttons {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
    width: 100%;
}

.action-buttons > button {
    flex: 1;
    min-width: fit-content;
}

@media (max-width: 480px) {
    .action-buttons {
        flex-direction: column;
    }

    .action-buttons > button {
        width: 100%;
    }
}

@media (min-width: 481px) and (max-width: 767px) {
    .action-buttons {
        justify-content: space-between;
    }

    .action-buttons > button {
        flex: 1 1 calc(50% - 0.25rem);
        min-width: 0;
    }
}

@media (min-width: 768px) {
    .action-buttons {
        width: auto;
        margin-left: auto;
        flex-wrap: nowrap;
    }

    .action-buttons > button {
        flex: 0 1 auto;
    }
}

/* Hide auth-section action buttons on desktop (use header buttons instead) */
@media (min-width: 1024px) {
    .auth-section .action-buttons {
        display: none;
    }

    /* Hide entire auth-section on desktop when logged in */
    .auth-section.logged-in {
        display: none;
    }
}

/* Dashboard Content */
.dashboard-content {
    display: none;
}

.dashboard-content.visible {
    display: block;
}

/* Stats Grid */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 0.75rem;
    margin-bottom: 2rem;
}

@media (min-width: 640px) {
    .stats-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 1rem;
    }
}

@media (min-width: 1024px) {
    .stats-grid {
        grid-template-columns: repeat(6, 1fr);
    }
}

.stat-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 0.5rem;
    padding: 1rem;
    text-align: center;
    position: relative;
    overflow: hidden;
    backdrop-filter: blur(2px);
    transition: all 0.3s;
}

.stat-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(90deg, var(--accent-primary), var(--accent-secondary));
}

.stat-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 10px 30px rgba(89, 111, 124, 0.2);
}

.stat-card h3 {
    font-family: 'Share Tech Mono', monospace;
    font-size: 0.625rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 0.5rem;
}

@media (min-width: 640px) {
    .stat-card h3 {
        font-size: 0.75rem;
    }
}

.stat-card .value {
    font-family: 'VT323', monospace;
    font-size: 2rem;
    font-weight: bold;
    color: var(--text-primary);
    text-shadow: 0 0 4px rgba(255, 255, 255, 0.3);
}

@media (min-width: 640px) {
    .stat-card .value {
        font-size: 2.5rem;
    }
}

.stat-card.success .value { color: var(--success); }
.stat-card.warning .value { color: var(--warning); }
.stat-card.error .value { color: var(--error); }

/* Sections */
.section {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 0.5rem;
    padding: 1rem;
    margin-bottom: 1.5rem;
    position: relative;
    backdrop-filter: blur(2px);
}

@media (min-width: 768px) {
    .section {
        padding: 1.5rem;
    }
}

.section::before,
.section::after {
    content: '';
    position: absolute;
    width: 15px;
    height: 15px;
    border: 2px solid var(--accent-secondary);
}

.section::before {
    top: -2px;
    left: -2px;
    border-right: none;
    border-bottom: none;
}

.section::after {
    bottom: -2px;
    right: -2px;
    border-left: none;
    border-top: none;
}

.section h2 {
    font-family: 'VT323', monospace;
    font-size: 1.5rem;
    color: var(--accent-primary);
    text-transform: uppercase;
    letter-spacing: 2px;
    margin-bottom: 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--border);
}

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

table {
    width: 100%;
    border-collapse: collapse;
    min-width: 500px;
}

th, td {
    text-align: left;
    padding: 0.75rem;
    border-bottom: 1px solid var(--border);
}

th {
    font-family: 'VT323', monospace;
    color: var(--accent-secondary);
    font-weight: 500;
    font-size: 0.875rem;
    text-transform: uppercase;
    letter-spacing: 1px;
}

td {
    font-size: 0.875rem;
}

tr.clickable {
    cursor: pointer;
    transition: all 0.2s;
}

tr.clickable:hover {
    background: rgba(113, 114, 170, 0.1);
}

code {
    font-family: 'Share Tech Mono', monospace;
    background: var(--bg-deep);
    padding: 0.125rem 0.5rem;
    border-radius: 0.25rem;
    color: var(--yellow);
}

/* Status Badges */
.status-badge {
    display: inline-block;
    padding: 0.25rem 0.75rem;
    border-radius: 0.25rem;
    font-family: 'VT323', monospace;
    font-size: 0.875rem;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.status-idle { background: rgba(80, 250, 123, 0.2); color: var(--success); border: 1px solid var(--success); }
.status-busy { background: rgba(255, 184, 108, 0.2); color: var(--warning); border: 1px solid var(--warning); }
.status-offline { background: rgba(255, 85, 85, 0.2); color: var(--error); border: 1px solid var(--error); }
.status-pending { background: rgba(189, 147, 249, 0.2); color: var(--purple-light); border: 1px solid var(--purple-light); }
.status-running { background: rgba(255, 184, 108, 0.2); color: var(--warning); border: 1px solid var(--warning); }
.status-analyzing { background: rgba(89, 111, 124, 0.2); color: var(--accent-secondary); border: 1px solid var(--accent-secondary); }
.status-success { background: rgba(80, 250, 123, 0.2); color: var(--success); border: 1px solid var(--success); }
.status-error { background: rgba(255, 85, 85, 0.2); color: var(--error); border: 1px solid var(--error); }
.status-scheduled { background: rgba(113, 114, 170, 0.2); color: var(--accent-primary); border: 1px solid var(--accent-primary); }
.status-assigned { background: rgba(138, 139, 192, 0.2); color: var(--accent-light); border: 1px solid var(--accent-light); }

.logs-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.25rem 0.75rem;
    border-radius: 0.25rem;
    font-family: 'VT323', monospace;
    font-size: 0.875rem;
    background: rgba(113, 114, 170, 0.2);
    color: var(--accent-primary);
    border: 1px solid var(--accent-primary);
    cursor: pointer;
    transition: all 0.2s;
}

.logs-badge:hover {
    background: var(--accent-primary);
    color: var(--bg-deep);
    box-shadow: 0 0 15px var(--accent-primary);
}

.logs-badge.no-logs {
    background: rgba(148, 163, 184, 0.1);
    color: var(--text-secondary);
    border-color: var(--text-secondary);
    cursor: default;
}

.logs-badge.no-logs:hover {
    background: rgba(148, 163, 184, 0.1);
    color: var(--text-secondary);
    box-shadow: none;
}

/* Refresh Note */
.refresh-note {
    font-size: 0.75rem;
    color: var(--text-secondary);
    text-align: center;
    margin-top: 1rem;
}

/* Modal Styles */
.modal-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(13, 2, 33, 0.95);
    z-index: 1001;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 1rem;
    /* Improve mobile scrolling */
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
    opacity: 1;
    transition: opacity 0.2s ease-out;
}

@media (min-width: 768px) {
    .modal-overlay {
        padding: 2rem;
    }
}

.modal-overlay.active {
    display: flex;
    align-items: flex-start;
    justify-content: center;
}

.modal-overlay.is-fading {
    opacity: 0;
}

.modal {
    width: 100%;
    max-width: 900px;
    background: var(--bg-primary);
    border: 2px solid var(--accent-secondary);
    border-radius: 0.75rem;
    overflow: hidden;
    box-shadow: 0 0 50px rgba(89, 111, 124, 0.3);
    margin: auto;
    /* Prevent horizontal overflow on mobile */
    max-width: calc(100vw - 2rem);
}

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

.modal-header h3 {
    font-family: 'VT323', monospace;
    font-size: 1.25rem;
    color: var(--accent-primary);
    text-transform: uppercase;
    letter-spacing: 1px;
}

.modal-close {
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 2rem;
    cursor: pointer;
    padding: 0;
    line-height: 1;
    transition: color 0.2s;
}

.modal-close:hover {
    color: var(--error);
    background: none;
    box-shadow: none;
    transform: none;
}

.modal-body {
    padding: 1.5rem;
    max-height: 70vh;
    overflow-y: auto;
    overflow-x: hidden;
    /* Improve mobile scrolling */
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
}

/* Mobile: Better modal sizing */
@media (max-width: 768px) {
    .modal-body {
        max-height: calc(100vh - 12rem);
        padding: 1rem;
    }
}

/* Form Styles */
.form-group {
    margin-bottom: 1.25rem;
    /* Prevent overflow on mobile */
    overflow-wrap: break-word;
    word-wrap: break-word;
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    color: var(--accent-light);
    font-family: 'VT323', monospace;
    font-size: 1rem;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.form-group input,
.form-group textarea,
.form-group select {
    width: 100%;
    padding: 0.75rem;
    border-radius: 0.375rem;
    border: 1px solid var(--border);
    background: var(--bg-deep);
    color: var(--text-primary);
    font-family: inherit;
    font-size: 0.875rem;
    /* Prevent overflow on mobile */
    box-sizing: border-box;
    max-width: 100%;
}

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

.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus {
    outline: none;
    border-color: var(--accent-primary);
    box-shadow: 0 0 10px rgba(113, 114, 170, 0.3);
}

.helper-text {
    margin-top: 0.4rem;
    font-size: 0.75rem;
    color: var(--text-secondary);
}

/* Session Info */
.session-info {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1rem;
    padding: 1rem;
    background: var(--bg-deep);
    border-radius: 0.5rem;
    margin-bottom: 1.5rem;
    border: 1px solid var(--border);
}

@media (min-width: 640px) {
    .session-info {
        grid-template-columns: repeat(3, 1fr);
    }
}

@media (min-width: 768px) {
    .session-info {
        grid-template-columns: repeat(5, 1fr);
    }
}

.session-info-item {
    text-align: center;
}

.session-info-item .label {
    font-size: 0.625rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 0.25rem;
}

.session-info-item .value {
    font-family: 'VT323', monospace;
    font-size: 1.25rem;
    color: var(--accent-primary);
}

/* Message Styles */
.message {
    margin-bottom: 1.5rem;
    border-radius: 0.5rem;
    overflow: hidden;
    border: 1px solid var(--border);
}

.message-header {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    padding: 0.75rem 1rem;
    font-size: 0.75rem;
}

@media (min-width: 640px) {
    .message-header {
        flex-direction: row;
        justify-content: space-between;
        align-items: center;
    }
}

.message-role {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-family: 'VT323', monospace;
    font-size: 1rem;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.message-role-icon {
    width: 1.75rem;
    height: 1.75rem;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.875rem;
    font-weight: bold;
}

.message-meta {
    color: var(--text-secondary);
    font-size: 0.75rem;
}

.message-content {
    padding: 1rem;
    font-size: 0.875rem;
    line-height: 1.7;
}

.message-content p { margin-bottom: 0.75rem; }
.message-content p:last-child { margin-bottom: 0; }
.message-content pre {
    margin: 0.75rem 0;
    border-radius: 0.375rem;
    overflow-x: auto;
}
.message-content code {
    font-family: 'Share Tech Mono', monospace;
    font-size: 0.8125rem;
}
.message-content code:not(pre code) {
    background: var(--bg-deep);
    padding: 0.125rem 0.375rem;
    border-radius: 0.25rem;
}

/* Role-specific colors */
.message.user .message-header { background: rgba(30, 64, 175, 0.5); }
.message.user .message-role-icon { background: #3b82f6; color: white; }
.message.user .message-content { background: rgba(23, 37, 84, 0.5); color: #bfdbfe; }

.message.assistant .message-header { background: rgba(22, 101, 52, 0.5); }
.message.assistant .message-role-icon { background: var(--success); color: var(--bg-deep); }
.message.assistant .message-content { background: rgba(20, 83, 45, 0.5); color: #bbf7d0; }

.message.system .message-header { background: rgba(107, 33, 168, 0.5); }
.message.system .message-role-icon { background: #a855f7; color: white; }
.message.system .message-content { background: rgba(88, 28, 135, 0.5); color: #e9d5ff; }

.message.tool .message-header { background: rgba(133, 77, 14, 0.5); }
.message.tool .message-role-icon { background: var(--warning); color: var(--bg-deep); }
.message.tool .message-content { background: rgba(113, 63, 18, 0.5); color: #fef08a; }

/* Loading state */
.loading {
    text-align: center;
    padding: 3rem;
    color: var(--text-secondary);
}

.loading-spinner {
    width: 3rem;
    height: 3rem;
    border: 3px solid var(--border);
    border-top-color: var(--accent-primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 1rem;
    box-shadow: 0 0 20px var(--accent-primary);
}

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

/* Empty state */
.empty-state {
    text-align: center;
    padding: 3rem;
    color: var(--text-secondary);
}

.empty-state-icon {
    font-family: 'VT323', monospace;
    font-size: 2rem;
    color: var(--accent-secondary);
    margin-bottom: 1rem;
}

/* File upload */
input[type="file"] {
    padding: 0.75rem;
    border: 2px dashed var(--border);
    border-radius: 0.375rem;
    cursor: pointer;
    transition: all 0.2s;
}

input[type="file"]:hover {
    border-color: var(--accent-primary);
}

.file-upload-status {
    font-size: 0.75rem;
    margin-top: 0.25rem;
    color: var(--text-secondary);
}

/* Animations */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.stat-card, .section {
    animation: fadeIn 0.5s ease-out;
}

.stat-card:nth-child(1) { animation-delay: 0.1s; }
.stat-card:nth-child(2) { animation-delay: 0.15s; }
.stat-card:nth-child(3) { animation-delay: 0.2s; }
.stat-card:nth-child(4) { animation-delay: 0.25s; }
.stat-card:nth-child(5) { animation-delay: 0.3s; }
.stat-card:nth-child(6) { animation-delay: 0.35s; }

/* Input Chips */
.chips-container {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    padding: 0.75rem;
    background: var(--bg-deep);
    border: 1px solid var(--border);
    border-radius: 0.375rem;
    min-height: 2.75rem;
}

.chip {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    padding: 0.375rem 0.75rem;
    background: rgba(113, 114, 170, 0.15);
    border: 1px solid var(--accent-primary);
    border-radius: 2rem;
    font-size: 0.75rem;
    color: var(--accent-primary);
    cursor: pointer;
    transition: all 0.2s;
    user-select: none;
}

.chip:hover {
    background: rgba(113, 114, 170, 0.25);
    box-shadow: 0 0 10px rgba(113, 114, 170, 0.3);
}

.chip.selected {
    background: var(--accent-primary);
    color: var(--bg-deep);
    font-weight: 600;
}

.chip.selected:hover {
    background: var(--accent-primary);
    box-shadow: 0 0 15px var(--accent-primary);
}

.chip .chip-remove {
    display: none;
    font-size: 1rem;
    line-height: 1;
    margin-left: 0.25rem;
}

.chip.selected .chip-remove {
    display: inline;
}

.chip-email {
    border-color: var(--accent-light);
    background: rgba(138, 139, 192, 0.15);
    color: var(--accent-light);
}

.chip-email:hover {
    background: rgba(138, 139, 192, 0.25);
    box-shadow: 0 0 10px rgba(138, 139, 192, 0.3);
}

.chip-email.selected {
    background: var(--accent-light);
    color: var(--bg-deep);
}

.chip-email.selected:hover {
    background: var(--accent-light);
    box-shadow: 0 0 15px var(--accent-light);
}

.chip-protocol {
    border-color: var(--purple-light);
    background: rgba(189, 147, 249, 0.15);
    color: var(--purple-light);
}

.chip-protocol:hover {
    background: rgba(189, 147, 249, 0.25);
    box-shadow: 0 0 10px rgba(189, 147, 249, 0.3);
}

.chip-protocol.selected {
    background: var(--purple-light);
    color: var(--bg-deep);
}

.chip-protocol.selected:hover {
    background: var(--purple-light);
    box-shadow: 0 0 15px var(--purple-light);
}

/* Collapsible Sections */
.collapsible-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
    padding: 0.5rem 0;
    margin-bottom: 0.5rem;
}

.collapsible-header:hover {
    color: var(--accent-primary);
}

.collapsible-header .toggle-icon {
    font-family: 'VT323', monospace;
    font-size: 1.25rem;
    transition: transform 0.3s;
}

.collapsible-header.open .toggle-icon {
    transform: rotate(90deg);
}

.collapsible-content {
    display: none;
    animation: slideDown 0.3s ease-out;
}

.collapsible-content.open {
    display: block;
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Protocol Adherence Toggle */
.toggle-group {
    display: flex;
    gap: 0;
    margin-top: 0.5rem;
}

.toggle-btn {
    flex: 1;
    padding: 0.5rem 1rem;
    border: 1px solid var(--border);
    background: var(--bg-deep);
    color: var(--text-secondary);
    font-family: 'VT323', monospace;
    font-size: 0.875rem;
    cursor: pointer;
    transition: all 0.2s;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.toggle-btn:first-child {
    border-radius: 0.375rem 0 0 0.375rem;
}

.toggle-btn:last-child {
    border-radius: 0 0.375rem 0.375rem 0;
    border-left: none;
}

.toggle-btn.active {
    background: var(--accent-secondary);
    border-color: var(--accent-secondary);
    color: var(--bg-deep);
    font-weight: 600;
}

.toggle-btn:hover:not(.active) {
    border-color: var(--accent-secondary);
    color: var(--accent-secondary);
}

/* Timezone Info */
.timezone-info {
    display: flex;
    gap: 0.75rem;
    padding: 0.75rem;
    background: rgba(113, 114, 170, 0.05);
    border: 1px solid rgba(113, 114, 170, 0.2);
    border-radius: 0.375rem;
    margin-bottom: 0.75rem;
    font-size: 0.875rem;
    flex-wrap: wrap;
    align-items: center;
}

.timezone-label {
    color: var(--text-secondary);
    font-weight: 600;
}

.timezone-value {
    color: var(--accent-primary);
    font-family: 'VT323', monospace;
    font-size: 1rem;
}

@media (max-width: 480px) {
    .timezone-info {
        flex-direction: column;
        gap: 0.5rem;
        align-items: flex-start;
    }
}

/* Timeout Presets */
.timeout-presets {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 0.75rem;
    flex-wrap: wrap;
}

.timeout-preset-btn {
    padding: 0.625rem 1rem;
    border: 1px solid var(--border);
    background: var(--bg-deep);
    color: var(--text-secondary);
    font-family: 'Share Tech Mono', monospace;
    font-size: 0.875rem;
    cursor: pointer;
    transition: all 0.2s;
    border-radius: 0.375rem;
    text-align: center;
    white-space: nowrap;
}

.timeout-preset-btn:hover {
    border-color: var(--accent-primary);
    color: var(--accent-primary);
    box-shadow: 0 0 10px rgba(113, 114, 170, 0.2);
}

.timeout-preset-btn.active {
    background: var(--accent-primary);
    border-color: var(--accent-primary);
    color: var(--bg-deep);
    font-weight: 600;
}

/* Schedule Presets */
.schedule-presets {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 0.5rem;
    margin-bottom: 1rem;
}

@media (min-width: 640px) {
    .schedule-presets {
        grid-template-columns: repeat(3, 1fr);
    }
}

@media (min-width: 768px) {
    .schedule-presets {
        grid-template-columns: repeat(4, 1fr);
    }
}

.preset-btn {
    padding: 0.625rem 0.75rem;
    border: 1px solid var(--border);
    background: var(--bg-deep);
    color: var(--text-secondary);
    font-family: 'Share Tech Mono', monospace;
    font-size: 0.75rem;
    cursor: pointer;
    transition: all 0.2s;
    border-radius: 0.375rem;
    text-align: center;
}

.preset-btn:hover {
    border-color: var(--yellow);
    color: var(--yellow);
    box-shadow: 0 0 10px rgba(243, 255, 88, 0.2);
}

.preset-btn.active {
    background: var(--yellow);
    border-color: var(--yellow);
    color: var(--bg-deep);
    font-weight: 600;
}

.preset-btn .preset-label {
    display: block;
    font-weight: 600;
    margin-bottom: 0.125rem;
}

.preset-btn .preset-cron {
    font-size: 0.625rem;
    opacity: 0.7;
}

/* Advanced Toggle Link */
.advanced-toggle {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--text-secondary);
    font-size: 0.75rem;
    cursor: pointer;
    margin-bottom: 0.75rem;
    transition: color 0.2s;
}

.advanced-toggle:hover {
    color: var(--accent-primary);
}

.advanced-toggle .arrow {
    transition: transform 0.2s;
}

.advanced-toggle.open .arrow {
    transform: rotate(90deg);
}

/* Info Button */
.info-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.25rem;
    height: 1.25rem;
    border-radius: 50%;
    border: 1px solid var(--text-secondary);
    color: var(--text-secondary);
    font-size: 0.75rem;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.2s;
    text-decoration: none;
    margin-left: 0.5rem;
}

.info-btn:hover {
    border-color: var(--accent-primary);
    color: var(--accent-primary);
    box-shadow: 0 0 10px rgba(113, 114, 170, 0.3);
    background: none;
    transform: none;
}

/* Bug Report Link */
.bug-report-link {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--text-secondary);
    font-size: 0.75rem;
    text-decoration: none;
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--border);
    border-radius: 0.375rem;
    transition: all 0.2s;
}

.bug-report-link:hover {
    color: var(--warning);
    border-color: var(--warning);
    box-shadow: 0 0 10px rgba(255, 184, 108, 0.3);
}

.bug-report-link svg {
    width: 1rem;
    height: 1rem;
}

/* Footer */
.dashboard-footer {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
    margin-top: 2rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--border);
}

@media (min-width: 640px) {
    .dashboard-footer {
        flex-direction: row;
        justify-content: space-between;
    }
}

/* Section Label with Optional Badge */
.form-label-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 0.5rem;
}

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

.optional-badge {
    font-size: 0.625rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 1px;
    padding: 0.125rem 0.5rem;
    border: 1px solid var(--border);
    border-radius: 0.25rem;
}

/* Selected Items Preview */
.selected-preview {
    margin-top: 0.5rem;
    padding: 0.5rem 0.75rem;
    background: rgba(0, 0, 0, 0.3);
    border-radius: 0.25rem;
    font-size: 0.75rem;
    color: var(--text-secondary);
    display: none;
}

.selected-preview.visible {
    display: block;
}

.selected-preview strong {
    color: var(--accent-primary);
}

/* Prompt Preview */
.prompt-preview {
    margin-top: 1rem;
    padding: 1rem;
    background: var(--bg-deep);
    border: 1px dashed var(--border);
    border-radius: 0.375rem;
    font-size: 0.8125rem;
    color: var(--text-secondary);
    white-space: pre-wrap;
    word-break: break-word;
    overflow-wrap: break-word;
    max-height: 200px;
    overflow-y: auto;
    overflow-x: hidden;
    /* Improve mobile scrolling */
    -webkit-overflow-scrolling: touch;
}

.prompt-preview-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 0.5rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--border);
    font-family: 'VT323', monospace;
    color: var(--accent-light);
    font-size: 0.875rem;
    text-transform: uppercase;
    letter-spacing: 1px;
}

/* Form Group Compact */
.form-group-compact {
    margin-bottom: 0.75rem;
}

/* Mobile Improvements */
@media (max-width: 480px) {
    .chips-container {
        padding: 0.5rem;
        gap: 0.375rem;
    }

    .chip {
        padding: 0.25rem 0.5rem;
        font-size: 0.6875rem;
    }

    .preset-btn {
        padding: 0.5rem;
    }

    .preset-btn .preset-label {
        font-size: 0.6875rem;
    }

    .preset-btn .preset-cron {
        font-size: 0.5625rem;
    }

    .toggle-group {
        flex-direction: column;
        gap: 0.5rem;
    }

    .toggle-btn:first-child,
    .toggle-btn:last-child {
        border-radius: 0.375rem;
        border-left: 1px solid var(--border);
    }

    .modal-body {
        padding: 1rem;
    }

    .form-group label {
        font-size: 0.875rem;
    }

    .prompt-preview {
        font-size: 0.75rem;
        padding: 0.75rem;
    }

    /* Improve button sizing on mobile */
    button {
        min-height: 2.75rem;
    }

    /* Better form input sizing */
    .form-group input,
    .form-group textarea,
    .form-group select {
        font-size: 1rem; /* Prevent zoom on focus on iOS */
    }
}

/* Ensure modal scrolls properly on mobile */
@media (max-height: 700px) {
    .modal-body {
        max-height: 60vh;
    }
}

/* Better touch targets */
@media (pointer: coarse) {
    .chip {
        min-height: 2.25rem;
        padding: 0.5rem 0.75rem;
    }

    .preset-btn {
        min-height: 3rem;
    }

    .toggle-btn {
        min-height: 2.5rem;
    }
}

/* Scrollable chips on mobile */
@media (max-width: 640px) {
    .chips-container {
        max-height: 150px;
        overflow-y: auto;
        overflow-x: hidden;
    }
}

/* Additional overflow prevention */
.modal *,
.modal-body * {
    max-width: 100%;
    box-sizing: border-box;
}

/* Ensure text areas and inputs stay within bounds */
textarea,
input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
input[type="datetime-local"] {
    max-width: 100%;
    box-sizing: border-box;
}

/* Task Info Section in Modal */
.task-info {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    padding: 1rem;
    margin-bottom: 1rem;
    background: var(--bg-deep);
    border: 1px solid var(--border);
    border-radius: 0.375rem;
    align-items: center;
}

.task-info-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.875rem;
}

.task-info-item .label {
    color: var(--text-secondary);
}

.task-info-item.task-actions {
    margin-left: auto;
}

/* Recurring and Scheduled Badges */
.recurring-badge,
.scheduled-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.25rem 0.5rem;
    border-radius: 0.25rem;
    font-family: 'Share Tech Mono', monospace;
    font-size: 0.75rem;
}

.recurring-badge {
    background: rgba(138, 139, 192, 0.2);
    color: var(--accent-light);
    border: 1px solid var(--accent-light);
}

.scheduled-badge {
    background: rgba(113, 114, 170, 0.2);
    color: var(--accent-primary);
    border: 1px solid var(--accent-primary);
}

/* Cancel Task Button */
.cancel-task-btn {
    padding: 0.375rem 0.75rem;
    font-size: 0.75rem;
    min-height: auto;
}

/* Table Schedule Column */
#tasksTable td:nth-child(4) {
    white-space: nowrap;
}

@media (max-width: 640px) {
    .task-info {
        flex-direction: column;
        align-items: flex-start;
    }

    .task-info-item.task-actions {
        margin-left: 0;
        margin-top: 0.5rem;
        width: 100%;
    }

    .cancel-task-btn {
        width: 100%;
    }
}

/* Custom Email Input */
.custom-email-row {
    display: flex;
    gap: 0.5rem;
    margin-top: 0.75rem;
}

.custom-email-row input {
    flex: 1;
    min-width: 0;
}

.custom-email-row button {
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
    white-space: nowrap;
}

@media (max-width: 480px) {
    .custom-email-row {
        flex-direction: column;
    }

    .custom-email-row button {
        width: 100%;
    }
}

/* Custom chip styling (removable) */
.chip-custom {
    position: relative;
}

.chip-custom .chip-delete {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin-left: 0.375rem;
    font-size: 0.875rem;
    opacity: 0.7;
    transition: opacity 0.2s;
}

.chip-custom:hover .chip-delete {
    opacity: 1;
}

/* Celebration animation for mascot */
@keyframes celebrate {
    0% { transform: scale(1) rotate(0deg); }
    25% { transform: scale(1.2) rotate(-10deg); }
    50% { transform: scale(1.2) rotate(10deg); }
    75% { transform: scale(1.1) rotate(-5deg); }
    100% { transform: scale(1) rotate(0deg); }
}

.mascot.celebrate {
    animation: celebrate 0.6s ease-out;
}

/* Toast Notification */
.toast {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    max-width: 400px;
    padding: 1rem 1.5rem;
    background: var(--bg-card);
    border: 2px solid var(--accent-primary);
    border-radius: 0.5rem;
    color: var(--text-primary);
    box-shadow: 0 0 30px rgba(113, 114, 170, 0.3);
    z-index: 10000;
    animation: slideInRight 0.3s ease-out;
}

.toast.success {
    border-color: var(--success);
    box-shadow: 0 0 30px rgba(80, 250, 123, 0.3);
}

.toast.error {
    border-color: var(--error);
    box-shadow: 0 0 30px rgba(255, 85, 85, 0.3);
}

.toast.warning {
    border-color: var(--warning);
    box-shadow: 0 0 30px rgba(255, 184, 108, 0.3);
}

.toast.toast-exit,
.toast.toast-exit:hover {
    animation: slideOutRight 0.3s ease-out forwards;
}

@keyframes slideInRight {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

@keyframes slideOutRight {
    from {
        transform: translateX(0);
        opacity: 1;
    }
    to {
        transform: translateX(100%);
        opacity: 0;
    }
}

/* Loading Overlay */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(13, 2, 33, 0.9);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
}

.loading-overlay.is-hidden {
    display: none;
}

.loading-overlay .loading-spinner {
    width: 4rem;
    height: 4rem;
}

/* Confirm Dialog */
.confirm-dialog {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    max-width: 500px;
    width: 90%;
    max-width: calc(100vw - 2rem);
    background: var(--bg-primary);
    border: 2px solid var(--accent-secondary);
    border-radius: 0.5rem;
    padding: 2rem;
    z-index: 10001;
    box-shadow: 0 0 50px rgba(89, 111, 124, 0.4);
    overflow-wrap: break-word;
    word-wrap: break-word;
}

.confirm-dialog-title {
    font-family: 'VT323', monospace;
    font-size: 1.5rem;
    color: var(--accent-primary);
    margin-bottom: 1rem;
    text-transform: uppercase;
}

.confirm-dialog-message {
    color: var(--text-primary);
    margin-bottom: 1.5rem;
    line-height: 1.6;
}

.confirm-dialog-buttons {
    display: flex;
    gap: 0.75rem;
    justify-content: flex-end;
}
