/* components.css — шапка, кнопки, формы, модалки, тултипы, флеш, переключатели */

/* ---- Header ---- */
.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 32px;
    padding-bottom: 16px;
    border-bottom: 1px solid #e0e0e0;
    position: relative;
}
.header.header-sticky {
    position: sticky;
    top: 0;
    background: #fff;
    z-index: 100;
    margin-bottom: 24px;
    padding: 16px 24px;
}
.header.header-sticky h1 { font-size: 20px; }
.header h1 {
    margin: 0;
    text-align: left;
    font-size: 28px;
    margin-bottom: 0;
}
.header-actions {
    display: flex;
    align-items: center;
    gap: 10px;
}
.user-info {
    display: flex;
    align-items: center;
    gap: 16px;
}
.user-actions,
.admin-actions {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}
.menu-separator {
    height: 1px;
    background: #e0e0e0;
    width: 100%;
    margin: 6px 0;
}
body[data-is-admin="true"] .user-info {
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
}
body[data-is-admin="true"] .admin-actions {
    width: 100%;
    padding-top: 6px;
    border-top: 1px solid #eee;
}
.user-name {
    color: #666;
    font-size: 14px;
}
.nav-link {
    color: #007aff;
    text-decoration: none;
    font-size: 14px;
}
.header .nav-link {
    margin-top: 0;
}
.nav-link:hover {
    text-decoration: none;
}
.admin-link {
    color: #dc3545;
    font-weight: 500;
}
.header-btn {
    padding: 6px 12px;
    border-radius: 4px;
    font-size: 13px;
    line-height: 1.2;
    height: 32px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    white-space: nowrap;
    border: 1px solid #d0d0d0;
    background: #fff;
    color: #333;
    cursor: pointer;
    text-decoration: none;
}
.header-btn:hover {
    background: #eef2ff;
}
.btn-feedback {
    border: 1px solid #007aff;
    background: #fff;
    color: #007aff;
    cursor: pointer;
}
.btn-feedback:hover {
    background: #e6f0ff;
}
.btn-help {
    border: 1px solid #d0d0d0;
    background: #f8f8f8;
    color: #444;
    text-decoration: none;
    font-weight: 500;
}
.btn-help:hover {
    background: #eee;
    color: #1a1a1a;
    text-decoration: none;
}
.admin-panel-btn {
    background: #f3e8ff;
    border-color: #c8a2ff;
    color: #6f42c1;
}
.admin-panel-btn:hover {
    background: #eadbff;
}
.admin-pending-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 20px;
    height: 20px;
    padding: 0 6px;
    margin-left: 6px;
    font-size: 12px;
    font-weight: 700;
    line-height: 1;
    color: #fff;
    background: #dc3545;
    border-radius: 10px;
    vertical-align: middle;
}
.menu-toggle {
    display: none;
    border: 1px solid #d0d0d0;
    background: #fff;
    color: #333;
    padding: 6px 10px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    height: 32px;
}
.menu-toggle span {
    display: inline-block;
    width: 18px;
    height: 2px;
    background: #333;
    position: relative;
}
.menu-toggle span::before,
.menu-toggle span::after {
    content: '';
    position: absolute;
    left: 0;
    width: 18px;
    height: 2px;
    background: #333;
}
.menu-toggle span::before { top: -6px; }
.menu-toggle span::after { top: 6px; }

/* ---- Toggle (debug, auto-refresh) ---- */
.toggle {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    color: #333;
    cursor: pointer;
    user-select: none;
}
.toggle input {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
}
.toggle-switch {
    position: relative;
    width: 38px;
    height: 20px;
    background: #cfd4da;
    border-radius: 999px;
    transition: background 0.2s;
    flex-shrink: 0;
}
.toggle-switch::after {
    content: '';
    position: absolute;
    top: 2px;
    left: 2px;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: #fff;
    transition: transform 0.2s;
}
.toggle input:checked + .toggle-switch {
    background: #28a745;
}
.toggle input:checked + .toggle-switch::after {
    transform: translateX(18px);
}

