/*
 * dialog-base.css
 *
 * Base styles for all modal dialogs in the Voice Flipper application.
 * Uses the db- prefix to avoid conflicts with existing dialog-specific styles.
 *
 * Design language: dark card (#111118), gradient header, bevel buttons,
 * teal accent — consistent with the main panel, login, and splash screen.
 */

/* *******************************************************
 * Dark mode scrollbars — applied to all dialog scroll areas
 * ******************************************************* */

.db-body,
.db-dialog {
    scrollbar-width: thin;
    scrollbar-color: rgba(255, 255, 255, 0.18) transparent;
}

.db-body::-webkit-scrollbar,
.db-dialog::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

.db-body::-webkit-scrollbar-track,
.db-dialog::-webkit-scrollbar-track {
    background: transparent;
}

.db-body::-webkit-scrollbar-thumb,
.db-dialog::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.18);
    border-radius: 3px;
}

.db-body::-webkit-scrollbar-thumb:hover,
.db-dialog::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.32);
}

/* *******************************************************
 * Overlay
 * ******************************************************* */

.db-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.75);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
}

/* *******************************************************
 * Dialog container variants
 * ******************************************************* */

.db-dialog {
    background: #16161f;
    border-radius: 16px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
    max-width: 500px;
    width: 100%;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.db-dialog-sm {
    max-width: 400px;
}

.db-dialog-wide {
    max-width: 700px;
}

.db-dialog-fullscreen {
    width: 100%;
    height: 100%;
    max-width: 100%;
    max-height: 100%;
    border-radius: 16px;
}

/* *******************************************************
 * Header — gradient bar with title and close button
 * ******************************************************* */

.db-header {
    --db-header-color1: #2d2d3e;
    --db-header-color2: #1a1a28;
    padding: 18px 24px;
    display: flex;
    align-items: center;
    gap: 15px;
    background: linear-gradient(135deg, var(--db-header-color1) 0%, var(--db-header-color2) 100%);
    border-bottom: 1px solid rgba(255, 255, 255, 0.07);
    border-radius: 16px 16px 0 0;
    flex-shrink: 0;
}

.db-header h2 {
    margin: 0;
    font-size: 1.25rem;
    font-weight: 700;
    color: white;
    flex: 1;
    font-family: 'Sora', sans-serif;
}

/* Count/badge indicators inside the gradient header */
.db-header .voice-count-indicator,
.db-header .flip-count-indicator {
    background: rgba(255, 255, 255, 0.25) !important;
    background-color: rgba(255, 255, 255, 0.25) !important;
    box-shadow: none !important;
    color: white !important;
    flex-shrink: 0;
}

.db-close-btn {
    background: rgba(255, 255, 255, 0.18);
    border: none;
    font-size: 1.6rem;
    line-height: 1;
    color: white;
    cursor: pointer;
    padding: 0;
    width: 34px;
    height: 34px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: background 0.2s ease, transform 0.1s ease;
    flex-shrink: 0;
}

.db-close-btn:hover {
    background: rgba(255, 255, 255, 0.3);
}

.db-close-btn:active {
    transform: scale(0.92);
}

/* *******************************************************
 * Body
 * ******************************************************* */

.db-body {
    padding: 20px 24px;
    flex: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 16px;
    background: #1e2030;
    color: rgba(255, 255, 255, 0.75);
    font-family: 'Inter', sans-serif;
}

/* *******************************************************
 * Footer with status bar
 * ******************************************************* */

.db-footer {
    flex-shrink: 0;
    min-height: 42px;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 0 0 16px 16px;
    background: #16161f;
    display: flex;
    align-items: stretch;
}

/* Column layout for footers that stack scroll-hint above buttons */
.db-footer-col {
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
    padding: 14px 24px;
}

.db-footer .db-status {
    flex: 1;
    padding: 10px 15px;
    margin: 0;
    background: rgba(45, 212, 191, 0.12);
    color: rgba(45, 212, 191, 0.9);
    border-radius: 0 0 16px 16px;
    font-size: 0.88rem;
    font-weight: 500;
    font-family: 'Inter', sans-serif;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    flex-wrap: wrap;
    word-break: break-word;
}

.db-status.hidden {
    display: none;
}

/* Footer status: stay in layout flow so the dialog height never shifts */
.db-footer .db-status.hidden {
    display: flex;
    visibility: hidden;
}

.db-footer .db-status.error {
    background: rgba(211, 47, 47, 0.25);
    color: #ff8080;
    border: none;
}

.db-footer .db-status.success {
    background: rgba(45, 212, 191, 0.2);
    color: #2dd4bf;
    border: none;
}

.db-footer .db-status.info {
    background: rgba(45, 212, 191, 0.12);
    color: rgba(45, 212, 191, 0.9);
    border: none;
}

/* *******************************************************
 * Buttons — bevel style matching the app
 * ******************************************************* */

.db-btn {
    padding: 12px 24px;
    border-left: none;
    border-right: none;
    border-radius: 0;
    font-size: 0.9rem;
    font-weight: 700;
    cursor: pointer;
    font-family: 'Sora', sans-serif;
    transition: background 0.15s ease, border-color 0.1s ease, transform 0.1s ease;
    min-width: 90px;
}

/* Primary — teal bevel */
.db-btn-primary {
    background: #2dd4bf;
    border-top: 3px solid #5ef0de;
    border-bottom: 3px solid #0f8a7a;
    color: #0a2218;
}

.db-btn-primary:hover:not(:disabled) {
    background: #3de0cb;
    border-top-color: #72f4e6;
    border-bottom-color: #1aaa8e;
}

.db-btn-primary:active:not(:disabled) {
    background: #25b8a4;
    border-top-color: #0f8a7a;
    border-bottom-color: #5ef0de;
    transform: translateY(1px);
}

/* Secondary — dark bevel */
.db-btn-secondary {
    background: #3a3a3a;
    border-top: 3px solid #606060;
    border-bottom: 3px solid #181818;
    color: rgba(255, 255, 255, 0.88);
}

.db-btn-secondary:hover:not(:disabled) {
    background: #484848;
    border-top-color: #787878;
    border-bottom-color: #202020;
    color: rgba(255, 255, 255, 1);
}

.db-btn-secondary:active:not(:disabled) {
    background: #2e2e2e;
    border-top-color: #181818;
    border-bottom-color: #606060;
    transform: translateY(1px);
}

/* Danger — red bevel */
.db-btn-danger {
    background: #c0392b;
    border-top: 3px solid #e74c3c;
    border-bottom: 3px solid #7b0e0e;
    color: white;
}

.db-btn-danger:hover:not(:disabled) {
    background: #d44636;
    border-top-color: #f05a4a;
    border-bottom-color: #9b1515;
}

.db-btn-danger:active:not(:disabled) {
    background: #a93226;
    border-top-color: #7b0e0e;
    border-bottom-color: #e74c3c;
    transform: translateY(1px);
}

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

.db-btn-container {
    display: flex;
    justify-content: center;
    gap: 12px;
}

/* *******************************************************
 * Scroll hint — used in consent dialogs (ToS, biometrics)
 * ******************************************************* */

/* Inline status boxes (not in footer, e.g. sub-dialogs) */
.db-status.error {
    background: rgba(211, 47, 47, 0.25);
    color: #ff8080;
    border: 1px solid rgba(211, 47, 47, 0.4);
    padding: 10px 14px;
    border-radius: 6px;
    font-size: 0.9rem;
}

.db-status.success {
    background: rgba(45, 212, 191, 0.2);
    color: #2dd4bf;
    border: 1px solid rgba(45, 212, 191, 0.3);
    padding: 10px 14px;
    border-radius: 6px;
    font-size: 0.9rem;
}

.db-status.info {
    background: rgba(45, 212, 191, 0.1);
    color: rgba(45, 212, 191, 0.9);
    border: 1px solid rgba(45, 212, 191, 0.2);
    padding: 10px 14px;
    border-radius: 6px;
    font-size: 0.9rem;
}

.db-status.loading {
    background: rgba(45, 212, 191, 0.1);
    color: #2dd4bf;
    border: 1px solid rgba(45, 212, 191, 0.2);
    padding: 10px 14px;
    border-radius: 6px;
    font-size: 0.9rem;
}

/* *******************************************************
 * Scroll hint — used in consent dialogs (ToS, biometrics)
 * ******************************************************* */

.db-scroll-hint {
    font-size: 0.82rem;
    color: rgba(255, 255, 255, 0.35);
    text-align: center;
    transition: opacity 0.3s ease;
    font-family: 'Inter', sans-serif;
}

.db-scroll-hint.hidden {
    opacity: 0;
    visibility: hidden;
}

/* *******************************************************
 * Form elements — dark style matching login/create account
 * ******************************************************* */

.db-form-group {
    margin-bottom: 16px;
}

.db-form-group label {
    display: block;
    font-size: 0.85rem;
    font-weight: 600;
    color: rgba(255, 255, 255, 0.55);
    margin-bottom: 6px;
    font-family: 'Inter', sans-serif;
}

.db-input {
    width: 100%;
    height: 46px;
    padding: 12px 14px;
    background: rgba(255, 255, 255, 0.07);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 6px;
    font-size: 0.95rem;
    font-family: 'Inter', sans-serif;
    color: rgba(255, 255, 255, 0.9);
    box-sizing: border-box;
    transition: border-color 0.2s ease;
    outline: none;
}

.db-input:focus {
    border-color: rgba(45, 212, 191, 0.5);
}

.db-input::placeholder {
    color: rgba(255, 255, 255, 0.28);
}

.db-select {
    width: 100%;
    height: 46px;
    padding: 12px 14px;
    background: rgba(255, 255, 255, 0.07);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 6px;
    font-size: 0.95rem;
    font-family: 'Inter', sans-serif;
    color: rgba(255, 255, 255, 0.9);
    box-sizing: border-box;
    transition: border-color 0.2s ease;
    outline: none;
    cursor: pointer;
    appearance: auto;
    color-scheme: dark;
}

.db-select:focus {
    border-color: rgba(45, 212, 191, 0.5);
}

.db-select:hover {
    border-color: rgba(255, 255, 255, 0.2);
}

/* Global dark mode for all select elements inside dialogs */
.db-body select,
.db-dialog select {
    background: rgba(255, 255, 255, 0.07);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 6px;
    color: rgba(255, 255, 255, 0.9);
    color-scheme: dark;
    outline: none;
    cursor: pointer;
    transition: border-color 0.2s ease;
}

.db-body select:focus,
.db-dialog select:focus {
    border-color: rgba(45, 212, 191, 0.5);
}

.db-body select:hover,
.db-dialog select:hover {
    border-color: rgba(255, 255, 255, 0.2);
}

.db-textarea {
    width: 100%;
    padding: 10px 14px;
    background: rgba(255, 255, 255, 0.07);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 6px;
    font-size: 0.95rem;
    font-family: 'Inter', sans-serif;
    color: rgba(255, 255, 255, 0.9);
    box-sizing: border-box;
    transition: border-color 0.2s ease;
    resize: vertical;
    outline: none;
}

.db-textarea:focus {
    border-color: rgba(45, 212, 191, 0.5);
}

.db-textarea::placeholder {
    color: rgba(255, 255, 255, 0.28);
}

/* *******************************************************
 * Tables inside dialog body — dark mode base
 * ******************************************************* */

.db-body table {
    width: 100%;
    border-collapse: collapse;
}

.db-body th {
    position: sticky;
    top: 0;
    z-index: 10;
    padding: 10px 12px;
    text-align: left;
    font-weight: 600;
    color: rgba(255, 255, 255, 0.55);
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    font-size: 0.85rem;
    font-family: 'Inter', sans-serif;
    background: #1e2030;
}

.db-body td {
    padding: 10px 12px;
    vertical-align: middle;
    color: rgba(255, 255, 255, 0.82);
    font-size: 0.9rem;
    font-family: 'Inter', sans-serif;
}

.db-body tbody tr {
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
    transition: background-color 0.15s ease;
}

.db-body tbody tr:hover {
    background-color: rgba(255, 255, 255, 0.05);
}

.db-body tbody tr.selected {
    background-color: rgba(45, 212, 191, 0.18);
}

/* *******************************************************
 * Responsive — mobile phones: all dialogs go full screen
 * ******************************************************* */

@media (max-width: 600px) {
    /* All overlays: fill the screen with no padding, stretch child to full height */
    .db-overlay,
    .modal-overlay,
    .mv-modal-overlay,
    .mf-modal-overlay,
    .mau-modal-overlay,
    .mua-modal-overlay,
    .cpw-modal-overlay,
    .fpw-modal-overlay,
    .df-modal-overlay,
    .sf-modal-overlay,
    .managepron-modal-overlay,
    .changelog-modal-overlay,
    .managetemplates-modal-overlay,
    .testemail-modal-overlay,
    .mav-modal-overlay,
    .tos-overlay {
        padding: 0;
        align-items: stretch;
    }

    /* All dialog containers: full screen */
    .db-dialog,
    .db-dialog-sm,
    .db-dialog-wide,
    .modal-dialog,
    .mv-modal-dialog,
    .mv-modal-dialog-small,
    .mf-modal-dialog,
    .mf-modal-dialog-small,
    .mau-modal-dialog,
    .mau-modal-dialog-small,
    .mua-modal-dialog,
    .cpw-modal-dialog,
    .fpw-modal-dialog,
    .df-modal-dialog,
    .sf-modal-dialog,
    .managepron-modal-dialog,
    .changelog-modal-dialog,
    .managetemplates-modal-dialog,
    .testemail-modal-dialog,
    .mav-modal-dialog,
    .tos-dialog {
        max-width: 100%;
        width: 100%;
        max-height: 100dvh;
        height: 100dvh;
        border-radius: 0;
        margin: 0;
    }

    /* Remove rounded corners from header/footer to match full-screen edges */
    .db-header {
        border-radius: 0;
    }

    .db-footer,
    .db-footer .db-status {
        border-radius: 0;
    }

    /* Button layout */
    .db-btn-container {
        flex-direction: column;
        gap: 10px;
    }

    .db-btn {
        width: 100%;
        min-width: unset;
    }
}
