/* ===== Iris Theme ===== */
/* Primary: Purple #5638B8 | Accent: Violet #7754ED | Highlight: Blue #65B7FF */

:root,
[data-theme="dark"] {
    /* Brand Colors */
    --iris-purple: #5638B8;
    --iris-purple-light: #7754ED;
    --iris-purple-dark: #4A31A3;
    --iris-blue: #65B7FF;
    --iris-blue-light: #56B9FF;
    --iris-navy: #08092D;

    /* Neutral Colors */
    --ff-white: #ffffff;
    --ff-gray-50: #f8f9fa;
    --ff-gray-100: #f1f3f5;
    --ff-gray-200: #e9ecef;
    --ff-gray-300: #dee2e6;
    --ff-gray-400: #ced4da;
    --ff-gray-500: #adb5bd;
    --ff-gray-600: #6c757d;
    --ff-gray-700: #495057;
    --ff-gray-800: #343a40;
    --ff-gray-900: #212529;

    /* Semantic Colors */
    --ff-success: #28a745;
    --ff-success-light: #d4edda;
    --ff-warning: #ffc107;
    --ff-warning-light: #fff3cd;
    --ff-danger: #dc3545;
    --ff-danger-light: #f8d7da;
    --ff-info: #17a2b8;
    --ff-info-light: #d1ecf1;

    /* Semantic surface tokens (dark) */
    --surface-bg:         #08092D;
    --surface-bg-raised:  #4A31A3;
    --surface-bg-inset:   #0d0f3a;
    --on-surface:         #ffffff;
    --on-surface-muted:   #adb5bd;
    --accent:             #65B7FF;
    --accent-hover:       #56B9FF;
    --accent-dark:        #4a9de8;
    --border-subtle:      rgba(255,255,255,0.1);
    --border-accent:      #7754ED;
    --badge-ai-bg:        #4A31A3;
    --badge-human-bg:     #28a745;
    --gate-banner-bg:     #3a2080;
    --gate-banner-border: #7754ED;
    --gate-banner-text:   #e0d8ff;
    --required-star:      #65B7FF;
}

[data-theme="light"] {
    --iris-purple: #5638B8;
    --iris-purple-light: #7754ED;
    --iris-purple-dark: #4A31A3;
    --iris-blue: #4a9de8;
    --iris-blue-light: #65B7FF;
    --iris-navy: #08092D;

    --ff-white: #ffffff;
    --ff-gray-50: #f8f9fa;
    --ff-gray-100: #f1f3f5;
    --ff-gray-200: #e9ecef;
    --ff-gray-300: #dee2e6;
    --ff-gray-400: #ced4da;
    --ff-gray-500: #adb5bd;
    --ff-gray-600: #6c757d;
    --ff-gray-700: #495057;
    --ff-gray-800: #343a40;
    --ff-gray-900: #212529;

    --ff-success: #155724;
    --ff-success-light: #d4edda;
    --ff-warning: #856404;
    --ff-warning-light: #fff3cd;
    --ff-danger: #dc3545;
    --ff-danger-light: #f8d7da;
    --ff-info: #0c5460;
    --ff-info-light: #d1ecf1;

    /* Semantic surface tokens (light) */
    --surface-bg:         #f0eeff;
    --surface-bg-raised:  #ffffff;
    --surface-bg-inset:   #e5dff8;
    --on-surface:         #08092D;
    --on-surface-muted:   #6c757d;
    --accent:             #5638B8;
    --accent-hover:       #7754ED;
    --accent-dark:        #4A31A3;
    --border-subtle:      rgba(0,0,0,0.1);
    --border-accent:      #5638B8;
    --badge-ai-bg:        #e5dff8;
    --badge-human-bg:     #d4edda;
    --gate-banner-bg:     #ede8ff;
    --gate-banner-border: #7754ED;
    --gate-banner-text:   #3a2080;
    --required-star:      #5638B8;
}

/* ===== Base Layout ===== */

* {
    box-sizing: border-box;
}

body {
    font-family: "Segoe UI", -apple-system, BlinkMacSystemFont, Roboto, sans-serif;
    margin: 0;
    padding: 0;
    background: linear-gradient(135deg, var(--iris-navy) 0%, var(--iris-purple-dark) 100%);
    color: var(--ff-white);
    min-height: 100vh;
}

/* ===== Header ===== */

.app-header {
    background: linear-gradient(135deg, var(--iris-navy) 0%, var(--iris-purple) 100%);
    color: var(--ff-white);
    padding: 16px;
    margin: 0;
    display: flex;
    align-items: center;
    gap: 10px;
    box-shadow: 0 2px 8px rgba(8, 9, 45, 0.3);
}

