/* ============================================
   PROFESSIONAL POPUP & MODAL DESIGN SYSTEM
   ============================================ */

/* ============================================
   AURELIA CONTACTS - PROFESSIONAL POPUP SYSTEM
   Matches website theme: Indigo/Purple gradients
   ============================================ */

/* Custom Alert & Confirm Dialog Overlay - Light blue tint for consistency */
.custom-dialog-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(102, 126, 234, 0.15);
    backdrop-filter: blur(12px);
    z-index: 10000;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    animation: fadeIn 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.custom-dialog-overlay.active {
    display: flex;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

@keyframes slideUp {
    from {
        transform: translateY(30px) scale(0.95);
        opacity: 0;
    }

    to {
        transform: translateY(0) scale(1);
        opacity: 1;
    }
}

@keyframes shake {

    0%,
    100% {
        transform: translateX(0);
    }

    10%,
    30%,
    50%,
    70%,
    90% {
        transform: translateX(-5px);
    }

    20%,
    40%,
    60%,
    80% {
        transform: translateX(5px);
    }
}

/* Dialog Container */
.custom-dialog {
    background: white;
    border-radius: 24px;
    padding: 0;
    box-shadow: 0 32px 64px -12px rgba(0, 0, 0, 0.35), 0 0 0 1px rgba(0, 0, 0, 0.08);
    max-width: 480px;
    width: 100%;
    max-height: 90vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    animation: slideUp 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.custom-dialog.shake {
    animation: shake 0.5s ease-in-out;
}

/* Dialog Icon Section - Matches website's gradient aesthetic */
.dialog-icon-section {
    padding: 2.5rem 2rem 1.5rem;
    text-align: center;
    background: linear-gradient(135deg, #f8fafc 0%, #f1f5f9 100%);
    border-bottom: 1px solid #e2e8f0;
    position: relative;
}

.dialog-icon-section::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(135deg, rgba(102, 126, 234, 0.03) 0%, rgba(118, 75, 162, 0.03) 100%);
    pointer-events: none;
}

.dialog-icon {
    width: 80px;
    height: 80px;
    margin: 0 auto 1.5rem;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2.5rem;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.15);
    animation: iconPulse 0.6s ease-in-out;
}

@keyframes iconPulse {

    0%,
    100% {
        transform: scale(1);
    }

    50% {
        transform: scale(1.1);
    }
}

/* Dialog Icon Types - Matching website color scheme */
.dialog-icon.success {
    background: linear-gradient(135deg, #10b981, #059669);
    box-shadow: 0 8px 20px rgba(16, 185, 129, 0.25);
}

.dialog-icon.error {
    background: linear-gradient(135deg, #ef4444, #dc2626);
    box-shadow: 0 8px 20px rgba(239, 68, 68, 0.25);
}

.dialog-icon.warning {
    background: linear-gradient(135deg, #f59e0b, #d97706);
    box-shadow: 0 8px 20px rgba(245, 158, 11, 0.25);
}

.dialog-icon.info {
    background: linear-gradient(135deg, #667eea, #764ba2);
    box-shadow: 0 8px 20px rgba(102, 126, 234, 0.25);
}

.dialog-icon.confirm {
    background: linear-gradient(135deg, #667eea, #764ba2);
    box-shadow: 0 8px 20px rgba(102, 126, 234, 0.25);
}

/* Dialog Content */
.dialog-content {
    padding: 1.5rem 2rem;
    overflow-y: auto;
    flex: 1;
}

.dialog-title {
    font-size: 1.5rem;
    font-weight: 800;
    color: #1e293b;
    margin: 0 0 0.75rem 0;
    text-align: center;
    letter-spacing: -0.025em;
}

.dialog-message {
    font-size: 1rem;
    color: #475569;
    line-height: 1.7;
    text-align: center;
    margin: 0;
    white-space: pre-wrap;
}

/* Dialog Input (for prompts) */
.dialog-input {
    width: 100%;
    padding: 0.875rem 1.125rem;
    border: 2px solid #e2e8f0;
    border-radius: 12px;
    font-size: 1rem;
    color: #1e293b;
    margin-top: 1rem;
    background: #f8fafc;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
}

.dialog-input:focus {
    outline: none;
    border-color: #667eea;
    background: white;
    box-shadow: 0 0 0 4px rgba(102, 126, 234, 0.1);
}

/* Dialog Actions */
.dialog-actions {
    display: flex;
    gap: 0.75rem;
    padding: 1.5rem 2rem 2rem;
    background: #f8fafc;
    border-top: 1px solid #e2e8f0;
}

.dialog-btn {
    flex: 1;
    padding: 0.875rem 1.5rem;
    border: none;
    border-radius: 12px;
    font-size: 1rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    letter-spacing: 0.025em;
    white-space: nowrap;
}

.dialog-btn:hover {
    transform: translateY(-2px);
}

.dialog-btn:active {
    transform: translateY(0);
}

.dialog-btn-primary {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    box-shadow: 0 6px 20px rgba(102, 126, 234, 0.35);
}

.dialog-btn-primary:hover {
    box-shadow: 0 8px 24px rgba(102, 126, 234, 0.45);
    background: linear-gradient(135deg, #7c8ef0 0%, #8b5cb8 100%);
}

.dialog-btn-success {
    background: linear-gradient(135deg, #10b981, #059669);
    color: white;
    box-shadow: 0 6px 20px rgba(16, 185, 129, 0.35);
}

.dialog-btn-success:hover {
    box-shadow: 0 8px 24px rgba(16, 185, 129, 0.45);
}

.dialog-btn-danger {
    background: linear-gradient(135deg, #ef4444, #dc2626);
    color: white;
    box-shadow: 0 6px 20px rgba(239, 68, 68, 0.35);
}

.dialog-btn-danger:hover {
    box-shadow: 0 8px 24px rgba(239, 68, 68, 0.45);
}

.dialog-btn-secondary {
    background: white;
    color: #64748b;
    border: 2px solid #e2e8f0;
    box-shadow: none;
}

.dialog-btn-secondary:hover {
    background: #f8fafc;
    border-color: #cbd5e1;
    color: #475569;
}

/* Enhanced Modal Styles - Light blue overlay */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(102, 126, 234, 0.15);
    backdrop-filter: blur(12px);
    z-index: 2000;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    animation: fadeIn 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

.modal.active {
    display: flex;
}

.modal-content {
    background: white;
    border-radius: 24px;
    padding: 0;
    max-width: 600px;
    width: 100%;
    max-height: 90vh;
    overflow: hidden;
    box-shadow: 0 32px 64px -12px rgba(0, 0, 0, 0.35), 0 0 0 1px rgba(0, 0, 0, 0.08);
    display: flex;
    flex-direction: column;
    animation: slideUp 0.35s cubic-bezier(0.4, 0, 0.2, 1);
}

.modal-header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 2rem 2.5rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: relative;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.modal-header::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.1) 0%, transparent 100%);
    pointer-events: none;
}

.modal-title {
    margin: 0;
    font-size: 1.625rem;
    font-weight: 800;
    letter-spacing: -0.025em;
    position: relative;
    z-index: 1;
}

.modal-close {
    background: rgba(255, 255, 255, 0.15);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: white;
    width: 40px;
    height: 40px;
    border-radius: 12px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    padding: 0;
    position: relative;
    z-index: 1;
    line-height: 1;
}

.modal-close:hover {
    background: rgba(255, 255, 255, 0.25);
    border-color: rgba(255, 255, 255, 0.3);
    transform: scale(1.08) rotate(90deg);
}

.modal-body {
    padding: 2rem 2.5rem;
    overflow-y: auto;
    flex: 1;
    background: linear-gradient(to bottom, #ffffff 0%, #fafbfc 100%);
}

.modal-footer {
    padding: 1.5rem 2.5rem;
    background: #f8fafc;
    border-top: 1px solid #e2e8f0;
    display: flex;
    gap: 0.75rem;
}

/* Loading Spinner in Dialogs */
.dialog-loading {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 3px solid rgba(255, 255, 255, 0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin-right: 0.5rem;
    vertical-align: middle;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* Toast Notifications */
.toast-container {
    position: fixed;
    top: 2rem;
    right: 2rem;
    z-index: 20000;
    pointer-events: none;
}

.toast {
    background: white;
    border-radius: 16px;
    padding: 1.25rem 1.5rem;
    margin-bottom: 1rem;
    box-shadow: 0 16px 32px rgba(0, 0, 0, 0.2), 0 0 0 1px rgba(0, 0, 0, 0.05);
    display: flex;
    align-items: center;
    gap: 1rem;
    min-width: 320px;
    max-width: 450px;
    pointer-events: auto;
    animation: toastIn 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    border-left: 4px solid #667eea;
}

@keyframes toastIn {
    from {
        transform: translateX(400px);
        opacity: 0;
    }

    to {
        transform: translateX(0);
        opacity: 1;
    }
}

@keyframes toastOut {
    to {
        transform: translateX(400px);
        opacity: 0;
    }
}

.toast.hiding {
    animation: toastOut 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.toast-icon {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
    flex-shrink: 0;
}

.toast.success {
    border-left-color: #10b981;
}

.toast.success .toast-icon {
    background: linear-gradient(135deg, #10b981, #059669);
    color: white;
}

.toast.error {
    border-left-color: #ef4444;
}

.toast.error .toast-icon {
    background: linear-gradient(135deg, #ef4444, #dc2626);
    color: white;
}

.toast.warning {
    border-left-color: #f59e0b;
}

.toast.warning .toast-icon {
    background: linear-gradient(135deg, #f59e0b, #d97706);
    color: white;
}

.toast.info {
    border-left-color: #667eea;
}

.toast.info .toast-icon {
    background: linear-gradient(135deg, #667eea, #764ba2);
    color: white;
}

.toast-content {
    flex: 1;
}

.toast-title {
    font-weight: 700;
    color: #1e293b;
    margin: 0 0 0.25rem 0;
    font-size: 1rem;
}

.toast-message {
    color: #64748b;
    margin: 0;
    font-size: 0.9rem;
    line-height: 1.5;
}

.toast-close {
    background: none;
    border: none;
    color: #94a3b8;
    cursor: pointer;
    font-size: 1.25rem;
    padding: 0;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
    transition: all 0.2s;
}

.toast-close:hover {
    background: #f1f5f9;
    color: #475569;
}

/* Responsive Design - Comprehensive Mobile Support */

/* Tablets (max-width: 768px) */
@media (max-width: 768px) {
    .custom-dialog {
        max-width: 90%;
    }

    .modal-content {
        max-width: 90%;
    }

    .toast {
        min-width: 280px;
        max-width: 400px;
    }
}

/* Mobile Devices (max-width: 640px) */
@media (max-width: 640px) {
    .custom-dialog {
        max-width: 100%;
        border-radius: 20px 20px 0 0;
        margin-top: auto;
    }

    .modal-content {
        max-width: 100%;
        border-radius: 24px;
        max-height: 92vh;
        margin: auto 0.75rem;
    }

    .dialog-icon-section {
        padding: 1.75rem 1.25rem 1rem;
    }

    .dialog-icon {
        width: 56px;
        height: 56px;
        font-size: 1.75rem;
        margin-bottom: 1rem;
    }

    .dialog-content {
        padding: 1rem 1.25rem;
    }

    .dialog-title {
        font-size: 1.125rem;
        margin-bottom: 0.5rem;
    }

    .dialog-message {
        font-size: 0.9rem;
        line-height: 1.6;
    }

    .dialog-input {
        padding: 0.875rem 1rem;
        font-size: 1rem;
        border-radius: 10px;
        min-height: 48px;
    }

    .dialog-actions {
        padding: 1rem 1.25rem 1.25rem;
        flex-direction: column-reverse;
        gap: 0.625rem;
    }

    .dialog-btn {
        width: 100%;
        padding: 0.875rem 1.25rem;
        font-size: 0.95rem;
        min-height: 48px;
    }

    .modal-header {
        padding: 1.25rem 1.25rem;
        flex-shrink: 0;
    }

    .modal-title {
        font-size: 1.25rem;
        line-height: 1.3;
    }

    .modal-close {
        width: 44px;
        height: 44px;
        font-size: 1.5rem;
        flex-shrink: 0;
    }

    .modal-body {
        padding: 1.25rem;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }

    /* Enhanced form styling for mobile */
    .modal-body .form-group {
        margin-bottom: 1.25rem;
    }

    .modal-body .form-group label {
        font-size: 0.95rem;
        font-weight: 600;
        margin-bottom: 0.5rem;
        display: block;
        color: #334155;
    }

    .modal-body .form-group input,
    .modal-body .form-group select,
    .modal-body .form-group textarea {
        font-size: 16px !important;
        /* Prevents iOS zoom */
        padding: 0.875rem;
        min-height: 48px;
        border-radius: 10px;
        border: 2px solid #e2e8f0;
        width: 100%;
        transition: all 0.2s;
    }

    .modal-body .form-group input:focus,
    .modal-body .form-group select:focus,
    .modal-body .form-group textarea:focus {
        border-color: #6366f1;
        outline: none;
        box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
    }

    .modal-body .form-group textarea {
        min-height: 100px;
        resize: vertical;
    }

    /* Better button styling in modal body */
    .modal-body .btn,
    .modal-footer .btn {
        min-height: 48px;
        font-size: 0.95rem;
        padding: 0.875rem 1.25rem;
        border-radius: 10px;
        font-weight: 600;
    }

    .modal-footer {
        padding: 1rem 1.25rem 1.25rem;
        flex-direction: column-reverse;
        gap: 0.625rem;
        flex-shrink: 0;
    }

    .modal-footer .btn {
        width: 100%;
    }

    /* Collapsible sections in modals */
    .modal-body details {
        margin-bottom: 1.25rem;
        border: 2px solid #e2e8f0;
        border-radius: 12px;
        overflow: hidden;
    }

    .modal-body details summary {
        padding: 1rem;
        background: #f8fafc;
        cursor: pointer;
        font-weight: 600;
        color: #1e40af;
        user-select: none;
        min-height: 48px;
        display: flex;
        align-items: center;
    }

    .modal-body details[open] summary {
        border-bottom: 2px solid #e2e8f0;
        background: #f0f9ff;
    }

    .modal-body details>div {
        padding: 1rem;
    }

    .toast-container {
        top: 1rem;
        right: 1rem;
        left: 1rem;
    }

    .toast {
        min-width: auto;
        width: 100%;
        padding: 1rem 1.25rem;
    }

    .toast-icon {
        width: 32px;
        height: 32px;
        font-size: 1.125rem;
    }

    .toast-title {
        font-size: 0.95rem;
    }

    .toast-message {
        font-size: 0.85rem;
    }
}

/* Small Mobile (max-width: 480px) */
@media (max-width: 480px) {
    .custom-dialog {
        border-radius: 20px;
        margin: 0.5rem;
    }

    .modal-content {
        border-radius: 20px;
        max-height: 94vh;
        margin: 0.5rem;
    }

    .dialog-icon-section {
        padding: 1.5rem 1rem 0.875rem;
    }

    .dialog-icon {
        width: 52px;
        height: 52px;
        font-size: 1.625rem;
        margin-bottom: 0.875rem;
    }

    .dialog-content {
        padding: 0.875rem 1rem;
    }

    .dialog-title {
        font-size: 1.0625rem;
        margin-bottom: 0.5rem;
    }

    .dialog-message {
        font-size: 0.875rem;
        line-height: 1.6;
    }

    .dialog-actions {
        padding: 0.875rem 1rem 1rem;
        gap: 0.5rem;
    }

    .dialog-btn {
        padding: 0.875rem 1rem;
        font-size: 0.9375rem;
        min-height: 48px;
    }

    .modal-header {
        padding: 1rem;
    }

    .modal-title {
        font-size: 1.125rem;
        line-height: 1.3;
        padding-right: 0.5rem;
    }

    .modal-close {
        width: 44px;
        height: 44px;
        font-size: 1.5rem;
    }

    .modal-body {
        padding: 1rem;
    }

    .modal-body .form-group {
        margin-bottom: 1rem;
    }

    .modal-body .form-group label {
        font-size: 0.9375rem;
        margin-bottom: 0.4375rem;
    }

    .modal-body .form-group input,
    .modal-body .form-group select,
    .modal-body .form-group textarea {
        font-size: 16px !important;
        padding: 0.8125rem 0.875rem;
    }

    .modal-body .btn,
    .modal-footer .btn {
        font-size: 0.9375rem;
        padding: 0.8125rem 1rem;
    }

    .modal-footer {
        padding: 0.875rem 1rem 1rem;
    }

    .toast {
        padding: 0.875rem 1rem;
        border-radius: 12px;
    }

    .toast-icon {
        width: 30px;
        height: 30px;
        font-size: 1.0625rem;
    }

    .toast-title {
        font-size: 0.9375rem;
    }

    .toast-message {
        font-size: 0.8125rem;
        line-height: 1.5;
    }
}

/* Extra Small Mobile (max-width: 375px) */
@media (max-width: 375px) {
    .modal-content {
        max-height: 96vh;
        margin: 0.375rem;
        border-radius: 18px;
    }

    .dialog-icon {
        width: 48px;
        height: 48px;
        font-size: 1.5rem;
        margin-bottom: 0.75rem;
    }

    .dialog-title {
        font-size: 1rem;
    }

    .dialog-message {
        font-size: 0.8125rem;
    }

    .modal-header {
        padding: 0.875rem;
    }

    .modal-title {
        font-size: 1.0625rem;
    }

    .modal-body {
        padding: 0.875rem;
    }

    .modal-body .form-group {
        margin-bottom: 0.875rem;
    }

    .modal-footer {
        padding: 0.75rem 0.875rem 0.875rem;
    }
}

/* Touch Device Optimization */
@media (hover: none) and (pointer: coarse) {

    .dialog-btn,
    .modal-close,
    .toast-close {
        min-height: 48px;
        min-width: 48px;
        display: inline-flex;
        align-items: center;
        justify-content: center;
    }

    .dialog-btn:active {
        transform: scale(0.96);
        transition: transform 0.1s;
    }

    .modal-close:active {
        transform: scale(0.96) rotate(90deg);
        transition: transform 0.1s;
    }

    /* Better scrolling */
    .dialog-content,
    .modal-body,
    .toast-container {
        -webkit-overflow-scrolling: touch;
    }

    /* Improve tap highlight - matches website primary color */
    * {
        -webkit-tap-highlight-color: rgba(102, 126, 234, 0.1);
    }
}

/* Landscape Mode Optimization */
@media (max-height: 500px) and (orientation: landscape) {

    .custom-dialog,
    .modal-content {
        max-height: 98vh;
        border-radius: 16px;
    }

    .dialog-icon-section {
        padding: 1.5rem 1.5rem 1rem;
    }

    .dialog-icon {
        width: 48px;
        height: 48px;
        font-size: 1.5rem;
    }

    .dialog-content {
        padding: 1rem 1.5rem;
    }

    .dialog-actions,
    .modal-footer {
        padding: 1rem 1.5rem;
    }

    .toast-container {
        top: 0.5rem;
        right: 0.5rem;
    }
}

/* iOS Safe Area Support for Popups */
@supports (padding-top: env(safe-area-inset-top)) {

    .custom-dialog-overlay,
    .modal {
        padding-top: max(1rem, env(safe-area-inset-top));
        padding-bottom: max(1rem, env(safe-area-inset-bottom));
        padding-left: max(1rem, env(safe-area-inset-left));
        padding-right: max(1rem, env(safe-area-inset-right));
    }

    @media (max-width: 640px) {

        .custom-dialog,
        .modal-content {
            padding-bottom: max(0, env(safe-area-inset-bottom));
        }

        .dialog-actions,
        .modal-footer {
            padding-bottom: max(1.5rem, calc(1.5rem + env(safe-area-inset-bottom)));
        }
    }

    .toast-container {
        top: max(2rem, calc(2rem + env(safe-area-inset-top)));
        right: max(2rem, calc(2rem + env(safe-area-inset-right)));
    }

    @media (max-width: 640px) {
        .toast-container {
            top: max(1rem, calc(1rem + env(safe-area-inset-top)));
            right: max(1rem, calc(1rem + env(safe-area-inset-right)));
            left: max(1rem, calc(1rem + env(safe-area-inset-left)));
        }
    }
}

/* Better Modal Animation on Mobile */
@media (max-width: 640px) {
    @keyframes slideUp {
        from {
            transform: translateY(100%);
            opacity: 1;
        }

        to {
            transform: translateY(0);
            opacity: 1;
        }
    }
}

/* Prevent Background Scroll on Mobile */
body.modal-open {
    overflow: hidden;
    position: fixed;
    width: 100%;
    height: 100%;
}

/* Collapsible Details Element Styling */
details summary {
    list-style: none;
    -webkit-tap-highlight-color: transparent;
}

details summary::-webkit-details-marker {
    display: none;
}

details summary:hover {
    background: #dbeafe !important;
}

details summary:active {
    background: #bfdbfe !important;
}

/* Better Select Dropdown Styling */
.modal-body select {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23475569' d='M6 9L1 4h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.875rem center;
    padding-right: 2.5rem;
}

/* Input Focus States - Better Visual Feedback */
.modal-body input:focus,
.modal-body select:focus,
.modal-body textarea:focus {
    border-color: #6366f1 !important;
    outline: none !important;
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1) !important;
}

/* Placeholder Styling */
.modal-body input::placeholder,
.modal-body textarea::placeholder {
    color: #94a3b8;
    opacity: 1;
}

/* Better Required Field Indicator */
.modal-body label {
    position: relative;
}

/* Smooth Scrolling for Modal Body */
.modal-body {
    scroll-behavior: smooth;
}

/* Better Button Hover States on Desktop */
@media (hover: hover) and (pointer: fine) {

    .modal-body .btn:hover,
    .modal-footer .btn:hover {
        transform: translateY(-1px);
        box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    }
}

/* Mobile-Optimized Button Containers */
@media (max-width: 640px) {

    .modal-body [style*="display: flex"],
    .modal-body [style*="display:flex"] {
        flex-direction: column !important;
        gap: 0.625rem !important;
    }

    .modal-body [style*="display: flex"] .btn,
    .modal-body [style*="display:flex"] .btn {
        width: 100% !important;
        flex: none !important;
    }

    /* Better spacing for inline paragraphs and sections */
    .modal-body p {
        font-size: 0.9375rem;
        line-height: 1.6;
    }

    /* Improve readability of text-heavy sections */
    .modal-body [style*="background"] {
        padding: 1rem !important;
        border-radius: 10px !important;
    }
}

/* Enhance Mobile Text Readability */
@media (max-width: 480px) {
    .modal-body [style*="display: flex"] {
        gap: 0.5rem !important;
    }

    /* Ensure all text is readable on small screens */
    .modal-body p,
    .modal-body div {
        font-size: 0.875rem !important;
        line-height: 1.6 !important;
    }

    .modal-body h3,
    .modal-body h4 {
        font-size: 1rem !important;
    }
}

/* Mobile Landscape Optimization - Keep Content Visible */
@media (max-width: 900px) and (max-height: 500px) and (orientation: landscape) {
    .modal-content {
        max-height: 96vh;
        margin: 0.375rem;
    }

    .modal-header {
        padding: 0.875rem 1rem;
    }

    .modal-body {
        padding: 0.875rem 1rem;
        font-size: 0.875rem;
    }

    .modal-footer {
        padding: 0.75rem 1rem;
    }

    .modal-title {
        font-size: 1.125rem;
    }

    .form-group {
        margin-bottom: 0.75rem !important;
    }

    .form-group input,
    .form-group select,
    .form-group textarea {
        padding: 0.625rem 0.75rem !important;
        min-height: 40px !important;
    }

    .btn {
        min-height: 40px !important;
        padding: 0.625rem 1rem !important;
    }
}

/* Accessibility - Focus Visible States for Touch Devices */
@media (max-width: 640px) {

    .modal-body input:focus-visible,
    .modal-body select:focus-visible,
    .modal-body textarea:focus-visible,
    .modal-body .btn:focus-visible,
    .modal-footer .btn:focus-visible {
        outline: 3px solid #6366f1;
        outline-offset: 2px;
    }
}

/* iOS Specific Fixes */
@supports (-webkit-touch-callout: none) {

    .custom-dialog,
    .modal-content {
        -webkit-overflow-scrolling: touch;
    }

    .dialog-content,
    .modal-body {
        -webkit-overflow-scrolling: touch;
    }
}

/* Dark Theme Support for Popups - Cohesive Deep Blue/Purple Design */
body.dark-theme .custom-dialog-overlay,
body.dark-theme .modal {
    background: rgba(10, 14, 26, 0.92);
    backdrop-filter: blur(16px);
}

body.dark-theme .custom-dialog,
body.dark-theme .modal-content {
    background: #12182b;
    border: 1px solid #2d3548;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.8), 0 0 0 1px rgba(102, 126, 234, 0.1);
}

body.dark-theme .dialog-icon-section {
    background: linear-gradient(135deg, #0a0e1a 0%, #12182b 100%);
    border-bottom-color: #2d3548;
}

body.dark-theme .dialog-icon-section::before {
    background: linear-gradient(135deg, rgba(102, 126, 234, 0.08) 0%, rgba(118, 75, 162, 0.08) 100%);
}

body.dark-theme .dialog-title {
    color: #ffffff;
}

body.dark-theme .dialog-message {
    color: #e5e7eb;
}

body.dark-theme .dialog-input {
    background: #0a0e1a;
    border-color: #2d3548;
    color: #ffffff;
}

body.dark-theme .dialog-input::placeholder {
    color: #6b7280;
}

body.dark-theme .dialog-input:focus {
    background: #1a2236;
    border-color: #667eea;
    box-shadow: 0 0 0 4px rgba(102, 126, 234, 0.2);
}

body.dark-theme .dialog-actions,
body.dark-theme .modal-footer {
    background: #0a0e1a;
    border-top-color: #2d3548;
}

body.dark-theme .dialog-btn-secondary {
    background: #1a2236;
    border-color: #2d3548;
    color: #ffffff;
}

body.dark-theme .dialog-btn-secondary:hover {
    background: #2d3548;
    border-color: #667eea;
    color: #ffffff;
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.15);
}

body.dark-theme .modal-header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-bottom-color: rgba(255, 255, 255, 0.05);
}

body.dark-theme .modal-body {
    background: #12182b;
}

body.dark-theme .toast {
    background: #12182b;
    border: 1px solid #2d3548;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.7), 0 0 0 1px rgba(102, 126, 234, 0.1);
}

body.dark-theme .toast-title {
    color: #ffffff;
}

body.dark-theme .toast-message {
    color: #e5e7eb;
}

body.dark-theme .toast-close {
    color: #9ca3af;
}

body.dark-theme .toast-close:hover {
    background: #1a2236;
    color: #ffffff;
}

/* Dark Theme - Toast Icons with better visibility */
body.dark-theme .toast-icon {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
}

/* ============================================
   DATE PICKER MODAL STYLES - REGISTER & PROFILE
   Matching commit 5617221 design
   ============================================ */

.date-picker-modal,
#register-date-picker-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(15, 23, 42, 0.75) !important;
    backdrop-filter: blur(8px);
    z-index: 2001;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    animation: fadeIn 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

.date-picker-modal.active,
#register-date-picker-modal.active {
    display: flex !important;
}

.date-picker-container,
#register-date-picker-modal .date-picker-container {
    background: white !important;
    border-radius: 28px !important;
    padding: 0 !important;
    box-shadow: 0 32px 64px -12px rgba(0, 0, 0, 0.35), 0 0 0 1px rgba(0, 0, 0, 0.08) !important;
    max-width: 520px !important;
    width: 100% !important;
    max-height: 92vh !important;
    overflow: hidden !important;
    display: flex !important;
    flex-direction: column !important;
    animation: slideUp 0.35s cubic-bezier(0.4, 0, 0.2, 1) !important;
}

.date-picker-header,
#register-date-picker-modal .date-picker-header {
    background: linear-gradient(135deg, #6366f1 0%, #8b5cf6 50%, #a855f7 100%) !important;
    color: white !important;
    padding: 2rem 2.5rem !important;
    display: flex !important;
    align-items: center !important;
    justify-content: space-between !important;
    position: relative !important;
}

.date-picker-header::before,
#register-date-picker-modal .date-picker-header::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.1) 0%, transparent 100%) !important;
    pointer-events: none;
}

.date-picker-header h3,
#register-date-picker-modal .date-picker-header h3 {
    margin: 0 !important;
    font-size: 1.625rem !important;
    font-weight: 800 !important;
    letter-spacing: -0.025em;
    position: relative;
    z-index: 1;
}

.date-picker-close,
#register-date-picker-modal .date-picker-close {
    background: rgba(255, 255, 255, 0.15) !important;
    border: 1px solid rgba(255, 255, 255, 0.2) !important;
    color: white !important;
    width: 40px !important;
    height: 40px !important;
    border-radius: 12px !important;
    cursor: pointer;
    display: flex !important;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    padding: 0;
    position: relative;
    z-index: 1;
    line-height: 1;
}

.date-picker-close:hover,
#register-date-picker-modal .date-picker-close:hover {
    background: rgba(255, 255, 255, 0.25) !important;
    border-color: rgba(255, 255, 255, 0.3) !important;
    transform: scale(1.08) rotate(90deg);
}

.date-picker-content,
#register-date-picker-modal .date-picker-content {
    padding: 2.5rem !important;
    overflow-y: auto;
    overflow-x: hidden;
    flex: 1;
    background: linear-gradient(to bottom, #ffffff 0%, #fafbfc 100%) !important;
    -webkit-overflow-scrolling: touch;
    scroll-behavior: smooth;
    min-height: 0;
    max-height: 100%;
}

.date-picker-display,
#register-date-picker-modal .date-picker-display {
    text-align: center;
    margin-bottom: 2.5rem;
    padding: 2rem 1.5rem;
    background: linear-gradient(135deg, #f8fafc 0%, #f1f5f9 100%) !important;
    border-radius: 20px;
    border: 1px solid #e2e8f0;
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.02);
    position: relative;
    overflow: hidden;
}

.date-picker-display::before,
#register-date-picker-modal .date-picker-display::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(90deg, #6366f1 0%, #8b5cf6 50%, #a855f7 100%) !important;
}

.date-picker-display .month-year,
#register-date-picker-modal .date-picker-display .month-year {
    font-size: 0.875rem;
    font-weight: 700;
    color: #64748b;
    margin-bottom: 1rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
}

.date-picker-display .day,
#register-date-picker-modal .date-picker-display .day {
    font-size: 4rem !important;
    font-weight: 900 !important;
    color: #6366f1 !important;
    line-height: 1;
    margin-bottom: 0.5rem;
    letter-spacing: -0.04em;
    text-shadow: 0 2px 8px rgba(99, 102, 241, 0.15);
}

.date-picker-display .weekday,
#register-date-picker-modal .date-picker-display .weekday {
    font-size: 1rem;
    color: #94a3b8;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.15em;
    margin-bottom: 1rem;
}

.date-picker-display .age-preview,
#register-date-picker-modal .date-picker-display .age-preview {
    margin-top: 1.25rem;
    padding-top: 1.25rem;
    border-top: 1px solid #e2e8f0;
    font-size: 0.95rem;
    color: #64748b;
    font-weight: 600;
}

