/* ===========================
   Noise Monitor - Styles
   =========================== */

/* --- Root Container --- */
.vnl-wrapper {
    zoom: 1.25;

    --vnl-bg: #fff;
    --vnl-text: #1e293b;
    --vnl-calm: #10b981;
    --vnl-warn: #f59e0b;
    --vnl-loud: #ef4444;
    --vnl-font: 'Inter', system-ui, -apple-system, sans-serif;
    --vnl-header-from: #166534;
    --vnl-header-to: #047857;
    --vnl-radius: 16px;
    --vnl-surface: #f8fafc;

    font-family: var(--vnl-font);
    background: var(--vnl-bg);
    border: 1px solid #e2e8f0;
    border-radius: var(--vnl-radius);
    max-width: 800px;
    margin: 20px auto;
    overflow: hidden;
    position: relative;
    color: var(--vnl-text);
    box-shadow: 0 20px 40px -8px rgba(0, 0, 0, 0.18), 0 4px 12px rgba(0,0,0,0.08);
    height: 600px;
    display: flex;
    flex-direction: column;
}

.vnl-wrapper:fullscreen {
    max-width: 100%;
    height: 100vh;
    border-radius: 0;
    border: none;
}

/* --- Header --- */
.vnl-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 11px 20px;
    background: linear-gradient(135deg, var(--vnl-header-from), var(--vnl-header-to));
    border-bottom: none;
    z-index: 20;
}

.vnl-header-left {
    display: flex;
    align-items: center;
    gap: 10px;
}

.vnl-title {
    margin: 0;
    font-size: 1rem;
    font-weight: 700;
    color: rgba(255, 255, 255, 0.95);
    letter-spacing: 0.01em;
}

.vnl-icon-btn {
    background: rgba(255, 255, 255, 0.15);
    border: 1px solid rgba(255, 255, 255, 0.25);
    border-radius: 8px;
    cursor: pointer;
    color: rgba(255, 255, 255, 0.9);
    padding: 5px 7px;
    transition: background 0.15s;
    line-height: 0;
}

.vnl-icon-btn:hover {
    background: rgba(255, 255, 255, 0.28);
    color: white;
}