h3 {
    margin: 0;
    padding: 16px;
    font-size: 18px;
    font-weight: 600;
    color: var(--ff-white);
    display: flex;
    align-items: center;
    gap: 8px;
    background: linear-gradient(135deg, var(--iris-navy) 0%, var(--iris-purple) 100%);
    box-shadow: 0 2px 8px rgba(8, 9, 45, 0.3);
}

h3::before {
    content: "";
    display: inline-block;
    width: 4px;
    height: 20px;
    background: var(--iris-blue);
    border-radius: 2px;
}

/* ===== Main Content ===== */

.content-wrapper {
    padding: 16px;
}

/* ===== Status Block ===== */

#status {
    display: none !important;
}

#status.status-error {
    display: none !important;
}

.muted {
    display: none !important;
}

/* ===== Analysis Container ===== */

#analysisContainer {
    background: var(--iris-purple-dark);
    padding: 0;
    border-radius: 10px;
    margin: 16px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
    max-height: calc(100vh - 200px);
    overflow-y: auto;
    overflow-x: hidden;
}

#analysisContainer:empty {
    display: none;
}

#analysisContainer pre.pre {
    max-width: 100%;
    overflow-x: auto;
    white-space: pre;
    background: var(--iris-navy);
    padding: 10px;
    border-radius: 6px;
    font-size: 12px;
    margin: 4px 0 0 0;
    color: var(--ff-white);
}

/* ===== Data Rows ===== */

.row {
    padding: 14px 16px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    transition: background-color 0.15s ease;
}

.row:last-child {
    border-bottom: none;
}

.row:hover {
    background: var(--iris-navy);
}

.label {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--iris-blue);
    margin-bottom: 6px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.label::before {
    content: "";
    display: inline-block;
    width: 3px;
    height: 12px;
    background: var(--iris-blue);
    border-radius: 2px;
}

.value {
    font-size: 14px;
    color: var(--ff-white);
    white-space: pre-wrap;
    word-break: break-word;
    line-height: 1.5;
}

/* ===== Primary Button ===== */

button, .btn {
    background: linear-gradient(135deg, var(--iris-purple) 0%, var(--iris-purple-dark) 100%);
    color: var(--ff-white);
    border: none;
    padding: 12px 20px;
    font-size: 14px;
    font-weight: 600;
    border-radius: 8px;
    cursor: pointer;
    width: 100%;
    transition: all 0.2s ease;
    box-shadow: 0 2px 8px rgba(86, 56, 184, 0.3);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

button:hover, .btn:hover {
    background: linear-gradient(135deg, var(--iris-purple-light) 0%, var(--iris-purple) 100%);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(119, 84, 237, 0.4);
}

button:active, .btn:active {
    transform: translateY(0);
}

button:disabled, .btn:disabled {
    background: var(--ff-gray-400);
    cursor: not-allowed;
    box-shadow: none;
    transform: none;
}

/* ===== Secondary Button ===== */

.btn-secondary {
    background: var(--ff-white);
    color: var(--iris-purple);
    border: 2px solid var(--iris-purple);
    box-shadow: none;
}

.btn-secondary:hover {
    background: var(--iris-purple);
    color: var(--ff-white);
    box-shadow: 0 2px 8px rgba(86, 56, 184, 0.2);
}

.btn-secondary:disabled {
    background: var(--ff-gray-100);
    border-color: var(--ff-gray-400);
    color: var(--ff-gray-500);
}

/* ===== Actions Section ===== */

#actions {
    padding: 0 16px 16px 16px;
}

/* ===== Panel / Card Styling ===== */

.panel {
    background: var(--iris-purple-dark);
    border-radius: 10px;
    margin: 16px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
    overflow: hidden;
}

/* ===== Category Section ===== */

#categorySection {
    margin: 16px;
    background: var(--iris-purple-dark);
    border-radius: 10px;
    padding: 16px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.section-header {
    font-size: 13px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 16px;
    color: var(--iris-blue);
    padding-bottom: 10px;
    border-bottom: 2px solid var(--iris-blue);
    display: flex;
    align-items: center;
    gap: 8px;
}

.section-header::before {
    content: "??";
    font-size: 14px;
}

.form-group {
    margin-bottom: 14px;
}

.form-group label {
    display: block;
    font-size: 12px;
    font-weight: 600;
    color: var(--ff-white);
    margin-bottom: 6px;
}