.date-picker-display .age-preview strong,
#register-date-picker-modal .date-picker-display .age-preview strong {
    color: #6366f1;
    font-weight: 800;
    font-size: 1.1em;
}

.date-picker-year-input,
#register-date-picker-modal .date-picker-year-input {
    width: 100%;
    padding: 0.75rem 0.8rem;
    border: 2px solid #e2e8f0;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 700;
    text-align: center;
    background: white;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    color: #1e293b;
    cursor: text;
}

.date-picker-year-input:focus,
#register-date-picker-modal .date-picker-year-input:focus {
    outline: none;
    border-color: #6366f1 !important;
    background: #fafbfc;
    box-shadow: 0 0 0 5px rgba(99, 102, 241, 0.1), 0 4px 12px rgba(99, 102, 241, 0.15);
    transform: translateY(-1px);
}

.calendar-nav,
#register-date-picker-modal .calendar-nav {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1rem;
}

.nav-arrows,
#register-date-picker-modal .nav-arrows {
    display: flex;
    gap: 0.5rem;
}

.nav-arrows button,
#register-date-picker-modal .nav-arrows button {
    background: #f0f4ff !important;
    border: 2px solid #e0e7ff !important;
    padding: 0.4rem 0.6rem;
    border-radius: 8px;
    cursor: pointer;
    color: #667eea !important;
    font-weight: 600;
    transition: all 0.2s;
}

