/* Base styles and variables */
:root {
    --bg-color: #ffffff;
    --text-color: #000000;
    --accent-color: #E24B4A; /* Red accent for [AI] */
}

body {
    margin: 0;
    padding: 0;
    font-size: 16px; /* Enforce min 16px for mobile */
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background-color: var(--bg-color);
    color: var(--text-color);
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
}

.container {
    text-align: center;
    padding: 2rem;
    max-width: 600px;
    width: 100%;
}

.logo {
    font-size: 2.5rem;
    font-weight: bold;
    margin-bottom: 1rem;
}

.logo .accent {
    color: var(--accent-color);
}

#challenge-container {
    margin-top: 2rem;
    display: flex;
    justify-content: center;
}

#path-canvas {
    border: 2px solid #eaeaea;
    border-radius: 12px;
    touch-action: none; /* Crucial for touch tracing, prevents scrolling */
    cursor: crosshair;
    background-color: #fafafa;
    box-shadow: 0 4px 6px rgba(0,0,0,0.05);
}

.challenge-section {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
}

/* === Slider Challenge === */
.slider-challenge-container {
    margin: 30px auto;
    width: 300px;
}

#slider-track {
    width: 100%;
    height: 40px;
    background: #2a2a2a;
    border-radius: 20px;
    position: relative;
    border: 2px solid var(--border-color);
}

#slider-target {
    position: absolute;
    height: 100%;
    width: 50px;
    background: rgba(0, 255, 128, 0.2);
    border: 2px dashed var(--accent-color);
    border-radius: 20px;
    top: -2px; /* offset border */
    box-sizing: border-box;
}

#slider-handle {
    position: absolute;
    width: 40px;
    height: 40px;
    background: var(--accent-color);
    border-radius: 50%;
    top: -2px;
    left: 0;
    cursor: grab;
    box-shadow: 0 0 10px rgba(0, 255, 128, 0.5);
    transition: background 0.2s;
}

#slider-handle:active {
    cursor: grabbing;
    background: #00cc66;
}

#tap-button {
    font-size: 1.5rem;
    padding: 1.5rem 3rem;
    min-height: 80px; /* Taller button for touch targets */
    border: none;
    border-radius: 8px;
    background-color: #111;
    color: white;
    cursor: pointer;
    touch-action: manipulation;
    user-select: none;
    width: 100%;
    max-width: 300px;
}

#tap-button:active {
    background-color: #333;
    transform: scale(0.95);
}

#start-rhythm-btn {
    font-size: 1.2rem;
    padding: 1rem 2rem;
    background-color: #4CAF50;
    color: white;
    border: none;
    border-radius: 6px;
    cursor: pointer;
}

.reading-container {
    max-width: 500px;
    margin: 2rem 0;
    text-align: left;
    background: #f9f9f9;
    padding: 1.5rem;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}

#reading-text {
    font-size: 1.1rem;
    line-height: 1.6;
    margin-bottom: 1.5rem;
}

#reading-question {
    font-size: 1.2rem;
    margin-bottom: 1rem;
}

.reading-option {
    display: block;
    width: 100%;
    padding: 1rem;
    margin-bottom: 0.8rem;
    font-size: 1rem;
    text-align: left;
    background-color: white;
    border: 1px solid #ccc;
    border-radius: 6px;
    cursor: pointer;
    transition: background-color 0.2s;
}

.reading-option:hover {
    background-color: #f0f0f0;
}

#honeypot {
    position: absolute;
    opacity: 0;
    top: -9999px;
    left: -9999px;
    z-index: -1;
    pointer-events: none;
}

/* Dashboard */
.dashboard-container {
    max-width: 800px;
}
.generate-section {
    background: #f9f9f9;
    padding: 2rem;
    border-radius: 8px;
    margin-bottom: 2rem;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 15px;
}
#label-input {
    padding: 0.8rem;
    font-size: 1rem;
    width: 250px;
    border: 1px solid #ccc;
    border-radius: 4px;
}
#generate-btn {
    padding: 0.8rem 1.5rem;
    font-size: 1rem;
    background-color: var(--text-color);
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
}
#generated-link-box {
    margin-top: 1rem;
    display: flex;
}
#generated-link {
    flex: 1;
    padding: 0.8rem;
    font-size: 1rem;
    border: 1px solid #ccc;
    border-radius: 4px 0 0 4px;
    background: #eee;
}
#copy-btn {
    padding: 0.8rem 1.5rem;
    background-color: var(--accent-color);
    color: white;
    border: none;
    border-radius: 0 4px 4px 0;
    cursor: pointer;
}

