/* File: voice-notebook/css/base.css */
/* Основные стили для голосового блокнота */

:root {
    --mic-btn-w: 160px;
    --mic-btn-pad-x: 26px;

    /* quick-panel: фиксированная сетка 5×N */
    --qp-cols: 5;
    --qp-btn: 34px;   /* ширина/высота мини-кнопки */
    --qp-gap: 6px;    /* gap между мини-кнопками */
    --qp-pad-x: 6px;  /* padding quick-panel по X */
    --qp-pad-y: 4px;  /* padding quick-panel по Y */

    /* fallback (если JS не выставил точные значения) */
    --qp-closed-h: calc(var(--qp-btn) + 2 * var(--qp-pad-y) + 2px);
    --qp-open-h: 520px;
}

body {
    margin: 0;
    padding: 0;
    font-family: 'Segoe UI', Arial, sans-serif;
    background-color: #02393E;
    color: #ffffff;
    height: 100vh;
    display: flex;
    overflow-x: hidden;
}

.container {
    display: flex;
    width: 100%;
    height: 100%;
    position: relative;
    overflow: hidden;
}

.note-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    padding: 20px;
    gap: 15px;
    margin-left: 0;
    transition: margin-left 0.3s ease;
    width: 100%;
    box-sizing: border-box;
}

.note-controls {
    display: flex;
    gap: 10px;
    align-items: center;

    width: 100%;
    justify-content: flex-start;

    box-sizing: border-box;
    padding-left: 70px;

    flex-wrap: wrap;
    overflow: visible;
}

.controls-left {
    flex: 1 1 auto;
    min-width: 0;

    display: flex;
    align-items: center;
    justify-content: center;

    gap: 10px;
    flex-wrap: wrap;

    overflow: visible;
}

.controls-right {
    flex: 0 0 auto;

    display: flex;
    align-items: center;
    justify-content: flex-end;

    gap: 10px;

    margin-left: auto;
    flex-wrap: nowrap;
}

.control-button {
    background: rgba(0, 150, 200, 0.7);
    color: white;
    border: none;
    padding: 10px 16px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 16px;
    transition: background 0.2s, transform 0.1s;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    user-select: none;
    min-width: 46px;
}

.control-button.mic-button {
    min-width: var(--mic-btn-w);
    width: var(--mic-btn-w);
    flex: 0 0 var(--mic-btn-w);
    padding-left: var(--mic-btn-pad-x);
    padding-right: var(--mic-btn-pad-x);
}

.control-button:hover { background: rgba(0, 170, 220, 0.9); }
.control-button:active { transform: scale(0.97); }

.control-button.active { background: rgba(200, 50, 50, 0.7); }
.control-button.active:hover { background: rgba(220, 70, 70, 0.9); }

.control-button.caps-active { background: rgba(170, 120, 0, 0.7); }
.control-button.caps-active:hover { background: rgba(190, 140, 0, 0.9); }

.control-button.commands-button.commands-off { background: rgba(120, 120, 120, 0.35); }
.control-button.commands-button.commands-off:hover { background: rgba(140, 140, 140, 0.5); }

/* ====== Save button dirty state (несохранённые изменения) ====== */
#save-note.dirty {
    background: rgba(200, 50, 50, 0.85);
}
#save-note.dirty:hover {
    background: rgba(220, 70, 70, 0.92);
}

.lang-select {
    background: rgba(0, 150, 200, 0.7);
    color: #ffffff;
    border: none;
    padding: 10px 14px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 14px;
    transition: background 0.2s, transform 0.1s;
    outline: none;
    min-width: 64px;
    height: 100%;
}

.lang-select option {
    background: #02393E;
    color: #ffffff;
}

.lang-select:hover { background: rgba(0, 170, 220, 0.9); }
.lang-select:active { transform: scale(0.97); }

/* ===========================
   Быстрая панель символов (B+C)
   "..." НЕ перемещается: всегда 5-я кнопка 1-го ряда
   =========================== */

.quick-panel-host {
    position: relative;
    display: inline-block;
    overflow: visible;
}

/* сам блок */
.quick-panel {
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 10px;

    padding: var(--qp-pad-y) var(--qp-pad-x);

    user-select: none;
    overflow: hidden;
    position: relative;
    box-sizing: border-box;

    /* фиксируем ширину под 5 кнопок */
    width: calc(
        var(--qp-cols) * var(--qp-btn) +
        (var(--qp-cols) - 1) * var(--qp-gap) +
        2 * var(--qp-pad-x)
    );

    /* аккордеон */
    max-height: var(--qp-closed-h);
    transition: max-height 260ms ease, background 0.2s, border-color 0.2s;
}

/* сетка кнопок */
.quick-panel__grid {
    display: grid;
    grid-template-columns: repeat(var(--qp-cols), var(--qp-btn));
    grid-auto-rows: var(--qp-btn);
    gap: var(--qp-gap);
    align-items: center;
    justify-content: start;
}