.nav-arrows button:hover,
#register-date-picker-modal .nav-arrows button:hover {
    background: #e0e7ff !important;
    border-color: #cbd5e1 !important;
}

.calendar-grid,
#register-date-picker-modal .calendar-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 0.4rem;
}

.calendar-grid .weekday,
#register-date-picker-modal .calendar-grid .weekday {
    text-align: center;
    font-weight: 700;
    color: #475569;
    padding: 0.35rem 0;
    font-size: 0.875rem;
}

.calendar-grid .day,
#register-date-picker-modal .calendar-grid .day {
    text-align: center;
    padding: 0.6rem 0.4rem;
    border-radius: 8px;
    cursor: pointer;
    background: white !important;
    border: 1px solid transparent;
    color: #1a202c;
    font-weight: 500;
    transition: all 0.2s;
}

.calendar-grid .day:hover,
#register-date-picker-modal .calendar-grid .day:hover {
    border-color: #cbd5e1;
    box-shadow: 0 6px 18px rgba(102, 126, 234, 0.06);
}

.calendar-grid .day.disabled,
#register-date-picker-modal .calendar-grid .day.disabled {
    color: #94a3b8;
    cursor: default;
    background: transparent !important;
}

.calendar-grid .day.selected,
#register-date-picker-modal .calendar-grid .day.selected {
    background: #667eea !important;
    color: white !important;
    border-color: #667eea !important;
    font-weight: 700;
}

