/* Modal Overlay */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(8px);
    /* Blur effect */
    -webkit-backdrop-filter: blur(8px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 20000;
    padding: 20px;
    box-sizing: border-box;
}

.modal-card {
    background: var(--modal-bg);
    border-radius: 24px;
    padding: 30px 24px;
    width: 100%;
    max-width: 320px;
    text-align: center;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
    border: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.modal-title {
    font-size: 20px;
    font-weight: 800;
    color: var(--text-color);
    margin-bottom: 8px;
    text-transform: uppercase;
}

.modal-subtitle {
    font-size: 14px;
    color: var(--text-secondary);
    margin-bottom: 28px;
}

.modal-btn {
    width: 100%;
    padding: 20px;
    /* Larger for gloves */
    border-radius: 16px;
    border: none;
    font-size: 17px;
    font-weight: 800;
    cursor: pointer;
    text-transform: uppercase;
    margin-bottom: 12px;
}

.modal-buttons {
    display: flex;
    gap: 12px;
    margin-top: 20px;
    width: 100%;
}

.modal-buttons .modal-btn {
    width: auto;
    flex: 1;
    margin-bottom: 0;
}

.modal-btn-confirm {
    background: #ef4444;
    color: #fff;
}

.modal-btn-cancel {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-secondary);
    border: 1px solid var(--border-color);
}

.modal-btn-save {
    background: #3b82f6;
    color: #fff;
}

/* Helpers */
.static-time {
    font-size: 28px;
    font-weight: 700;
    color: #334155;
    margin-bottom: 5px;
}

.static-label {
    font-size: 12px;
    color: #94a3b8;
    text-transform: uppercase;
    font-weight: 600;
    margin-bottom: 20px;
}

/* Edit Inputs */
.edit-input {
    background: var(--input-bg);
    border-radius: 12px;
    border: 1px solid var(--border-color);
    color: var(--text-color);
    padding: 10px;
    font-size: 24px;
    font-weight: 700;
    text-align: center;
    width: 60px;
    -moz-appearance: textfield;
    appearance: textfield;
    /* Standard property */
}

.edit-input::-webkit-outer-spin-button,
.edit-input::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

.edit-input-row {
    display: flex;
    gap: 10px;
    justify-content: center;
    align-items: center;
    margin-bottom: 24px;
}

.edit-input-group {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.edit-input-label {
    font-size: 10px;
    color: var(--text-secondary);
    margin-top: 5px;
    font-weight: 600;
    text-transform: uppercase;
}

.edit-input-sep {
    font-weight: 700;
    padding-bottom: 20px;
}

/* Version 3.7 Additions */
.card-widget {
    background: var(--card-bg);
    border-radius: 20px;
    padding: 20px;
    margin-bottom: 20px;
    border: none;
    box-shadow: var(--shadow-soft);
    display: flex;
    flex-direction: column;
    align-items: center;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}

/* Native Time Input Style */
.native-time-input {
    appearance: none;
    -webkit-appearance: none;
    background: var(--input-bg);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 12px;
    font-size: 28px;
    font-weight: 700;
    color: var(--text-color);
    width: 100%;
    text-align: center;
    font-family: inherit;
    margin-bottom: 20px;
    display: block;
}

/* Focused / blurred state for Pause Modal */
.blur-content {
    transition: filter 0.3s ease;
}

.blur-active {
    filter: blur(8px);
    pointer-events: none;
    user-select: none;
}

/* Pause Modal specific (overrides/extends modal) */
.pause-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 30000;
    display: flex;
    align-items: center;
    justify-content: center;
    /* No background here, blur is on content beneath. Or semi-transparent dark? */
    /* User asked "основной экран должен заблюриться". This usually means content is blurred. 
       The overlay itself can be transparent or have a slight tint. */
    background: rgba(0, 0, 0, 0.3);
}

.pause-timer-large {
    font-size: 80px;
    font-weight: 900;
    color: var(--text-color);
    text-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
    margin-bottom: 40px;
    font-variant-numeric: tabular-nums;
}

/* v3.8 Final Polish */
[data-theme="light"] .card-widget {
    background: #ffffff;
    border: 1px solid rgba(0, 0, 0, 0.15);
    /* Stronger border */
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
    /* Deeper shadow */
}