/* кнопки одинакового размера */
.mini-button {
    background: rgba(0, 150, 200, 0.82);
    color: #ffffff;
    border: 1px solid rgba(255, 255, 255, 0.26);
    border-radius: 8px;

    width: var(--qp-btn);
    height: var(--qp-btn);

    padding: 0;
    cursor: pointer;
    font-size: 14px;
    line-height: 1;
    text-shadow: 0 1px 1px rgba(0, 0, 0, 0.38);
    transition: background 0.2s, transform 0.1s, opacity 180ms ease, transform 180ms ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    box-sizing: border-box;
}

.mini-button:hover { background: rgba(0, 170, 220, 0.92); }
.mini-button:active { transform: scale(0.97); }

.quick-panel__toggle {
    background: rgba(0, 150, 200, 0.74);
}

/* extra-кнопки (начиная с 6-й) — скрываем, когда панель закрыта */
.quick-panel:not(:hover):not(:focus-within):not(.is-open) .quick-panel__grid > .mini-button:nth-child(n+6) {
    opacity: 0;
    transform: translateY(-4px);
    pointer-events: none;
    visibility: hidden;
    transition: opacity 180ms ease, transform 180ms ease, visibility 0ms linear 180ms;
}

/* показываем extra-кнопки при раскрытии */
.quick-panel:hover .quick-panel__grid > .mini-button:nth-child(n+6),
.quick-panel:focus-within .quick-panel__grid > .mini-button:nth-child(n+6),
.quick-panel.is-open .quick-panel__grid > .mini-button:nth-child(n+6) {
    opacity: 1;
    transform: translateY(0);
    pointer-events: auto;
    visibility: visible;
    transition: opacity 180ms ease, transform 180ms ease, visibility 0ms;
}

/* раскрытие: hover/focus (ПК) или .is-open (тап) */
.quick-panel:hover,
.quick-panel:focus-within,
.quick-panel.is-open {
    background: rgba(255, 255, 255, 0.09);
    border-color: rgba(255, 255, 255, 0.18);
    max-height: var(--qp-open-h);
}

/* ----------- DESKTOP (мышь): раскрытие "поверх", textarea НЕ двигаем ----------- */
@media (pointer: fine) {
    .quick-panel-host.qp-ready {
        width: var(--qp-host-w, auto);
        height: var(--qp-host-h, auto);
    }

    .quick-panel-host.qp-ready .quick-panel {
        position: absolute;
        top: 0;
        left: 0;
        width: 100%;
        z-index: 300;
        transform: none;
        will-change: opacity, transform;
    }

    .quick-panel-host.qp-ready .quick-panel:hover,
    .quick-panel-host.qp-ready .quick-panel:focus-within,
    .quick-panel-host.qp-ready .quick-panel.is-open {
        z-index: 450;
    }
}

/* ----------- MOBILE (тач): раскрытие в потоке (C) и двигаем textarea вниз ----------- */
@media (pointer: coarse) {
    .quick-panel-host {
        width: auto !important;
        height: auto !important;
    }

    .quick-panel {
        position: static !important;
        transform: none !important;
    }

    :root {
        --qp-btn: 38px;
    }
}

/* ===========================
   textarea
   =========================== */

#note-text {
    flex: 1;
    width: 100%;
    min-height: 60vh;
    resize: none;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: white;
    padding: 12px;
    border-radius: 8px;
    font-family: inherit;
    font-size: 16px;
    box-sizing: border-box;
    line-height: 1.5;
    overflow-y: auto;
}

#note-text:focus {
    outline: none;
    border-color: rgba(0, 150, 200, 0.5);
    box-shadow: 0 0 0 2px rgba(0, 150, 200, 0.2);
}

/* Модальное окно */
.modal {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.55);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 18px;
    box-sizing: border-box;
}

.hidden { display: none; }

.modal-content {
    width: min(760px, 100%);
    max-height: 85vh;
    overflow: auto;
    background: rgba(0, 40, 45, 0.97);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 14px;
    box-shadow: 0 20px 70px rgba(0, 0, 0, 0.55);
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 16px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.10);
}

.modal-title { font-size: 18px; font-weight: 600; }

.modal-close {
    background: transparent;
    border: none;
    color: rgba(255, 255, 255, 0.9);
    font-size: 24px;
    cursor: pointer;
    padding: 0 8px;
    line-height: 1;
}

.modal-close:hover { color: #ffffff; }

.modal-body {
    padding: 14px 16px 18px;
    font-size: 14px;
    line-height: 1.45;
}

.modal-body code {
    background: rgba(255, 255, 255, 0.08);
    padding: 2px 6px;
    border-radius: 6px;
}

.modal-body ul {
    margin: 10px 0 10px 18px;
    padding: 0;
}

.modal-sep {
    border: none;
    height: 1px;
    background: rgba(255, 255, 255, 0.12);
    margin: 12px 0;
}

@media (max-width: 768px) {
    :root {
        --mic-btn-w: 140px;
        --mic-btn-pad-x: 20px;
    }

    .note-container { padding: 15px; }

    .control-button {
        padding: 8px 14px;
        font-size: 14px;
        min-width: 42px;
    }

    .lang-select {
        padding: 8px 12px;
        font-size: 13px;
        min-width: 58px;
    }

    #note-text { min-height: 50vh; }
}

@media (max-width: 540px) {
    .note-controls { justify-content: flex-start; }

    .controls-right {
        width: 100%;
        justify-content: flex-end;
    }

    #note-text { min-height: 40vh; }
}
