/* ===================================================
   ALDAGAIAK ETA OINARRIA
   =================================================== */
:root {
    --primary:        #1B5E20;
    --primary-light:  #2E7D32;
    --primary-hover:  #145214;
    --secondary:      #0D47A1;
    --accent:         #E65100;
    --bg:             #EFF3EE;
    --card:           #FFFFFF;
    --text:           #212121;
    --text-light:     #616161;
    --border:         #D0D9D0;
    --shadow:         0 4px 16px rgba(0,0,0,0.10);
    --shadow-sm:      0 2px 6px rgba(0,0,0,0.07);
    --radius:         14px;
    --radius-sm:      8px;
    --font:           'Segoe UI', system-ui, -apple-system, sans-serif;

    --timer-full:     #1565C0;
    --timer-mid:      #F57C00;
    --timer-low:      #C62828;
    --recording:      #B71C1C;
}

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

html, body {
    height: 100%;
    font-family: var(--font);
    background: var(--bg);
    color: var(--text);
    font-size: 16px;
    line-height: 1.5;
}

/* ===================================================
   EGOERA-BARRA KOMUNA (header)
   =================================================== */
.app-header {
    background: var(--primary);
    color: #fff;
    padding: 0.75rem 2rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    box-shadow: 0 2px 8px rgba(0,0,0,0.2);
    position: sticky;
    top: 0;
    z-index: 100;
}

.app-header .logo {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-size: 1.2rem;
    font-weight: 700;
    letter-spacing: 0.01em;
}

.app-header .logo svg { width: 32px; height: 32px; fill: #fff; }

.app-header .header-right {
    display: flex;
    align-items: center;
    gap: 1.5rem;
    font-size: 0.9rem;
    opacity: 0.9;
}

.app-header .logout-btn {
    background: rgba(255,255,255,0.15);
    border: 1px solid rgba(255,255,255,0.3);
    color: #fff;
    padding: 0.35rem 1rem;
    border-radius: 20px;
    cursor: pointer;
    font-size: 0.85rem;
    text-decoration: none;
    transition: background 0.2s;
}
.app-header .logout-btn:hover { background: rgba(255,255,255,0.25); }

/* ===================================================
   LOGIN ORRIA
   =================================================== */
.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #1B5E20 0%, #2E7D32 50%, #1565C0 100%);
    padding: 1rem;
}

.login-card {
    background: var(--card);
    border-radius: var(--radius);
    padding: 3rem 2.5rem;
    width: 100%;
    max-width: 420px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.2);
    text-align: center;
}