.form-select,
.form-input {
    width: 100%;
    padding: 10px 14px;
    font-size: 14px;
    border: 2px solid var(--iris-purple-light);
    border-radius: 8px;
    background: var(--iris-navy);
    color: var(--ff-white);
    transition: all 0.2s ease;
}

.form-select:focus,
.form-input:focus {
    outline: none;
    border-color: var(--iris-blue);
    box-shadow: 0 0 0 3px rgba(101, 183, 255, 0.3);
}

.form-select:hover,
.form-input:hover {
    border-color: var(--iris-blue);
}

/* ===== History Section ===== */

#historySection {
    margin: 16px;
    background: var(--iris-purple-dark);
    border-radius: 10px;
    padding: 16px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

#historySection .section-header::before {
    content: "??";
}

#historyContainer {
    max-height: 150px;
    overflow-y: auto;
}

.history-item {
    padding: 10px 12px;
    margin-bottom: 8px;
    background: var(--iris-navy);
    border-radius: 6px;
    border-left: 3px solid var(--iris-blue);
    font-size: 12px;
    transition: all 0.15s ease;
    color: var(--ff-white);
}

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

.history-item:hover {
    background: #060720;
    border-left-color: var(--iris-blue);
}

.history-category {
    font-weight: 700;
    color: var(--iris-blue);
    font-size: 13px;
}

.history-meta {
    color: var(--ff-gray-400);
    margin-top: 4px;
    font-size: 11px;
}

/* ===== Classification Badges ===== */

.classification-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    margin-right: 8px;
}

.badge-ai {
    background: linear-gradient(135deg, var(--iris-purple-dark) 0%, var(--iris-purple) 100%);
    color: var(--ff-white);
}

.badge-ai::before {
    content: "??";
    font-size: 10px;
}

.badge-human {
    background: linear-gradient(135deg, var(--ff-success) 0%, #1e7e34 100%);
    color: var(--ff-white);
}

.badge-human::before {
    content: "??";
    font-size: 10px;
}

/* ===== Confidence Badges ===== */

.confidence-badge {
    display: inline-block;
    padding: 3px 8px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 600;
    margin-left: 6px;
}

.confidence-high {
    background: var(--ff-success-light);
    color: var(--ff-success);
    border: 1px solid var(--ff-success);
}

.confidence-medium {
    background: var(--ff-warning-light);
    color: #856404;
    border: 1px solid var(--ff-warning);
}

.confidence-low {
    background: var(--ff-danger-light);
    color: var(--ff-danger);
    border: 1px solid var(--ff-danger);
}

/* ===== Scrollbar Styling ===== */

::-webkit-scrollbar {
    width: 6px;
}

::-webkit-scrollbar-track {
    background: var(--iris-navy);
    border-radius: 3px;
}

::-webkit-scrollbar-thumb {
    background: var(--iris-purple);
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--iris-purple-light);
}

/* ===== Loading Animation ===== */

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

.loading {
    animation: pulse 1.5s ease-in-out infinite;
}

/* ===== Responsive Adjustments ===== */

@media (max-width: 320px) {
    h3 {
        font-size: 16px;
        padding: 12px;
    }

    .row {
        padding: 12px;
    }

    #categorySection,
    #historySection {
        margin: 12px;
        padding: 12px;
    }
}

/* ===== Gate Banner ===== */

.gate-banner {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    margin: 12px 16px;
    padding: 12px 14px;
    background: var(--gate-banner-bg);
    border: 1px solid var(--gate-banner-border);
    border-radius: 8px;
    color: var(--gate-banner-text);
    font-size: 13px;
    line-height: 1.5;
}

.gate-banner .gate-icon {
    font-size: 16px;
    flex-shrink: 0;
    margin-top: 1px;
}

.gate-banner-text {
    flex: 1;
}

.gate-pending-list {
    margin: 6px 0 0 0;
    padding: 0 0 0 16px;
    font-size: 12px;
}

/* ===== Required Field Indicator ===== */

.field-required::after {
    content: " *";
    color: var(--required-star);
    font-weight: 700;
}

.form-input.field-error,
.form-select.field-error {
    border-color: var(--ff-danger);
    box-shadow: 0 0 0 2px rgba(220, 53, 69, 0.25);
}

.field-error-msg {
    color: var(--ff-danger);
    font-size: 11px;
    margin-top: 4px;
}

/* ===== Action Panel ===== */

#actionPanel {
    margin: 16px;
    background: var(--surface-bg-raised);
    border-radius: 10px;
    padding: 16px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.2);
}

.action-block {
    margin-bottom: 14px;
}

.action-block:last-child {
    margin-bottom: 0;
}

/* Pill button group (mark status) */