/* ---- Tooltips ---- */
[data-tooltip] {
    position: relative;
}
[data-tooltip]::after {
    content: attr(data-tooltip);
    position: absolute;
    bottom: calc(100% + 8px);
    left: 50%;
    transform: translateX(-50%);
    background: #1a1a1a;
    color: #fff;
    font-size: 12px;
    line-height: 1.4;
    padding: 6px 10px;
    border-radius: 5px;
    white-space: pre-wrap;
    max-width: 240px;
    width: max-content;
    text-align: center;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.15s;
    z-index: 200;
}
[data-tooltip]:hover::after {
    opacity: 1;
}

/* ---- Info icon ---- */
.info-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    border: 1.5px solid #aaa;
    color: #aaa;
    font-size: 11px;
    font-style: normal;
    font-weight: 700;
    cursor: default;
    position: relative;
    margin-left: 5px;
    vertical-align: middle;
    flex-shrink: 0;
    line-height: 1;
    user-select: none;
}
.info-icon::after {
    content: attr(data-tip);
    position: absolute;
    bottom: calc(100% + 8px);
    left: 50%;
    transform: translateX(-50%);
    background: #1a1a1a;
    color: #fff;
    font-size: 12px;
    line-height: 1.5;
    padding: 8px 12px;
    border-radius: 6px;
    width: max-content;
    max-width: 260px;
    text-align: left;
    white-space: normal;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.15s;
    z-index: 500;
    font-weight: 400;
}
.info-icon:hover::after {
    opacity: 1;
}
.info-icon.tip-left::after {
    left: auto;
    right: 0;
    transform: none;
}
.info-icon.tip-below::after {
    bottom: auto;
    top: 100%;
    left: 0;
    right: 0;
    transform: none;
    width: auto;
    max-width: none;
    border-radius: 0 0 6px 6px;
}

/* ---- Buttons ---- */
.submit-btn {
    background: #007aff;
    color: white;
    border: none;
    padding: 12px 24px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 16px;
    font-weight: 500;
    transition: background 0.2s;
}
.submit-btn:hover {
    background: #005fcc;
}
button {
    font-family: inherit;
}

/* ---- Forms ---- */
.form-group {
    margin-bottom: 20px;
}
label {
    display: block;
    margin-bottom: 8px;
    font-weight: 500;
    color: #333;
}
input[type="text"],
input[type="password"],
input[type="email"],
textarea,
select {
    width: 100%;
    padding: 12px;
    border: 1px solid #ccc;
    border-radius: 6px;
    font-size: 16px;
    font-family: inherit;
}
input:focus,
textarea:focus,
select:focus {
    outline: none;
    border-color: #007aff;
}

/* ---- Flash messages ---- */
.flash-messages {
    margin-bottom: 20px;
}
.flash-message {
    padding: 12px;
    border-radius: 6px;
    margin-bottom: 12px;
}
.flash-success {
    background: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
}
.flash-error {
    background: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
}
.flash-info {
    background: #d1ecf1;
    color: #0c5460;
    border: 1px solid #bee5eb;
}

/* ---- Feedback modal ---- */
.feedback-modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.5);
    padding: 12px;
}
.feedback-modal.show {
    display: flex;
    align-items: center;
    justify-content: center;
}
.feedback-modal-content {
    background: white;
    padding: 24px;
    border-radius: 8px;
    width: calc(100% - 24px);
    max-width: 480px;
    box-sizing: border-box;
}
.feedback-modal h3 {
    margin: 0 0 16px 0;
    font-size: 18px;
}
.feedback-modal textarea {
    width: 100%;
    min-height: 120px;
    padding: 10px;
    border: 1px solid #ccc;
    border-radius: 6px;
    font-size: 14px;
    box-sizing: border-box;
    resize: vertical;
}
.feedback-modal .modal-actions {
    margin-top: 16px;
    display: flex;
    justify-content: flex-end;
    gap: 8px;
}
.feedback-modal .modal-actions button {
    padding: 8px 16px;
    border-radius: 4px;
    border: none;
    cursor: pointer;
    font-size: 14px;
}
.feedback-modal .btn-cancel {
    background: #6c757d;
    color: white;
}
.feedback-modal .btn-submit {
    background: #007aff;
    color: white;
}
body.modal-open {
    overflow: hidden;
}