/* Pause Modal - Live Shift Timer */
.pause-shift-display {
    font-size: 24px;
    font-weight: 700;
    color: var(--text-color);
    margin-bottom: 5px;
    font-variant-numeric: tabular-nums;
}

/* =========================================
   v4.6 MINIMAL GLASS & 3D PATCH (SAFE MODE)
   ========================================= */

/* 1. Выпуклая гравировка (Embossed Title) */
#page-title {
    margin-top: 65px !important;
    opacity: 0.35 !important;
    font-weight: 800 !important;
    text-shadow: 1px 1px 1px rgba(255, 255, 255, 0.1), -1px -1px 1px rgba(0, 0, 0, 0.5) !important;
}

/* 2. Стеклянные блоки (Glassmorphism) */
.card-widget {
    background: rgba(255, 255, 255, 0.08) !important;
    border: 1px solid rgba(255, 255, 255, 0.1) !important;
    backdrop-filter: blur(12px) !important;
    -webkit-backdrop-filter: blur(12px) !important;
}

/* 3. Гарантия кликабельности верхних кнопок */
.theme-toggle,
.header-close-btn {
    z-index: 1000000 !important;
}

/* 4. Разрушение Stacking Context хедера */
header {
    z-index: auto !important;
}

/* 5. Поднимаем стандартные модальные окна выше Паузы */
.modal-overlay {
    z-index: 40000 !important;
}

/* 6. Стеклянный эффект для модальных окон (попапов) */
.modal-card {
    background: rgba(30, 41, 59, 0.7) !important;
    backdrop-filter: blur(20px) !important;
    -webkit-backdrop-filter: blur(20px) !important;
    border: 1px solid rgba(255, 255, 255, 0.15) !important;
}

/* Прозрачность для кнопки "Коррекция" (Тахограф) */
.btn-tacho-edit {
    background: rgba(255, 255, 255, 0.08) !important;
    backdrop-filter: blur(12px) !important;
    -webkit-backdrop-filter: blur(12px) !important;
    border: 1px solid rgba(255, 255, 255, 0.1) !important;
}

/* Прозрачность для кнопки "Завершить смену" */
.btn-close {
    background: rgba(255, 59, 48, 0.15) !important;
    backdrop-filter: blur(12px) !important;
    -webkit-backdrop-filter: blur(12px) !important;
    border: 1px solid rgba(255, 59, 48, 0.3) !important;
}

/* Поддержка светлой темы */
[data-theme="light"] .modal-card {
    background: rgba(255, 255, 255, 0.75) !important;
    border: 1px solid rgba(0, 0, 0, 0.1) !important;
}

[data-theme="light"] .btn-tacho-edit {
    background: rgba(255, 255, 255, 0.5) !important;
    border: 1px solid rgba(0, 0, 0, 0.1) !important;
}

/* ========= SOS MODULE ========= */

/* SOS FAB */
.sos-fab {
    position: fixed;
    left: 16px;
    bottom: calc(90px + env(safe-area-inset-bottom, 20px));
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: linear-gradient(135deg, #ef4444, #dc2626);
    color: #fff;
    border: none;
    font-size: 14px;
    font-weight: 900;
    letter-spacing: 1px;
    cursor: pointer;
    z-index: 9999;
    box-shadow: 0 4px 20px rgba(239, 68, 68, 0.5);
    animation: sos-glow 3s ease-in-out infinite;
    display: flex;
    align-items: center;
    justify-content: center;
}

.sos-fab:active {
    transform: scale(0.9);
}

@keyframes sos-glow {

    0%,
    100% {
        box-shadow: 0 4px 20px rgba(239, 68, 68, 0.5);
    }

    50% {
        box-shadow: 0 4px 30px rgba(239, 68, 68, 0.8);
    }
}

/* SOS Modal Overlay */
.sos-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 50000;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
}

.sos-card {
    width: 90%;
    max-width: 360px;
    background: rgba(30, 41, 59, 0.95);
    border-radius: 24px;
    border: 1px solid rgba(239, 68, 68, 0.3);
    padding: 28px 24px;
    position: relative;
    max-height: 85vh;
    overflow-y: auto;
}

.sos-title {
    text-align: center;
    font-size: 28px;
    font-weight: 900;
    color: #ef4444;
    margin: 0 0 20px;
}

/* SOS Action Items */
.sos-action-row {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 16px;
    margin-bottom: 10px;
    border-radius: 16px;
    background: rgba(255, 255, 255, 0.05);
    border: 2px solid transparent;
    cursor: pointer;
    transition: all 0.2s;
}