/* --- Class Chip (header, shown during monitoring) --- */
.vnl-class-chip {
    background: rgba(255, 255, 255, 0.2);
    border: 1px solid rgba(255, 255, 255, 0.35);
    color: white;
    font-size: 0.75rem;
    font-weight: 600;
    padding: 3px 10px;
    border-radius: 30px;
    letter-spacing: 0.02em;
    white-space: nowrap;
    max-width: 180px;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* --- Views --- */
.vnl-view {
    display: none;
    flex: 1;
    position: relative;
    width: 100%;
    height: 100%;
    min-height: 0;
}

.vnl-view.active {
    display: flex;
    flex-direction: column;
}

/* --- Start Screen --- */
#vnl-view-start {
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 20px;
    gap: 14px;
    overflow-y: auto;
    background: linear-gradient(160deg, #f0f4ff 0%, #f8f6ff 60%, #fafafa 100%);
}

.vnl-permission-card {
    background: white;
    padding: 36px 40px 32px;
    border-radius: 20px;
    box-shadow: 0 8px 30px rgba(4, 120, 87, 0.15), 0 2px 8px rgba(0,0,0,0.06);
    max-width: 400px;
    border-top: 4px solid;
    border-image: linear-gradient(90deg, #166534, #047857) 1;
    border-top-left-radius: 20px;
    border-top-right-radius: 20px;
}

.vnl-permission-card h3 {
    font-size: 1.2rem;
    color: var(--vnl-text);
    margin: 0 0 6px;
}

.vnl-permission-card p {
    font-size: 0.875rem;
    color: #64748b;
    margin: 0;
}

.vnl-emoji-hero {
    font-size: 3.8rem;
    margin-bottom: 12px;
    animation: vnl-wave 2s infinite;
    filter: drop-shadow(0 4px 12px rgba(4, 120, 87, 0.25));
    display: block;
}

.vnl-btn-primary {
    background: linear-gradient(135deg, #166534, #047857);
    color: white;
    border: none;
    padding: 13px 32px;
    border-radius: 50px;
    font-weight: 700;
    font-size: 1rem;
    cursor: pointer;
    margin-top: 20px;
    letter-spacing: 0.02em;
    box-shadow: 0 4px 14px rgba(4, 120, 87, 0.35);
    transition: transform 0.15s, box-shadow 0.15s;
}

.vnl-btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(4, 120, 87, 0.45);
}

/* --- Class Row (start screen) --- */
.vnl-class-row {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 6px;
    margin-top: 16px;
    text-align: left;
    width: 100%;
}

.vnl-class-row label {
    font-size: 0.8rem;
    font-weight: 700;
    color: #475569;
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

.vnl-class-select {
    width: 100%;
    padding: 8px 10px;
    border: 1.5px solid #cbd5e0;
    border-radius: 8px;
    font-size: 0.875rem;
    background: white;
    cursor: pointer;
    transition: border-color 0.15s, box-shadow 0.15s;
    font-family: var(--vnl-font);
    color: var(--vnl-text);
}

.vnl-class-select:focus {
    outline: none;
    border-color: #166534;
    box-shadow: 0 0 0 3px rgba(4, 120, 87, 0.12);
}

.vnl-class-new-input {
    width: 100%;
    padding: 8px 10px;
    border: 1.5px solid #cbd5e0;
    border-radius: 8px;
    font-size: 0.875rem;
    box-sizing: border-box;
    font-family: var(--vnl-font);
    transition: border-color 0.15s, box-shadow 0.15s;
}

.vnl-class-new-input:focus {
    outline: none;
    border-color: #166534;
    box-shadow: 0 0 0 3px rgba(4, 120, 87, 0.12);
}

/* --- Class History Panel (start screen) --- */
.vnl-history-panel {
    background: white;
    border: 1px solid #e2e8f0;
    border-left: 3px solid #047857;
    border-radius: 12px;
    padding: 10px 16px;
    width: 100%;
    max-width: 400px;
    box-sizing: border-box;
    text-align: left;
    font-size: 0.875rem;
    box-shadow: 0 2px 10px rgba(0,0,0,0.06);
}

.vnl-history-panel summary {
    cursor: pointer;
    font-weight: 700;
    font-size: 0.875rem;
    color: #1e293b;
    list-style: none;
    padding: 2px 0;
}

.vnl-history-panel summary::-webkit-details-marker { display: none; }
.vnl-history-panel summary::before { content: '▶ '; font-size: 0.75rem; color: #047857; }
.vnl-history-panel[open] summary::before { content: '▼ '; font-size: 0.75rem; color: #047857; }

.vnl-history-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 8px;
    font-size: 0.875rem;
}

.vnl-history-table th {
    text-align: left;
    font-weight: 700;
    color: #94a3b8;
    padding: 3px 6px;
    border-bottom: 1px solid #e2e8f0;
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

.vnl-history-table td {
    padding: 5px 6px;
    color: #334155;
    border-bottom: 1px solid #f1f5f9;
    vertical-align: middle;
}

.vnl-history-table tr:last-child td {
    border-bottom: none;
}

.vnl-history-empty {
    color: #94a3b8;
    font-size: 0.875rem;
    margin: 8px 0 2px;
}

/* --- Grade Badge (history table) --- */
.vnl-grade-badge {
    display: inline-block;
    font-size: 0.7rem;
    font-weight: 800;
    padding: 2px 7px;
    border-radius: 20px;
    line-height: 1.4;
    letter-spacing: 0.03em;
}

.vnl-grade-badge.grade-a { background: #d1fae5; color: #065f46; }
.vnl-grade-badge.grade-b { background: #dcfce7; color: #166534; }
.vnl-grade-badge.grade-c { background: #fef9c3; color: #854d0e; }
.vnl-grade-badge.grade-d { background: #ffedd5; color: #9a3412; }
.vnl-grade-badge.grade-f { background: #fee2e2; color: #991b1b; }

/* --- Monitor Stage --- */
.vnl-stage {
    flex: 1;
    position: relative;
    background: #dde3ef;
    display: flex;
    flex-direction: row;
    overflow: hidden;
    transition: background 0.3s;
    min-height: 0;
}

.vnl-stage.stage-warn {
    background: #fde9cd;
}

.vnl-stage.stage-loud {
    background: #fdd5d5;
}

/* --- Left Cards Panel --- */
.vnl-cards-panel {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 150px;
    flex-shrink: 0;
    padding: 12px 10px;
    gap: 8px;
    box-sizing: border-box;
    overflow-y: auto;
}

.vnl-stat-card {
    background: rgba(255, 255, 255, 0.85);
    border-radius: 12px;
    padding: 8px 10px;
    width: 100%;
    text-align: center;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.12);
    box-sizing: border-box;
    border-left: 3px solid transparent;
}

.vnl-stat-card.active .vnl-stat-value {
    color: var(--vnl-loud);
}

/* Grade card — teal accent */
#vnl-score-display {
    border-left-color: #0f766e;
}

/* Streak card — green accent */
#vnl-streak-display {
    border-left-color: var(--vnl-calm);
}

/* Over-limit card — always red accent */
#vnl-over-limit {
    border-left-color: var(--vnl-loud);
}

.vnl-stat-label {
    display: block;
    font-size: 0.7rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: #475569;
    margin-bottom: 2px;
}

.vnl-stat-value {
    display: block;
    font-size: 1.5rem;
    font-weight: 700;
    color: #1e293b;
    line-height: 1.2;
}

/* --- Emoji --- */
.vnl-emoji-main {
    font-size: 4rem;
    margin-bottom: 4px;
    filter: drop-shadow(0 4px 10px rgba(0, 0, 0, 0.15));
    transition: transform 0.1s;
    flex-shrink: 0;
    line-height: 1;
}

/* --- Meter Bar Panel --- */
.vnl-bar-panel {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 72px;
    flex-shrink: 0;
    padding: 12px 8px 8px;
    box-sizing: border-box;
}

/* --- Volume Meter --- */
.vnl-meter-container {
    width: 56px;
    flex: 1;
    position: relative;
    z-index: 1;
    min-height: 0;
}

.vnl-meter-bg {
    width: 100%;
    height: 100%;
    background: rgba(255, 255, 255, 0.35);
    border: 1px solid rgba(0, 0, 0, 0.08);
    border-radius: 6px;
    position: relative;
    overflow: hidden;
}

.vnl-meter-fill {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 0%;
    transition: height 0.1s ease-out, background-color 0.3s;
    opacity: 0.85;
    border-radius: 4px 4px 0 0;
}

.vnl-fill-calm {
    background-color: var(--vnl-calm);
    box-shadow: 0 0 20px var(--vnl-calm);
}

.vnl-fill-warn {
    background-color: var(--vnl-warn);
    box-shadow: 0 0 20px var(--vnl-warn);
}

/* --- Limit Line --- */
.vnl-limit-line {
    position: absolute;
    bottom: 70%;
    left: 0;
    width: 100%;
    height: 2px;
    background: #1e293b;
    z-index: 10;
    pointer-events: none;
}

.vnl-limit-line span {
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    bottom: 3px;
    font-size: 0.6rem;
    font-weight: 800;
    background: #1e293b;
    color: white;
    padding: 2px 4px;
    border-radius: 3px;
    white-space: nowrap;
    letter-spacing: 0.04em;
}

/* --- Right Graph Panel --- */
.vnl-graph-panel {
    flex: 1;
    display: flex;
    flex-direction: column;
    padding: 10px 12px 10px 4px;
    min-width: 0;
}

#vnl-graph {
    flex: 1;
    width: 100%;
    background: rgba(255, 255, 255, 0.5);
    border-radius: 12px;
    border: 1px solid rgba(0, 0, 0, 0.07);
    display: block;
    min-height: 0;
    box-shadow: inset 0 1px 4px rgba(0,0,0,0.04);
}

/* --- Alarm Overlay --- */
.vnl-alarm-overlay {
    position: absolute;
    inset: 0;
    background: rgba(220, 38, 38, 0.9);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 50;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.1s;
    backdrop-filter: blur(4px);
}

.vnl-alarm-overlay.active {
    opacity: 1;
    pointer-events: auto;
    animation: vnl-flash 0.5s infinite;
}

.vnl-alarm-content {
    text-align: center;
    color: white;
    transform: scale(0.8);
    transition: transform 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.vnl-alarm-overlay.active .vnl-alarm-content {
    transform: scale(1);
}

.vnl-alarm-emoji {
    font-size: 3rem;
    line-height: 1;
    margin-bottom: 4px;
    animation: vnl-alarm-emoji-spin 1s ease-in-out infinite alternate;
}

@keyframes vnl-alarm-emoji-spin {
    from { transform: rotate(-12deg) scale(1); }
    to   { transform: rotate(12deg) scale(1.15); }
}

.vnl-alarm-content h2 {
    font-size: 2.5rem;
    margin: 0;
    text-transform: uppercase;
    font-weight: 900;
    letter-spacing: 4px;
    text-shadow: 0 2px 12px rgba(0,0,0,0.3);
}

/* --- Controls --- */
.vnl-controls {
    background: white;
    padding: 12px 20px;
    border-top: 1px solid #e2e8f0;
    display: flex;
    gap: 20px;
    align-items: center;
    justify-content: space-between;
    z-index: 20;
    box-shadow: 0 -2px 10px rgba(0,0,0,0.05);
}

.vnl-control-group {
    flex: 1;
    display: flex;
    flex-direction: column;
}

.vnl-control-group label {
    font-size: 0.75rem;
    font-weight: 700;
    color: #64748b;
    margin-bottom: 5px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    display: flex;
    align-items: center;
    gap: 6px;
}

/* Live slider value badge */
.vnl-slider-val {
    background: #d1fae5;
    color: #065f46;
    font-size: 0.7rem;
    font-weight: 700;
    padding: 1px 6px;
    border-radius: 20px;
    letter-spacing: 0;
    line-height: 1.6;
}

.vnl-wrapper input[type="range"] {
    width: 100%;
    accent-color: #166534;
    cursor: pointer;
}

.vnl-btn-secondary {
    background: #f1f5f9;
    border: 1px solid #e2e8f0;
    padding: 8px 16px;
    border-radius: 8px;
    color: #334155;
    font-weight: 600;
    font-size: 0.875rem;
    cursor: pointer;
    transition: background 0.15s, color 0.15s, border-color 0.15s;
    font-family: var(--vnl-font);
    white-space: nowrap;
}

.vnl-btn-secondary:hover {
    background: #e2e8f0;
    color: #1e293b;
}

/* Pause button — amber state when paused */
.vnl-btn-secondary.vnl-btn-paused {
    background: #fef3c7;
    border-color: #fcd34d;
    color: #92400e;
}

.vnl-btn-secondary.vnl-btn-paused:hover {
    background: #fde68a;
    color: #78350f;
}

/* Stop button — red tint */
.vnl-btn-danger {
    border-color: #fca5a5 !important;
}

.vnl-btn-danger:hover {
    background: #fee2e2 !important;
    color: #dc2626 !important;
    border-color: #f87171 !important;
}

/* --- Responsive --- */
@media (max-width: 600px) {
    .vnl-controls {
        flex-direction: column;
        align-items: stretch;
        gap: 15px;
    }

    .vnl-cards-panel {
        width: 110px;
    }
}

/* --- Warning Zone Pulse --- */
@keyframes vnl-warn-pulse {
    0%, 100% {
        box-shadow: inset 4px 0 16px -4px rgba(245, 158, 11, 0),
                    inset -4px 0 16px -4px rgba(245, 158, 11, 0);
    }
    50% {
        box-shadow: inset 4px 0 16px -4px rgba(245, 158, 11, 0.35),
                    inset -4px 0 16px -4px rgba(245, 158, 11, 0.35);
    }
}

.vnl-stage.stage-warn {
    animation: vnl-warn-pulse 1.5s ease-in-out infinite;
}

/* --- Alarm Countdown --- */
.vnl-alarm-countdown {
    font-size: 9rem;
    font-weight: 900;
    color: white;
    line-height: 1;
    text-shadow: 0 6px 30px rgba(0,0,0,0.5), 0 2px 6px rgba(0,0,0,0.3);
}

/* --- Toast --- */
.vnl-toast {
    position: absolute;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%) translateY(20px);
    background: linear-gradient(135deg, #059669, #10b981);
    color: white;
    padding: 13px 32px;
    border-radius: 50px;
    font-size: 1rem;
    font-weight: 700;
    z-index: 60;
    opacity: 0;
    transition: opacity 0.3s, transform 0.3s;
    pointer-events: none;
    white-space: nowrap;
    box-shadow: 0 4px 20px rgba(16, 185, 129, 0.45);
    letter-spacing: 0.01em;
}

.vnl-toast.active {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

/* --- Best Streak Label --- */
.vnl-best-streak {
    display: block;
    font-size: 0.7rem;
    font-weight: 500;
    color: #64748b;
    margin-top: 1px;
}

/* --- Score Grade Colors --- */
.vnl-score-display .grade-a { color: var(--vnl-calm); }
.vnl-score-display .grade-b { color: #38a169; }
.vnl-score-display .grade-c { color: var(--vnl-warn); }
.vnl-score-display .grade-d { color: #dd6b20; }
.vnl-score-display .grade-f { color: var(--vnl-loud); }

/* --- Session Delete Button --- */
.vnl-btn-delete-session {
    background: none;
    border: none;
    color: #cbd5e1;
    cursor: pointer;
    font-size: 0.75rem;
    padding: 2px 4px;
    border-radius: 4px;
    line-height: 1;
    transition: background 0.15s, color 0.15s;
}

.vnl-btn-delete-session:hover {
    background: #fee2e2;
    color: #dc2626;
}

/* --- Over Limit always red --- */
#vnl-over-limit .vnl-stat-value { color: var(--vnl-loud); }

/* --- Warning Count (inside alarm overlay) --- */
.vnl-warning-count {
    font-size: 1rem;
    color: rgba(255, 255, 255, 0.9);
    font-weight: 700;
    margin-top: 6px;
    min-height: 1.4em;
    letter-spacing: 0.02em;
}

/* --- Countdown cycle flash --- */
@keyframes vnl-hit-flash {
    0%   { background: rgba(255, 255, 255, 0.55); }
    100% { background: rgba(220, 38, 38, 0.9); }
}

.vnl-alarm-overlay.vnl-flash-hit {
    animation: vnl-hit-flash 0.35s ease-out forwards !important;
}

/* --- Animations --- */
@keyframes vnl-wave {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.1); }
}

@keyframes vnl-flash {
    0%, 100% { background: rgba(220, 38, 38, 0.85); }
    50% { background: rgba(220, 38, 38, 0.97); }
}