/* ---- Generic modal ---- */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    overflow: auto;
}
.modal-content {
    background-color: #fff;
    margin: 5% auto;
    padding: 24px;
    border-radius: 8px;
    max-width: 500px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}
.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding-bottom: 12px;
    border-bottom: 1px solid #e0e0e0;
}
.modal-header h3 {
    margin: 0;
    font-size: 18px;
}
.modal .close {
    color: #aaa;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
    border: none;
    background: none;
    padding: 0;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
}
.modal .close:hover {
    color: #000;
}

/* ---- Overlay modals (index: новый проект, сменить проект, список расшифровок спикера) ---- */
.modal-overlay {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    padding: 16px;
    box-sizing: border-box;
    background: rgba(0, 0, 0, 0.5);
    align-items: center;
    justify-content: center;
}
.modal-overlay.show {
    display: flex;
}
.modal-box {
    background: #fff;
    padding: 24px;
    border-radius: 8px;
    width: 90%;
    max-width: 420px;
    max-height: 90vh;
    overflow-y: auto;
    box-sizing: border-box;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.18);
}
.modal-box h3 {
    margin: 0 0 16px;
    font-size: 18px;
}
.modal-box input,
.modal-box textarea {
    width: 100%;
    padding: 10px;
    border: 1px solid #ccc;
    border-radius: 6px;
    font-size: 14px;
    font-family: inherit;
    box-sizing: border-box;
    margin-bottom: 10px;
}
.modal-box textarea {
    min-height: 80px;
    resize: vertical;
}
.modal-box .modal-btns {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    margin-top: 8px;
    flex-wrap: wrap;
}
.modal-box .modal-btns button {
    padding: 8px 16px;
    border-radius: 4px;
    border: none;
    cursor: pointer;
    font-size: 14px;
    font-family: inherit;
}
.modal-btn {
    display: inline-block;
    padding: 8px 14px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    font-family: inherit;
    line-height: 1.2;
    appearance: none;
    -webkit-appearance: none;
}
.modal-btn--primary {
    background: #007aff;
    color: #fff;
    border: none;
}
.modal-btn--primary:hover {
    background: #005fcc;
    color: #fff;
}
.modal-btn--danger {
    background: #fff3f3;
    color: #d32f2f;
    border: 1px solid #f0c2c2;
}
.modal-btn--danger:hover {
    background: #ffe8e8;
    color: #c62828;
}
.modal-btn--neutral {
    background: #6c757d;
    color: #fff;
    border: none;
}
.modal-btn--neutral:hover {
    background: #5a6268;
    color: #fff;
}

/* ---- Auth container (login, register, pending) ---- */
body.body-auth {
    background: #f5f5f5;
    display: flex;
    flex-direction: column;
    align-items: stretch;
    min-height: 100vh;
}
.auth-container {
    background: white;
    padding: 40px;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    width: 100%;
    max-width: 400px;
    align-self: center;
}
.link {
    text-align: center;
    margin-top: 16px;
}
.link a {
    color: #007aff;
    text-decoration: none;
}
.link a:hover {
    text-decoration: underline;
}

/* ---- Info box ---- */
.info-box {
    padding: 16px;
    background: #e7f3ff;
    border: 1px solid #b3d7ff;
    border-radius: 6px;
    margin-bottom: 20px;
    color: #0c5460;
}
.info-box-warning {
    background: #fff3cd;
    color: #856404;
    border: 1px solid #ffeaa7;
    padding: 20px;
}
.info-box-warning p { margin-bottom: 12px; }
.info-box-warning p:last-child { margin-bottom: 0; }
.logout-btn {
    display: inline-block;
    margin-top: 16px;
    padding: 8px 16px;
    background: #dc3545;
    color: white;
    text-decoration: none;
    border-radius: 6px;
    font-size: 14px;
}
.logout-btn:hover {
    background: #c82333;
    color: white;
    text-decoration: none;
}
.pending-container {
    background: white;
    padding: 40px;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    width: 100%;
    max-width: 500px;
    text-align: center;
    align-self: center;
}
.pending-container .link { margin-top: 24px; }