#dashboard-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 1rem;
}
#dashboard-table th, #dashboard-table td {
    border-bottom: 1px solid #eaeaea;
    padding: 1rem;
    text-align: left;
}
#dashboard-table th {
    background-color: #fafafa;
    font-weight: 600;
}
.badge {
    padding: 0.3rem 0.6rem;
    border-radius: 12px;
    font-size: 0.85rem;
    font-weight: bold;
    color: white;
}
.badge-human { background-color: #4CAF50; }
.badge-bot { background-color: #E24B4A; }
.badge-uncertain { background-color: #FF9800; }
.badge-pending { background-color: #9e9e9e; }

/* Result Page */
.result-container {
    max-width: 600px;
}
.verdict-box {
    padding: 3rem;
    border-radius: 12px;
    color: white;
    margin: 2rem 0;
    transition: background-color 0.3s;
}
.verdict-box.loading { background-color: #9e9e9e; }
.verdict-human { background-color: #4CAF50; }
.verdict-bot { background-color: #E24B4A; }
.verdict-uncertain { background-color: #FF9800; }

#verdict-title {
    font-size: 2.5rem;
    margin: 0 0 1rem 0;
}
#confidence-score {
    font-size: 1.5rem;
    font-weight: 300;
}

/* Breakdown Bars */
.bar-row {
    display: flex;
    align-items: center;
    margin-bottom: 1rem;
}
.bar-label {
    width: 80px;
    text-align: right;
    margin-right: 1rem;
    font-weight: 500;
}
.bar-track {
    flex: 1;
    height: 16px;
    background-color: #eee;
    border-radius: 8px;
    overflow: hidden;
}
.bar-fill {
    height: 100%;
    background-color: var(--text-color);
    transition: width 1s ease-out;
}
.bar-score {
    width: 40px;
    text-align: right;
    font-weight: bold;
}

#flags-section {
    margin-top: 2rem;
    text-align: left;
    background: #fff3f3;
    padding: 1.5rem;
    border-radius: 8px;
    border-left: 4px solid var(--accent-color);
}
#flags-section h3 {
    margin-top: 0;
    color: var(--accent-color);
}
#flags-list {
    margin: 0;
    padding-left: 1.5rem;
}
#flags-list li {
    margin-bottom: 0.5rem;
}

/* SPA View Management */
.view {
    display: none;
    flex-direction: column;
}
#view-dashboard {
    display: flex; /* default */
}

/* Toast Notifications */
#toast-container {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 1000;
}
.toast {
    background: #E24B4A;
    color: white;
    padding: 15px 25px;
    border-radius: 8px;
    margin-top: 10px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    transition: opacity 0.3s ease;
}

/* Auth Header */
#auth-header {
    position: absolute;
    top: 20px;
    right: 20px;
    display: flex;
    align-items: center;
    gap: 15px;
}
#auth-header button {
    padding: 8px 15px;
    font-size: 14px;
}

/* Options Row */
.options-row {
    display: flex;
    gap: 15px;
    margin-bottom: 15px;
    align-items: center;
}
.options-row select {
    padding: 10px;
    border-radius: 6px;
    border: 1px solid #ccc;
    font-size: 14px;
}
.alert-label {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 14px;
}

