/* ==========================================================================
   North - Modern Custom Dialog System (Alerts & Confirms)
   Clean, crafted UI inspired by native macOS sheets and Linear / Radix design.
   ========================================================================== */

/* Zabránění poskakování obsahu při načtení a změně výšky stránky */
html {
    scrollbar-gutter: stable;
}

@supports not (scrollbar-gutter: stable) {
    html {
        overflow-y: scroll;
    }
}

.custom-dialog-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(15, 23, 42, 0.48);
    backdrop-filter: blur(5px);
    -webkit-backdrop-filter: blur(5px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100000;
    padding: 16px;
    box-sizing: border-box;
    opacity: 0;
    transition: opacity 0.12s ease-out;
    pointer-events: auto;
}

.custom-dialog-overlay.active {
    opacity: 1;
}

.custom-dialog-overlay.closing {
    opacity: 0;
}

/* Dialog Card - desktop size slightly enlarged */
.custom-dialog-card {
    background: #ffffff;
    color: #0f172a;
    width: 100%;
    max-width: 490px;
    border-radius: 14px;
    padding: 22px 24px 20px 24px;
    box-sizing: border-box;
    box-shadow: 0 20px 35px -8px rgba(0, 0, 0, 0.12), 0 6px 14px -2px rgba(0, 0, 0, 0.04), 0 0 0 1px rgba(15, 23, 42, 0.08);
    transform: scale(0.96) translateY(-4px);
    opacity: 0;
    transition: transform 0.13s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.11s ease-out;
    position: relative;
    font-family: 'Poppins', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    overflow: hidden;
}

body.dark-mode .custom-dialog-card {
    background: #1e1e28;
    color: #f1f5f9;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.75), 0 0 0 1px rgba(255, 255, 255, 0.08), inset 0 1px 0 rgba(255, 255, 255, 0.06);
}

.custom-dialog-overlay.active .custom-dialog-card {
    transform: scale(1) translateY(0);
    opacity: 1;
}

.custom-dialog-overlay.closing .custom-dialog-card {
    transform: scale(0.97) translateY(2px);
    opacity: 0;
}

/* Header (Icon + Title + Close button) */
.custom-dialog-header {
    display: flex;
    align-items: flex-start;
    gap: 14px;
    position: relative;
}

/* Compact status badge (38x38 squircle) */
.custom-dialog-icon {
    width: 38px;
    height: 38px;
    min-width: 38px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-sizing: border-box;
    margin-top: 1px;
}

/* Type variations for badges */
.custom-dialog-card.type-success .custom-dialog-icon {
    background: rgba(22, 163, 74, 0.1);
    color: #16a34a;
    border: 1px solid rgba(22, 163, 74, 0.22);
}
body.dark-mode .custom-dialog-card.type-success .custom-dialog-icon {
    background: rgba(34, 197, 94, 0.14);
    color: #4ade80;
    border-color: rgba(34, 197, 94, 0.26);
}

.custom-dialog-card.type-warning .custom-dialog-icon {
    background: rgba(245, 158, 11, 0.1);
    color: #d97706;
    border: 1px solid rgba(245, 158, 11, 0.22);
}
body.dark-mode .custom-dialog-card.type-warning .custom-dialog-icon {
    background: rgba(245, 158, 11, 0.14);
    color: #fbbf24;
    border-color: rgba(245, 158, 11, 0.3);
}

.custom-dialog-card.type-info .custom-dialog-icon {
    background: rgba(15, 112, 215, 0.09);
    color: #0f70d7;
    border: 1px solid rgba(15, 112, 215, 0.22);
}
body.dark-mode .custom-dialog-card.type-info .custom-dialog-icon {
    background: rgba(15, 112, 215, 0.16);
    color: #60a5fa;
    border-color: rgba(15, 112, 215, 0.3);
}

.custom-dialog-card.type-error .custom-dialog-icon {
    background: rgba(220, 38, 38, 0.1);
    color: #dc2626;
    border: 1px solid rgba(220, 38, 38, 0.22);
}
body.dark-mode .custom-dialog-card.type-error .custom-dialog-icon {
    background: rgba(239, 68, 68, 0.14);
    color: #f87171;
    border-color: rgba(239, 68, 68, 0.3);
}

.custom-dialog-header-text {
    flex: 1;
    min-width: 0;
    padding-top: 6px;
}

.custom-dialog-title {
    margin: 0;
    font-size: 1.12rem;
    font-weight: 600;
    letter-spacing: -0.015em;
    line-height: 1.35;
    color: inherit;
    text-align: left;
}