.success-icon { font-size: 48px; margin-bottom: 16px; }
.redirect-info { margin: 16px 0; color: #666; font-size: 14px; }
.btn {
    display: inline-block;
    padding: 10px 20px;
    background: #007aff;
    color: white;
    text-decoration: none;
    border-radius: 6px;
    font-size: 16px;
    font-weight: 500;
}
.btn:hover { color: white; text-decoration: none; background: #005fcc; }

/* ---- Spinner ---- */
.spinner {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 3px solid rgba(0,122,255,0.3);
    border-radius: 50%;
    border-top-color: #007aff;
    animation: spin 1s linear infinite;
    margin-right: 12px;
}
@keyframes spin {
    to { transform: rotate(360deg); }
}
.spinner-inline {
    display: inline-block;
    width: 14px;
    height: 14px;
    border: 2px solid rgba(0,122,255,0.3);
    border-radius: 50%;
    border-top-color: #007aff;
    animation: spin 1s linear infinite;
    margin-left: 8px;
    vertical-align: middle;
}

/* ---- Status ---- */
.status-processing {
    color: #007aff;
    font-style: italic;
    font-size: 14px;
}
.status-error {
    padding: 24px;
    background: #ffe6e6;
    border: 1px solid #ffcdd2;
    border-radius: 6px;
    color: #d32f2f;
    margin-bottom: 24px;
}
.status-failed {
    color: #d32f2f;
    font-weight: 500;
}
.status-queued {
    color: #856404;
    font-style: italic;
    font-size: 14px;
}
.queued-badge {
    background: #fff3cd;
    color: #856404;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 500;
    margin-left: 6px;
}

/* ---- Mobile: header menu ---- */
@media (max-width: 900px) {
    .header {
        align-items: center;
        gap: 10px;
    }
    .header-actions {
        width: 100%;
        justify-content: space-between;
    }
    .menu-toggle {
        display: inline-flex;
        align-items: center;
        justify-content: center;
    }
    .user-info {
        position: absolute;
        top: calc(100% + 8px);
        right: 0;
        display: none;
        flex-direction: column;
        align-items: stretch;
        gap: 10px;
        padding: 12px;
        background: #fff;
        border: 1px solid #e0e0e0;
        border-radius: 8px;
        box-shadow: 0 6px 16px rgba(0,0,0,0.1);
        z-index: 500;
        min-width: 220px;
    }
    .header.menu-open .user-info {
        display: flex;
    }
    .user-info .user-actions,
    .user-info .admin-actions {
        width: 100%;
        align-items: stretch;
    }
    .user-info .user-name {
        font-size: 13px;
        color: #777;
    }
    .user-info .header-btn,
    .user-info .nav-link {
        width: 100%;
        text-align: center;
        margin-left: 0;
    }
    .user-info .nav-link {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        height: 32px;
        border: 1px solid #d0d0d0;
        border-radius: 4px;
        color: #333;
        background: #f8f8f8;
        text-decoration: none;
        font-size: 13px;
    }
    .user-info .nav-link.admin-link {
        color: #dc3545;
        border-color: #f0c2c2;
        background: #fff7f7;
    }
}

@media (max-width: 768px) {
    .header {
        margin-bottom: 20px;
        padding-bottom: 12px;
    }
    .header-btn {
        height: 30px;
        padding: 6px 10px;
        font-size: 12px;
    }
    .menu-toggle {
        height: 30px;
    }
    [data-tooltip]::after,
    .info-icon::after {
        max-width: calc(100vw - 24px);
        white-space: normal;
    }
    .auth-container {
        padding: 24px;
        border-radius: 10px;
        box-shadow: 0 2px 6px rgba(0,0,0,0.08);
    }
    .feedback-modal textarea {
        font-size: 16px;
    }
}

@media (max-width: 700px) {
    [data-tooltip]::after,
    .info-icon::after {
        display: none !important;
        content: none !important;
    }
    .info-icon {
        display: none !important;
    }
}

@media (max-width: 480px) {
    .auth-container {
        padding: 20px;
    }
    .link {
        margin-top: 12px;
    }
}