/* Physics Drag Challenge */
.physics-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 30px;
    margin-top: 20px;
}
.drag-items {
    display: flex;
    gap: 20px;
    font-size: 40px;
}
.draggable {
    cursor: grab;
    user-select: none;
    padding: 10px;
    background: white;
    border-radius: 10px;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
    transition: transform 0.1s;
    filter: url(#adversarial-noise); /* Applies high-frequency noise that confuses CV models */
}
.draggable:active {
    cursor: grabbing;
}
.drop-zone {
    width: 250px;
    height: 100px;
    border: 3px dashed #ccc;
    border-radius: 10px;
    display: flex;
    justify-content: center;
    align-items: center;
    color: #888;
    font-weight: bold;
    letter-spacing: 2px;
    transition: background 0.2s, border-color 0.2s;
}
.drop-zone.drag-over {
    background: rgba(226, 75, 74, 0.1);
    border-color: #E24B4A;
}

/* Timer Group */
.timer-group {
    display: flex;
    align-items: center;
    gap: 5px;
}
.timer-group select {
    padding: 10px;
    border-radius: 6px;
    border: 1px solid #ccc;
    font-size: 14px;
}

/* Auth Input */
.auth-input {
    width: 100%;
    padding: 10px;
    margin-bottom: 10px;
    border: 1px solid #ccc;
    border-radius: 6px;
    box-sizing: border-box;
}

/* Mobile responsive adjustments */
@media (max-width: 600px) {
    .options-row {
        flex-direction: column;
        align-items: stretch;
    }
}

/* Feedback UI */
.feedback-float-btn {
    position: fixed;
    bottom: 20px;
    left: 20px;
    background-color: var(--text-color);
    color: white;
    padding: 10px 20px;
    border: none;
    border-radius: 20px;
    cursor: pointer;
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
    z-index: 999;
}

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

.modal-content {
    background: rgba(25, 25, 25, 0.85);
    backdrop-filter: blur(12px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: #e0e0e0;
    padding: 2.5rem;
    border-radius: 16px;
    width: 90%;
    max-width: 400px;
    display: flex;
    flex-direction: column;
    gap: 15px;
    box-sizing: border-box;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.4), 0 0 0 1px rgba(255, 255, 255, 0.05) inset;
}

.modal-content h2 {
    margin-top: 0;
    margin-bottom: 5px;
    font-size: 1.5rem;
    color: #fff;
    text-align: center;
}

.modal-content textarea {
    width: 100%;
    padding: 12px 15px;
    background: #121212;
    color: #fff;
    border: 1px solid #333;
    border-radius: 8px;
    font-family: inherit;
    font-size: 1rem;
    resize: vertical;
    box-sizing: border-box;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.auth-input {
    width: 100%;
    padding: 12px 15px;
    background: #121212;
    color: #fff;
    border: 1px solid #333;
    border-radius: 8px;
    font-family: inherit;
    font-size: 1rem;
    box-sizing: border-box;
    resize: none !important;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.modal-content textarea:focus, .auth-input:focus {
    outline: none;
    border-color: var(--accent-color);
    box-shadow: 0 0 8px rgba(226, 75, 74, 0.3);
}

.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}

.center-actions {
    justify-content: center;
}

.close-btn {
    position: absolute !important;
    top: 15px !important;
    right: 15px !important;
    background: transparent !important;
    color: #888 !important;
    border: none !important;
    font-size: 1.5rem !important;
    cursor: pointer !important;
    line-height: 1 !important;
    padding: 0 !important;
    width: auto !important;
    min-width: unset !important;
    height: auto !important;
    min-height: unset !important;
    transition: color 0.2s;
    appearance: none !important;
    -webkit-appearance: none !important;
}

.close-btn:hover {
    color: #fff !important;
}

.password-toggle {
    top: 50%;
    transform: translateY(-50%);
    background: transparent;
    border: none;
    cursor: pointer;
    font-size: 1.2rem;
    opacity: 0.6;
    padding: 0;
    line-height: 1;
}

.password-toggle:hover {
    opacity: 1;
}

.btn-primary {
    background: var(--accent-color);
    color: white;
    border: none;
    padding: 12px 20px;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.1s, opacity 0.2s;
}

.btn-primary:hover {
    opacity: 0.9;
}

.btn-primary:active {
    transform: scale(0.97);
}

.btn-secondary {
    background: #333;
    color: #e0e0e0;
    border: 1px solid #444;
    padding: 12px 20px;
    border-radius: 8px;
    font-size: 1rem;
    cursor: pointer;
    transition: background 0.2s;
}

.btn-secondary:hover {
    background: #444;
}
