/**
 * TodoSign - Custom Popup System
 * Premium UI popups for confirmations, alerts, and errors
 */

@import url('design-tokens.css');
@import url('https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@400;500;600;700&display=swap');

/* ========== BASE MODAL STYLES ========== */
.ts-popup-modal {
    position: fixed;
    inset: 0;
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    font-family: 'Plus Jakarta Sans', 'DM Sans', sans-serif;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

.ts-popup-modal.show {
    opacity: 1;
    visibility: visible;
}

.ts-popup-overlay {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
}

.ts-popup-container {
    position: relative;
    width: 100%;
    max-width: 420px;
    background: linear-gradient(180deg, #ffffff 0%, #fafbfc 100%);
    border-radius: 24px;
    overflow: hidden;
    box-shadow:
        0 0 0 1px rgba(6, 182, 212, 0.1),
        0 25px 80px -20px rgba(6, 182, 212, 0.25),
        0 40px 100px -30px rgba(0, 0, 0, 0.3);
    transform: translateY(30px) scale(0.96);
    opacity: 0;
    transition: transform 0.4s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.4s ease;
}

.ts-popup-modal.show .ts-popup-container {
    transform: translateY(0) scale(1);
    opacity: 1;
}

/* Decorative Glows */
.ts-popup-glow {
    position: absolute;
    border-radius: 50%;
    filter: blur(60px);
    pointer-events: none;
    z-index: 0;
}

.ts-popup-glow-1 {
    width: 150px;
    height: 150px;
    background: rgba(6, 182, 212, 0.12);
    top: -40px;
    right: -40px;
}

.ts-popup-glow-2 {
    width: 100px;
    height: 100px;
    background: rgba(99, 102, 241, 0.08);
    bottom: 40px;
    left: -30px;
}

/* ========== CONTENT STYLES ========== */
.ts-popup-content {
    position: relative;
    z-index: 1;
    padding: 40px 32px;
    text-align: center;
}

/* Icon */
.ts-popup-icon {
    width: 80px;
    height: 80px;
    margin: 0 auto 24px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2rem;
    position: relative;
}

.ts-popup-icon::before {
    content: '';
    position: absolute;
    inset: -8px;
    border-radius: 50%;
    opacity: 0.3;
    animation: ts-popup-pulse 2s ease-in-out infinite;
}

@keyframes ts-popup-pulse {
    0%, 100% { transform: scale(1); opacity: 0.3; }
    50% { transform: scale(1.1); opacity: 0.15; }
}

/* Icon Types */
.ts-popup-icon.warning {
    background: linear-gradient(145deg, #fef3c7 0%, #fde68a 100%);
    color: #d97706;
    box-shadow: 0 8px 24px rgba(217, 119, 6, 0.2);
}

.ts-popup-icon.warning::before {
    background: #fbbf24;
}

.ts-popup-icon.error {
    background: linear-gradient(145deg, #fee2e2 0%, #fecaca 100%);
    color: #dc2626;
    box-shadow: 0 8px 24px rgba(220, 38, 38, 0.2);
}

.ts-popup-icon.error::before {
    background: #ef4444;
}

.ts-popup-icon.success {
    background: linear-gradient(145deg, #d1fae5 0%, #a7f3d0 100%);
    color: #059669;
    box-shadow: 0 8px 24px rgba(5, 150, 105, 0.2);
}

.ts-popup-icon.success::before {
    background: #10b981;
}

.ts-popup-icon.info {
    background: linear-gradient(145deg, #e0e7ff 0%, #c7d2fe 100%);
    color: #4f46e5;
    box-shadow: 0 8px 24px rgba(79, 70, 229, 0.2);
}

.ts-popup-icon.info::before {
    background: #6366f1;
}

.ts-popup-icon.logout {
    background: linear-gradient(145deg, #06b6d4 0%, #6366f1 100%);
    color: white;
    box-shadow: 0 8px 24px rgba(6, 182, 212, 0.35);
}

.ts-popup-icon.logout::before {
    background: #06b6d4;
}

.ts-popup-icon.signature {
    background: linear-gradient(145deg, #06b6d4 0%, #6366f1 100%);
    color: white;
    box-shadow: 0 8px 24px rgba(6, 182, 212, 0.35);
}

.ts-popup-icon.signature::before {
    background: #06b6d4;
}

.ts-popup-icon.danger {
    background: linear-gradient(145deg, #ef4444 0%, #dc2626 100%);
    color: white;
    box-shadow: 0 8px 24px rgba(220, 38, 38, 0.35);
}

.ts-popup-icon.danger::before {
    background: #ef4444;
}

/* Title and Message */
.ts-popup-title {
    margin: 0 0 12px;
    font-size: 1.35rem;
    font-weight: 700;
    color: #0f172a;
    letter-spacing: -0.02em;
}

.ts-popup-message {
    margin: 0 0 28px;
    font-size: 0.95rem;
    color: #64748b;
    line-height: 1.6;
}

/* ========== BUTTON STYLES ========== */
.ts-popup-buttons {
    display: flex;
    gap: 12px;
    justify-content: center;
}

.ts-popup-btn {
    padding: 14px 28px;
    border-radius: 14px;
    font-family: inherit;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    min-width: 120px;
}

.ts-popup-btn-cancel {
    background: transparent;
    border: 1px solid #e2e8f0;
    color: #64748b;
}

.ts-popup-btn-cancel:hover {
    background: #f8fafc;
    border-color: #cbd5e1;
    color: #0f172a;
}

/* Primary Button (Confirm) */
.ts-popup-btn-primary {
    position: relative;
    background: linear-gradient(135deg, #06b6d4 0%, #6366f1 100%);
    border: none;
    color: white;
    box-shadow: 0 4px 16px rgba(6, 182, 212, 0.35);
    overflow: hidden;
}

.ts-popup-btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(6, 182, 212, 0.4);
}

.ts-popup-btn-primary:active {
    transform: translateY(0);
}

/* Danger Button */
.ts-popup-btn-danger {
    background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
    border: none;
    color: white;
    box-shadow: 0 4px 16px rgba(239, 68, 68, 0.35);
}

.ts-popup-btn-danger:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(239, 68, 68, 0.4);
}

/* Success Button */
.ts-popup-btn-success {
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
    border: none;
    color: white;
    box-shadow: 0 4px 16px rgba(16, 185, 129, 0.35);
}

.ts-popup-btn-success:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(16, 185, 129, 0.4);
}

/* ========== CLOSE ANIMATION ========== */
.ts-popup-modal.closing .ts-popup-container {
    transform: translateY(20px) scale(0.96);
    opacity: 0;
}

.ts-popup-modal.closing .ts-popup-overlay {
    opacity: 0;
}

/* ========== ERROR DETAILS ========== */
.ts-popup-details {
    margin-top: 16px;
    padding: 16px;
    background: #fef2f2;
    border: 1px solid #fecaca;
    border-radius: 12px;
    text-align: left;
}

.ts-popup-details-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
    font-size: 0.8rem;
    font-weight: 600;
    color: #dc2626;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.ts-popup-details-content {
    font-size: 0.85rem;
    color: #7f1d1d;
    font-family: 'Monaco', 'Menlo', monospace;
    word-break: break-word;
    max-height: 150px;
    overflow-y: auto;
}

/* ========== RESPONSIVE ========== */
@media (max-width: 480px) {
    .ts-popup-container {
        max-width: 95%;
        border-radius: 20px;
    }

    .ts-popup-content {
        padding: 32px 24px;
    }

    .ts-popup-buttons {
        flex-direction: column;
    }

    .ts-popup-btn {
        width: 100%;
    }
}

/* ========== DARK MODE ========== */
[data-theme="dark"] .ts-popup-container {
    background: linear-gradient(180deg, #1e293b 0%, #0f172a 100%);
    box-shadow:
        0 0 0 1px rgba(6, 182, 212, 0.2),
        0 25px 80px -20px rgba(0, 0, 0, 0.5),
        0 40px 100px -30px rgba(0, 0, 0, 0.6);
}

[data-theme="dark"] .ts-popup-title {
    color: #f1f5f9;
}

[data-theme="dark"] .ts-popup-message {
    color: #94a3b8;
}

[data-theme="dark"] .ts-popup-btn-cancel {
    background: transparent;
    border-color: #334155;
    color: #94a3b8;
}

[data-theme="dark"] .ts-popup-btn-cancel:hover {
    background: #1e293b;
    border-color: #475569;
    color: #f1f5f9;
}

[data-theme="dark"] .ts-popup-details {
    background: rgba(127, 29, 29, 0.2);
    border-color: rgba(239, 68, 68, 0.3);
}

[data-theme="dark"] .ts-popup-details-header {
    color: #f87171;
}

[data-theme="dark"] .ts-popup-details-content {
    color: #fca5a5;
}

/* Warning icon dark mode */
[data-theme="dark"] .ts-popup-icon.warning {
    background: linear-gradient(145deg, rgba(251, 191, 36, 0.2) 0%, rgba(245, 158, 11, 0.3) 100%);
    color: #fbbf24;
}

/* Error icon dark mode */
[data-theme="dark"] .ts-popup-icon.error {
    background: linear-gradient(145deg, rgba(239, 68, 68, 0.2) 0%, rgba(220, 38, 38, 0.3) 100%);
    color: #f87171;
}

/* Success icon dark mode */
[data-theme="dark"] .ts-popup-icon.success {
    background: linear-gradient(145deg, rgba(16, 185, 129, 0.2) 0%, rgba(5, 150, 105, 0.3) 100%);
    color: #34d399;
}

/* Info icon dark mode */
[data-theme="dark"] .ts-popup-icon.info {
    background: linear-gradient(145deg, rgba(99, 102, 241, 0.2) 0%, rgba(79, 70, 229, 0.3) 100%);
    color: #818cf8;
}