/* Close Button */
.custom-dialog-close {
    background: transparent;
    border: none;
    color: #94a3b8;
    cursor: pointer;
    width: 30px;
    height: 30px;
    border-radius: 7px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    transition: background 0.1s ease, color 0.1s ease;
    margin-top: 1px;
    margin-right: -4px;
}

.custom-dialog-close:hover {
    background: rgba(15, 23, 42, 0.06);
    color: #0f172a;
}

body.dark-mode .custom-dialog-close:hover {
    background: rgba(255, 255, 255, 0.08);
    color: #f8fafc;
}

/* Body / Message (Aligned with title on desktop) */
.custom-dialog-body {
    margin-top: 10px;
    padding-left: 52px;
    text-align: left;
}

.custom-dialog-message {
    font-size: 0.95rem;
    line-height: 1.6;
    color: #475569;
    white-space: pre-line;
    word-break: break-word;
    margin: 0;
    max-height: 48vh;
    overflow-y: auto;
}

body.dark-mode .custom-dialog-message {
    color: #94a3b8;
}

/* Actions Footer (Right-aligned on desktop) */
.custom-dialog-actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 22px;
    padding-top: 16px;
    border-top: 1px solid rgba(15, 23, 42, 0.06);
}

body.dark-mode .custom-dialog-actions {
    border-top: 1px solid rgba(255, 255, 255, 0.07);
}

.custom-dialog-btn {
    appearance: none;
    -webkit-appearance: none;
    border: none;
    outline: none;
    cursor: pointer;
    font-family: 'Poppins', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    font-size: 0.9rem;
    font-weight: 500;
    padding: 8px 18px;
    border-radius: 8px;
    transition: background-color 0.12s ease, border-color 0.12s ease, transform 0.08s ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    min-height: 38px;
    box-sizing: border-box;
}

.custom-dialog-btn:active {
    transform: scale(0.98);
}

.custom-dialog-btn:focus-visible {
    outline: 2px solid var(--primary-color, #0f70d7);
    outline-offset: 2px;
}

/* Secondary / Cancel Button (Clean ghost style) */
.custom-dialog-btn-secondary {
    background: transparent;
    color: #475569;
    border: 1px solid #d1d5db;
}

.custom-dialog-btn-secondary:hover {
    background: #f3f4f6;
    color: #111827;
    border-color: #9ca3af;
}

body.dark-mode .custom-dialog-btn-secondary {
    background: transparent;
    color: #cbd5e1;
    border: 1px solid rgba(255, 255, 255, 0.14);
}

body.dark-mode .custom-dialog-btn-secondary:hover {
    background: rgba(255, 255, 255, 0.06);
    color: #ffffff;
    border-color: rgba(255, 255, 255, 0.24);
}

/* Primary Button */
.custom-dialog-btn-primary {
    background: #0f70d7;
    color: #ffffff;
    border: 1px solid transparent;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.06);
}

.custom-dialog-btn-primary:hover {
    background: #0b5aa2;
}

/* Type variations for primary action */
.type-success .custom-dialog-btn-primary {
    background: #16a34a;
}
.type-success .custom-dialog-btn-primary:hover {
    background: #15803d;
}

.type-warning .custom-dialog-btn-primary {
    background: #d97706;
}
.type-warning .custom-dialog-btn-primary:hover {
    background: #b45309;
}

.type-error .custom-dialog-btn-primary,
.custom-dialog-btn-danger {
    background: #dc2626 !important;
    color: #ffffff !important;
}
.type-error .custom-dialog-btn-primary:hover,
.custom-dialog-btn-danger:hover {
    background: #b91c1c !important;
}

/* Mobile responsive - stacked buttons */
@media (max-width: 560px) {
    .custom-dialog-overlay {
        padding: 14px;
    }

    .custom-dialog-card {
        max-width: 100%;
        padding: 20px 18px 18px 18px;
        border-radius: 14px;
    }

    .custom-dialog-header {
        gap: 12px;
    }

    .custom-dialog-body {
        padding-left: 0;
        margin-top: 12px;
    }

    .custom-dialog-message {
        font-size: 0.94rem;
        line-height: 1.55;
    }

    .custom-dialog-actions {
        flex-direction: column-reverse; /* Primary on top, cancel underneath */
        gap: 10px;
        margin-top: 20px;
        padding-top: 16px;
        width: 100%;
    }

    .custom-dialog-btn {
        width: 100%;
        min-height: 44px; /* Mobile touch-friendly target */
        font-size: 0.95rem;
        font-weight: 500;
        border-radius: 9px;
    }
}