.calendar-grid .day.today,
#register-date-picker-modal .calendar-grid .day.today {
    box-shadow: inset 0 0 0 2px rgba(102, 126, 234, 0.12);
}

.date-picker-actions,
#register-date-picker-modal .date-picker-actions {
    display: flex;
    gap: 0.875rem;
    padding: 1.75rem 2.5rem;
    background: #f8fafc;
    border-top: 1px solid #e2e8f0;
}

.date-picker-actions button,
#register-date-picker-modal .date-picker-actions button {
    flex: 1;
    padding: 1rem 1.75rem;
    border: none;
    border-radius: 14px;
    cursor: pointer;
    font-weight: 800;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    font-size: 1rem;
    letter-spacing: 0.02em;
}

.date-picker-actions .confirm,
#register-date-picker-modal .date-picker-actions .confirm {
    background: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%) !important;
    color: white !important;
    box-shadow: 0 6px 20px rgba(99, 102, 241, 0.35);
}

.date-picker-actions .confirm:hover,
#register-date-picker-modal .date-picker-actions .confirm:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(99, 102, 241, 0.45);
}

.date-picker-actions .confirm:active,
#register-date-picker-modal .date-picker-actions .confirm:active {
    transform: translateY(0);
}

.date-picker-actions .cancel,
#register-date-picker-modal .date-picker-actions .cancel {
    background: white !important;
    color: #64748b;
    border: 2px solid #e2e8f0;
}