.pill-group {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.pill-btn {
    flex: 1;
    padding: 8px 12px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    border: 2px solid var(--border-accent);
    background: transparent;
    color: var(--on-surface);
    transition: all 0.15s ease;
    text-transform: none;
    letter-spacing: 0;
    box-shadow: none;
    width: auto;
}

.pill-btn.active,
.pill-btn:hover {
    background: var(--accent);
    color: var(--ff-white);
    border-color: var(--accent);
}

/* Tag input */

.tag-input-wrapper {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    padding: 8px 10px;
    border: 2px solid var(--border-accent);
    border-radius: 8px;
    background: var(--surface-bg-inset);
    min-height: 42px;
    cursor: text;
}

.tag-chip {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 8px 2px 10px;
    background: var(--accent);
    color: var(--ff-white);
    border-radius: 12px;
    font-size: 12px;
    font-weight: 600;
}

.tag-chip-remove {
    cursor: pointer;
    font-size: 14px;
    line-height: 1;
    opacity: 0.8;
}

.tag-chip-remove:hover {
    opacity: 1;
}

.tag-text-input {
    flex: 1;
    min-width: 80px;
    border: none;
    background: transparent;
    color: var(--on-surface);
    font-size: 13px;
    outline: none;
}

/* Toggle switch */

.toggle-pair {
    display: flex;
    gap: 10px;
    align-items: center;
}

.toggle-label {
    display: flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
    font-size: 13px;
    color: var(--on-surface);
}

.toggle-label input[type="checkbox"] {
    width: 16px;
    height: 16px;
    accent-color: var(--accent);
    cursor: pointer;
}

/* ===== Submit Row ===== */

.submit-row {
    padding: 0 16px 20px 16px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.required-hint {
    font-size: 11px;
    color: var(--on-surface-muted);
    text-align: center;
}

/* ===== Automated mode notice ===== */

.automated-notice {
    margin: 20px 16px;
    padding: 16px;
    background: var(--surface-bg-raised);
    border-radius: 10px;
    border-left: 4px solid var(--accent);
    color: var(--on-surface-muted);
    font-size: 13px;
    line-height: 1.6;
}

.automated-notice strong {
    display: block;
    color: var(--on-surface);
    margin-bottom: 6px;
    font-size: 14px;
}

/* ===== Theme Toggle Button ===== */

.btn-icon {
    background: transparent;
    border: none;
    color: var(--on-surface);
    padding: 6px 8px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 16px;
    margin-left: auto;
    width: auto;
    box-shadow: none;
    text-transform: none;
    letter-spacing: 0;
    transition: background 0.15s ease;
}

.btn-icon:hover {
    background: var(--border-subtle);
    transform: none;
    box-shadow: none;
}

/* ===== Workflow Status Timeline ===== */

.status-timeline {
    display: flex;
    align-items: center;
    gap: 4px;
    flex-wrap: wrap;
    margin-top: 4px;
}

.status-chip {
    padding: 3px 10px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 600;
    background: var(--surface-bg-inset);
    color: var(--on-surface-muted);
    border: 1px solid var(--border-subtle);
}

.status-chip.active {
    background: var(--accent);
    color: var(--ff-white);
    border-color: var(--accent);
}

.status-divider {
    color: var(--on-surface-muted);
    font-size: 10px;
}

/* ===== Read-only overlay on optional elements in read-only mode ===== */

.mode-readonly {
    pointer-events: none;
    opacity: 0.7;
    cursor: default;
}

/* ===== Light mode body overrides ===== */

[data-theme="light"] body {
    background: var(--surface-bg);
    color: var(--on-surface);
}

[data-theme="light"] .row:hover {
    background: var(--surface-bg-inset);
}

[data-theme="light"] #analysisContainer,
[data-theme="light"] .panel,
[data-theme="light"] #categorySection,
[data-theme="light"] #historySection {
    background: var(--surface-bg-raised);
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
}

[data-theme="light"] .label {
    color: var(--accent);
}

[data-theme="light"] .label::before {
    background: var(--accent);
}

[data-theme="light"] .value {
    color: var(--on-surface);
}

[data-theme="light"] .history-item {
    background: var(--surface-bg-inset);
    color: var(--on-surface);
}

[data-theme="light"] .form-select,
[data-theme="light"] .form-input {
    background: var(--surface-bg-raised);
    color: var(--on-surface);
    border-color: var(--accent);
}

[data-theme="light"] h3 {
    background: linear-gradient(135deg, var(--iris-purple) 0%, var(--iris-purple-dark) 100%);
    color: var(--ff-white);
}