.login-card .app-icon {
    width: 80px;
    height: 80px;
    background: var(--primary);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 1.5rem;
}
.login-card .app-icon svg { width: 44px; height: 44px; fill: #fff; }

.login-card h1 {
    font-size: 1.6rem;
    color: var(--primary);
    margin-bottom: 0.4rem;
}

.login-card .subtitle {
    color: var(--text-light);
    font-size: 0.95rem;
    margin-bottom: 2rem;
}

.login-card .form-group {
    text-align: left;
    margin-bottom: 1.25rem;
}

.login-card label {
    display: block;
    font-weight: 600;
    font-size: 0.9rem;
    margin-bottom: 0.4rem;
    color: var(--text);
}

.login-card input[type="text"],
.login-card input[type="password"] {
    width: 100%;
    padding: 0.85rem 1rem;
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 1rem;
    font-family: var(--font);
    transition: border-color 0.2s, box-shadow 0.2s;
    background: #FAFAFA;
}

.login-card input:focus {
    outline: none;
    border-color: var(--primary-light);
    box-shadow: 0 0 0 3px rgba(46,125,50,0.12);
    background: #fff;
}

.login-card .btn-login {
    width: 100%;
    background: var(--primary);
    color: #fff;
    border: none;
    padding: 1rem;
    border-radius: var(--radius-sm);
    font-size: 1.05rem;
    font-weight: 700;
    cursor: pointer;
    margin-top: 0.5rem;
    transition: background 0.2s, transform 0.1s;
    letter-spacing: 0.02em;
}
.login-card .btn-login:hover  { background: var(--primary-hover); }
.login-card .btn-login:active { transform: scale(0.98); }

.login-card .error-msg {
    background: #FFEBEE;
    color: #B71C1C;
    border: 1px solid #FFCDD2;
    border-radius: var(--radius-sm);
    padding: 0.75rem 1rem;
    margin-bottom: 1.25rem;
    font-size: 0.9rem;
    text-align: left;
}

/* ===================================================
   INSTRUKZIOAK ORRIA
   =================================================== */
.instrukzioak-page {
    min-height: calc(100vh - 60px);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem 1rem;
}

.instrukzioak-card {
    background: var(--card);
    border-radius: var(--radius);
    padding: 2.5rem 3rem;
    max-width: 780px;
    width: 100%;
    box-shadow: var(--shadow);
}

.instrukzioak-card h2 {
    font-size: 1.6rem;
    color: var(--primary);
    margin-bottom: 0.5rem;
}

.instrukzioak-card .ongi-etorri {
    color: var(--text-light);
    margin-bottom: 2rem;
    font-size: 1.05rem;
}

.instrukzioak-card .azalpena {
    background: #F1F8E9;
    border-left: 4px solid var(--primary-light);
    border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
    padding: 1.25rem 1.5rem;
    margin-bottom: 2rem;
    font-size: 0.95rem;
    line-height: 1.7;
    color: var(--text);
}

.pauso-zerrenda {
    list-style: none;
    counter-reset: pauso-counter;
    margin-bottom: 2rem;
}

.pauso-zerrenda li {
    counter-increment: pauso-counter;
    display: flex;
    align-items: flex-start;
    gap: 1rem;
    margin-bottom: 1.25rem;
    padding: 1rem 1.25rem;
    background: #FAFAFA;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
}

.pauso-zerrenda li::before {
    content: counter(pauso-counter);
    background: var(--primary);
    color: #fff;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.9rem;
    flex-shrink: 0;
    margin-top: 0.1rem;
}

.pauso-zerrenda li strong { display: block; margin-bottom: 0.2rem; color: var(--primary-light); }

.instrukzioak-actions {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    flex-wrap: wrap;
}

.mic-status {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    font-size: 0.9rem;
    color: var(--text-light);
    padding: 0.6rem 1rem;
    border-radius: 20px;
    background: #FAFAFA;
    border: 1px solid var(--border);
}

.mic-status .dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: #9E9E9E;
    flex-shrink: 0;
}
.mic-status.granted .dot { background: #4CAF50; }
.mic-status.denied  .dot { background: #F44336; }

/* ===================================================
   BOTOIAK
   =================================================== */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.85rem 1.75rem;
    border-radius: var(--radius-sm);
    border: none;
    font-size: 1rem;
    font-weight: 600;
    font-family: var(--font);
    cursor: pointer;
    transition: background 0.2s, transform 0.1s, opacity 0.2s;
    text-decoration: none;
}
.btn:active { transform: scale(0.97); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn:disabled:active { transform: none; }

.btn-primary {
    background: var(--primary);
    color: #fff;
}
.btn-primary:hover:not(:disabled) { background: var(--primary-hover); }

.btn-secondary {
    background: #E8F5E9;
    color: var(--primary);
    border: 1.5px solid #A5D6A7;
}
.btn-secondary:hover:not(:disabled) { background: #C8E6C9; }

.btn-lg {
    padding: 1rem 2.25rem;
    font-size: 1.1rem;
}

/* ===================================================
   AZTERKETA ORRIA — DISEINUA
   =================================================== */
.azterketa-layout {
    display: grid;
    grid-template-columns: 1fr 380px;
    gap: 0;
    height: calc(100vh - 60px);
    overflow: hidden;
}

/* Ezkerreko panela — Galdera */
.panel-galdera {
    background: var(--card);
    border-right: 2px solid var(--border);
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    padding: 2.5rem 3rem;
}

.galdera-zenbakia {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-light);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    margin-bottom: 1.5rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.galdera-zenbakia .zenbakia-badge {
    background: var(--primary);
    color: #fff;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 0.85rem;
}

.galdera-testua {
    font-size: 1.3rem;
    line-height: 1.6;
    color: var(--text);
    margin-bottom: 2rem;
    font-weight: 500;
}

.galdera-irudia-wrapper {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
}

.galdera-irudia-wrapper img {
    max-width: 100%;
    max-height: 380px;
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow);
    object-fit: contain;
}

.galdera-irudia-wrapper.hutsa {
    display: none;
}

.audio-egoera {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    font-size: 0.9rem;
    color: var(--text-light);
    margin-top: 1.5rem;
    padding: 0.75rem 1rem;
    background: #F5F5F5;
    border-radius: var(--radius-sm);
}

.audio-egoera .audio-dot {
    width: 10px; height: 10px;
    border-radius: 50%;
    background: #9E9E9E;
    flex-shrink: 0;
    transition: background 0.3s;
}
.audio-egoera.irakurtzen .audio-dot { background: #2196F3; animation: pulse-blue 1.2s infinite; }
.audio-egoera.grabatzen .audio-dot  { background: var(--recording); animation: pulse-red 1s infinite; }
.audio-egoera.amaituta .audio-dot   { background: #4CAF50; }

@keyframes pulse-blue {
    0%, 100% { box-shadow: 0 0 0 0 rgba(33,150,243,0.5); }
    50%       { box-shadow: 0 0 0 6px rgba(33,150,243,0); }
}
@keyframes pulse-red {
    0%, 100% { box-shadow: 0 0 0 0 rgba(183,28,28,0.5); }
    50%       { box-shadow: 0 0 0 6px rgba(183,28,28,0); }
}

/* Eskuineko panela — Kontadorea */
.panel-erantzuna {
    background: var(--bg);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 2rem;
    gap: 2rem;
}

/* Denbora-kontadorea SVG */
.timer-wrapper {
    position: relative;
    width: 200px;
    height: 200px;
}

.timer-wrapper svg {
    transform: rotate(-90deg);
    width: 200px;
    height: 200px;
}

.timer-bg { fill: none; stroke: #E0E0E0; stroke-width: 10; }
.timer-arc {
    fill: none;
    stroke: var(--timer-full);
    stroke-width: 10;
    stroke-linecap: round;
    transition: stroke-dashoffset 0.9s linear, stroke 0.5s ease;
}

.timer-text {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    text-align: center;
}

.timer-text .segundoak {
    font-size: 2.6rem;
    font-weight: 700;
    color: var(--text);
    line-height: 1;
    display: block;
}

.timer-text .etiketa {
    font-size: 0.75rem;
    color: var(--text-light);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    margin-top: 0.3rem;
    display: block;
}

/* Grabazio adierazlea */
.grabazio-adierazlea {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.6rem;
}

.grabazio-adierazlea .graba-dot {
    width: 18px; height: 18px;
    border-radius: 50%;
    background: #BDBDBD;
    transition: background 0.3s;
}
.grabazio-adierazlea.aktibo .graba-dot {
    background: var(--recording);
    animation: pulse-red 1s infinite;
}

.grabazio-adierazlea .graba-testua {
    font-size: 0.9rem;
    color: var(--text-light);
    font-weight: 500;
}
.grabazio-adierazlea.aktibo .graba-testua { color: var(--recording); }

/* Hurrengo botoia */
.panel-erantzuna .btn-hurrengo {
    width: 100%;
    max-width: 260px;
    justify-content: center;
}

/* ===================================================
   BUKAERA ORRIA
   =================================================== */
.bukaera-page {
    min-height: calc(100vh - 60px);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem;
}

.bukaera-card {
    background: var(--card);
    border-radius: var(--radius);
    padding: 3rem;
    max-width: 560px;
    width: 100%;
    text-align: center;
    box-shadow: var(--shadow);
}

.bukaera-card .check-icon {
    width: 90px; height: 90px;
    background: #E8F5E9;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 1.5rem;
}
.bukaera-card .check-icon svg { width: 52px; height: 52px; stroke: #2E7D32; fill: none; stroke-width: 3; stroke-linecap: round; stroke-linejoin: round; }

.bukaera-card h2 { font-size: 1.8rem; color: var(--primary); margin-bottom: 0.75rem; }
.bukaera-card p  { color: var(--text-light); line-height: 1.6; margin-bottom: 1.5rem; }

/* ===================================================
   ADMIN ORRIA
   =================================================== */
.admin-page { padding: 2rem; max-width: 1100px; margin: 0 auto; }
.admin-page h2 { color: var(--primary); margin-bottom: 1.5rem; font-size: 1.5rem; }

.admin-table-wrapper { overflow-x: auto; }

.admin-table {
    width: 100%;
    border-collapse: collapse;
    background: var(--card);
    border-radius: var(--radius-sm);
    overflow: hidden;
    box-shadow: var(--shadow-sm);
}
.admin-table th {
    background: var(--primary);
    color: #fff;
    padding: 0.9rem 1.25rem;
    text-align: left;
    font-size: 0.9rem;
    font-weight: 600;
}
.admin-table td {
    padding: 0.85rem 1.25rem;
    border-bottom: 1px solid var(--border);
    font-size: 0.9rem;
    vertical-align: middle;
}
.admin-table tr:last-child td { border-bottom: none; }
.admin-table tr:hover td { background: #F1F8F1; }

.admin-table a { color: var(--secondary); text-decoration: none; font-weight: 500; }
.admin-table a:hover { text-decoration: underline; }

/* ===================================================
   MIKROFONO PROBA (instrukzioak orria)
   =================================================== */
.mic-proba-seczioa {
    background: #F1F8E9;
    border: 1.5px solid #AED581;
    border-radius: var(--radius-sm);
    padding: 1.25rem 1.5rem;
    margin-bottom: 2rem;
}

.mic-proba-seczioa h4 {
    color: var(--primary-light);
    margin-bottom: 0.85rem;
    font-size: 0.95rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.mic-proba-kontrolak {
    display: flex;
    align-items: center;
    gap: 1rem;
    flex-wrap: wrap;
}

.mic-proba-canvas {
    border-radius: 6px;
    background: #0D1F0D;
    display: block;
    flex-shrink: 0;
}

.mic-proba-egoera {
    font-size: 0.88rem;
    color: var(--text-light);
    flex: 1;
    min-width: 100px;
}

.mic-proba-audio {
    display: none;
    height: 36px;
    width: 100%;
    margin-top: 0.75rem;
}

/* ===================================================
   AUDIO NIVEL-METROA (azterketa orria)
   =================================================== */
.nivel-metro {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.4rem;
    width: 100%;
    max-width: 230px;
}

.nivel-metro canvas {
    border-radius: 8px;
    background: #0D1F0D;
    width: 100%;
    max-width: 230px;
    display: block;
}

.nivel-metro .nivel-etiketa {
    font-size: 0.72rem;
    color: var(--text-light);
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

/* ===================================================
   LAGUNTZAILEAK
   =================================================== */
.text-center { text-align: center; }
.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mt-3 { margin-top: 1.5rem; }

/* Fade-in animazioa */
@keyframes fadeInUp {
    from { opacity: 0; transform: translateY(20px); }
    to   { opacity: 1; transform: translateY(0); }
}
.fade-in { animation: fadeInUp 0.4s ease both; }

/* ===================================================
   ERANTZUKIZUNA (responsive)
   =================================================== */
@media (max-width: 768px) {
    .azterketa-layout {
        grid-template-columns: 1fr;
        grid-template-rows: auto auto;
        height: auto;
        overflow: visible;
    }
    .panel-galdera { padding: 1.5rem; border-right: none; border-bottom: 2px solid var(--border); }
    .panel-erantzuna { padding: 1.5rem; min-height: 300px; }
    .instrukzioak-card { padding: 1.75rem 1.5rem; }
    .instrukzioak-actions { flex-direction: column; }
    .timer-wrapper { width: 160px; height: 160px; }
    .timer-wrapper svg { width: 160px; height: 160px; }
    .timer-text .segundoak { font-size: 2rem; }
}