.date-picker-actions .cancel:hover,
#register-date-picker-modal .date-picker-actions .cancel:hover {
    background: #f8fafc !important;
    border-color: #cbd5e1;
    color: #475569;
    transform: translateY(-1px);
}

/* Mobile Responsive for Date Picker */
@media (max-width: 640px) {

    .date-picker-modal,
    #register-date-picker-modal {
        padding: 0;
        align-items: flex-end;
    }

    .date-picker-container,
    #register-date-picker-modal .date-picker-container {
        max-width: 100%;
        border-radius: 24px 24px 0 0;
        max-height: 95vh;
        width: 100%;
        margin: 0;
    }

    .date-picker-header,
    #register-date-picker-modal .date-picker-header {
        padding: 1.75rem 1.5rem !important;
    }

    .date-picker-header h3,
    #register-date-picker-modal .date-picker-header h3 {
        font-size: 1.375rem;
    }

    .date-picker-content,
    #register-date-picker-modal .date-picker-content {
        padding: 2rem 1.5rem;
    }

    .date-picker-display,
    #register-date-picker-modal .date-picker-display {
        padding: 1.5rem 1rem;
    }

    .date-picker-display .day,
    #register-date-picker-modal .date-picker-display .day {
        font-size: 2rem !important;
    }

    .calendar-grid,
    #register-date-picker-modal .calendar-grid {
        gap: 0.35rem;
    }

    .calendar-grid .weekday,
    #register-date-picker-modal .calendar-grid .weekday {
        font-size: 0.8rem;
    }

    .calendar-grid .day,
    #register-date-picker-modal .calendar-grid .day {
        padding: 0.5rem 0.3rem;
        font-size: 0.9rem;
    }

    .date-picker-actions,
    #register-date-picker-modal .date-picker-actions {
        padding: 1.5rem 1.5rem;
    }
}


/* Performance Optimizations */
@media (max-width: 768px) {

    .custom-dialog,
    .modal-content,
    .toast {
        will-change: transform, opacity;
        transform: translateZ(0);
        backface-visibility: hidden;
    }
}