.sos-action-row.selected {
    border-color: #ef4444;
    background: rgba(239, 68, 68, 0.12);
}

.sos-radio,
.sos-checkbox {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    border: 2px solid rgba(255, 255, 255, 0.3);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: all 0.2s;
}

.sos-checkbox {
    border-radius: 6px;
}

.sos-radio.active,
.sos-checkbox.active {
    border-color: #ef4444;
    background: #ef4444;
}

.sos-radio.active::after {
    content: '';
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: #fff;
}

.sos-checkbox.active::after {
    content: '✓';
    color: #fff;
    font-size: 14px;
    font-weight: 900;
}

.sos-action-text {
    flex: 1;
}

.sos-action-label {
    font-size: 15px;
    font-weight: 700;
    color: var(--text-color);
}

.sos-action-desc {
    font-size: 12px;
    color: var(--text-secondary);
    margin-top: 2px;
}

.sos-action-icon {
    font-size: 24px;
}

/* SOS Buttons */
.sos-send-btn {
    width: 100%;
    padding: 16px;
    border: none;
    border-radius: 16px;
    background: linear-gradient(135deg, #ef4444, #dc2626);
    color: #fff;
    font-size: 16px;
    font-weight: 800;
    cursor: pointer;
    margin-top: 16px;
    transition: transform 0.15s;
}

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

.sos-send-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

/* SOS Divider */
.sos-divider {
    height: 1px;
    background: rgba(255, 255, 255, 0.1);
    margin: 20px 0;
}

/* Witness Button */
.sos-witness-btn {
    width: 100%;
    padding: 14px;
    border: 1px solid rgba(59, 130, 246, 0.3);
    border-radius: 16px;
    background: rgba(59, 130, 246, 0.1);
    color: #60a5fa;
    font-size: 14px;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s;
}

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

/* SOS Close */
.sos-close {
    position: absolute;
    right: 16px;
    top: 16px;
    background: none;
    border: none;
    color: var(--text-color);
    opacity: 0.6;
    font-size: 28px;
    cursor: pointer;
    line-height: 1;
}

/* Witness Popup (nested) */
.witness-popup-card {
    width: 85%;
    max-width: 320px;
    background: rgba(30, 41, 59, 0.98);
    border-radius: 20px;
    border: 1px solid rgba(59, 130, 246, 0.3);
    padding: 30px 24px;
    text-align: center;
}

.witness-popup-card h3 {
    color: #60a5fa;
    font-size: 20px;
    font-weight: 800;
    margin: 0 0 12px;
}

.witness-popup-card p {
    color: var(--text-secondary);
    font-size: 14px;
    line-height: 1.6;
    margin: 0 0 20px;
}

.witness-activate-btn {
    width: 100%;
    padding: 14px;
    border: none;
    border-radius: 14px;
    background: linear-gradient(135deg, #3b82f6, #2563eb);
    color: #fff;
    font-size: 15px;
    font-weight: 700;
    cursor: pointer;
    margin-bottom: 10px;
}

.witness-back-btn {
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 14px;
    cursor: pointer;
}

/* Emergency Stub */
.emergency-stub {
    text-align: center;
    padding: 20px;
}

.emergency-stub p {
    color: var(--text-secondary);
    font-size: 14px;
    line-height: 1.6;
}

/* Profile Contact Row */
.contact-row {
    display: flex;
    gap: 8px;
    margin-bottom: 10px;
    align-items: center;
}

.contact-row input {
    flex: 1;
    min-width: 0;
}

.contact-row select {
    width: 70px;
    flex-shrink: 0;
}

/* Light theme overrides for SOS */
[data-theme="light"] .sos-card {
    background: rgba(255, 255, 255, 0.95);
    border-color: rgba(239, 68, 68, 0.2);
}

[data-theme="light"] .sos-action-row {
    background: rgba(0, 0, 0, 0.03);
}

[data-theme="light"] .sos-action-row.selected {
    background: rgba(239, 68, 68, 0.08);
}

[data-theme="light"] .sos-action-label {
    color: #1e293b;
}

[data-theme="light"] .witness-popup-card {
    background: rgba(255, 255, 255, 0.98);
    border-color: rgba(59, 130, 246, 0.2);
}