/* Tranzip Modal System - Complete Redesign */
/* Mobile-first, space-efficient, modern design */
/* Author: Yogesh */

:root {
    --tz-modal-radius: 20px;
    --tz-primary: #70EE91;
    --tz-primary-dark: #141B2C;
    --tz-danger: #EF4444;
    --tz-text-primary: #1F2937;
    --tz-text-secondary: #6B7280;
    --tz-border: #E5E7EB;
    --tz-bg-subtle: #F9FAFB;
}

/* Backdrop */
.tz-modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    display: flex;
    align-items: flex-end;
    justify-content: center;
    z-index: 9999;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.2s ease, visibility 0.2s ease;
}

.tz-modal-backdrop.tz-show {
    opacity: 1;
    visibility: visible;
}

/* Modal Container */
.tz-modal {
    background: white;
    width: 100%;
    max-width: 100%;
    max-height: 75vh; /* Increased to better accommodate content on mobile */
    border-radius: var(--tz-modal-radius) var(--tz-modal-radius) 0 0;
    display: flex;
    flex-direction: column;
    transform: translateY(100%);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 -10px 25px -5px rgba(0, 0, 0, 0.1);
    overflow: hidden;
}

.tz-modal-backdrop.tz-show .tz-modal {
    transform: translateY(0);
}

/* Modal Header - Sticky */
.tz-modal-header {
    position: sticky;
    top: 0;
    z-index: 10;
    background: white;
    padding: 12px 20px;
    border-bottom: 1px solid var(--tz-border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
}

/* Drag Indicator */
.tz-modal-drag-indicator {
    position: absolute;
    top: 8px;
    left: 50%;
    transform: translateX(-50%);
    width: 36px;
    height: 4px;
    background: var(--tz-border);
    border-radius: 2px;
}

/* Close Button - Always Visible */
.tz-modal-close {
    width: 36px;
    height: 36px;
    margin-left: auto;
    background: var(--tz-bg-subtle);
    border: none;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
    -webkit-tap-highlight-color: transparent;
}

.tz-modal-close:active {
    background: var(--tz-border);
    transform: scale(0.95);
}

.tz-modal-close svg {
    width: 20px;
    height: 20px;
    stroke: var(--tz-text-secondary);
}

/* Modal Content */
.tz-modal-content {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    -webkit-overflow-scrolling: touch;
}

/* Compact spacing for error modals on mobile */
.tz-modal--error .tz-modal-content {
    padding: 16px 20px;
}

/* Icons */
.tz-modal-icon {
    width: 48px;
    height: 48px;
    margin: 0 auto 16px;
    animation: tz-icon-bounce 0.5s ease-out;
}

/* Smaller icon and margin for error modals on mobile */
.tz-modal--error .tz-modal-icon {
    width: 40px;
    height: 40px;
    margin-bottom: 12px;
}

@keyframes tz-icon-bounce {
    0% { transform: scale(0.8); opacity: 0; }
    50% { transform: scale(1.1); }
    100% { transform: scale(1); opacity: 1; }
}

/* Typography */
.tz-modal-title {
    font-family: Jost, sans-serif;
    font-size: 20px;
    font-weight: 600;
    color: var(--tz-text-primary);
    margin: 0 0 8px;
    text-align: center;
}

.tz-modal-message {
    font-family: Jost, sans-serif;
    font-size: 15px;
    color: var(--tz-text-secondary);
    margin: 0 0 20px;
    text-align: center;
    line-height: 1.5;
}

/* Compact message for error modals */
.tz-modal--error .tz-modal-message {
    margin-bottom: 12px;
}

/* Compact Timeline */
.tz-modal-timeline {
    background: var(--tz-bg-subtle);
    border-radius: 12px;
    padding: 12px;
    margin: 0 0 20px;
    display: flex;
    gap: 8px;
}

.tz-timeline-step {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    opacity: 0.5;
    transition: opacity 0.3s ease;
}

.tz-timeline-step--active {
    opacity: 1;
}

.tz-timeline-icon {
    width: 24px;
    height: 24px;
    background: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
}

.tz-timeline-step--active .tz-timeline-icon {
    background: var(--tz-primary);
    color: var(--tz-primary-dark);
}

.tz-timeline-text {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
}

.tz-timeline-time {
    font-family: Jost, sans-serif;
    font-size: 11px;
    font-weight: 600;
    color: var(--tz-text-primary);
}

.tz-timeline-label {
    font-family: Jost, sans-serif;
    font-size: 11px;
    color: var(--tz-text-secondary);
}

/* Contact Card for Errors */
.tz-modal-contact-card {
    background: #F0FDF4;
    border: 1px solid #BBF7D0;
    border-radius: 12px;
    padding: 12px;
    margin: 0 0 12px;
}

.tz-contact-card-title {
    font-family: Jost, sans-serif;
    font-size: 14px;
    font-weight: 600;
    color: var(--tz-text-primary);
    margin: 0 0 12px;
}

.tz-contact-methods {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.tz-contact-method {
    display: flex;
    align-items: center;
    gap: 8px;
    color: #059669;
    text-decoration: none;
    font-family: Jost, sans-serif;
    font-size: 14px;
    font-weight: 500;
    padding: 8px 12px;
    background: white;
    border-radius: 8px;
    transition: all 0.2s ease;
}

.tz-contact-method:active {
    background: #F0FDF4;
    transform: scale(0.98);
}

/* Error Tips */
.tz-error-tips {
    background: #FEF3F2;
    border: 1px solid #FEE4E2;
    border-radius: 12px;
    padding: 10px 12px;
    margin: 0 0 16px;
}

.tz-tips-title {
    font-family: Jost, sans-serif;
    font-size: 13px;
    font-weight: 600;
    color: var(--tz-text-primary);
    margin: 0 0 8px;
}

.tz-tips-list {
    margin: 0;
    padding: 0 0 0 20px;
    list-style: disc;
}

.tz-tips-list li {
    font-family: Jost, sans-serif;
    font-size: 13px;
    color: var(--tz-text-secondary);
    margin: 0 0 4px;
}

/* Actions */
.tz-modal-actions {
    display: flex;
    gap: 8px;
    margin-top: auto;
    position: sticky;
    bottom: 0;
    background: white;
    padding: 16px 20px;
    margin: 0 -20px -20px;
    border-top: 1px solid var(--tz-border);
}

/* Remove extra padding for error modals since actions are now sticky */
.tz-modal--error .tz-modal-actions {
    padding: 12px 20px;
    margin: 0 -20px -16px;
}

/* Buttons */
.tz-btn {
    flex: 1;
    padding: 12px 20px;
    font-family: Jost, sans-serif;
    font-size: 15px;
    font-weight: 500;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 44px;
    -webkit-tap-highlight-color: transparent;
}

.tz-btn--primary {
    background: var(--tz-primary);
    color: var(--tz-primary-dark);
}

.tz-btn--primary:active {
    background: #5FDD80;
    transform: scale(0.98);
}

.tz-btn--danger {
    background: var(--tz-danger);
    color: white;
}

.tz-btn--danger:active {
    background: #DC2626;
    transform: scale(0.98);
}

.tz-btn--ghost {
    background: transparent;
    color: var(--tz-text-secondary);
    border: 1px solid var(--tz-border);
}

.tz-btn--ghost:active {
    background: var(--tz-bg-subtle);
    transform: scale(0.98);
}

/* Modal Footer - Auto-close */
.tz-modal-footer {
    padding: 12px 20px;
    background: var(--tz-bg-subtle);
    border-top: 1px solid var(--tz-border);
    display: flex;
    justify-content: center;
    flex-shrink: 0;
}

.tz-auto-close {
    display: flex;
    align-items: center;
    gap: 8px;
    font-family: Jost, sans-serif;
    font-size: 13px;
    color: var(--tz-text-secondary);
}

.tz-auto-close-ring {
    animation: tz-rotate 10s linear infinite;
}

.tz-auto-close-progress {
    stroke-dashoffset: 38;
    transition: stroke-dashoffset 10s linear;
    transform-origin: center;
    transform: rotate(-90deg);
}

.tz-modal-backdrop.tz-show .tz-auto-close-progress {
    stroke-dashoffset: 0;
}

@keyframes tz-rotate {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

/* Tablet and Desktop */
@media (min-width: 640px) {
    .tz-modal-backdrop {
        align-items: center;
        padding: 20px;
    }
    
    .tz-modal {
        max-width: 420px;
        max-height: 90vh;
        border-radius: 16px;
        transform: scale(0.9) translateY(20px);
        transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
    }
    
    .tz-modal-backdrop.tz-show .tz-modal {
        transform: scale(1) translateY(0);
    }
    
    .tz-modal-drag-indicator {
        display: none;
    }
    
    .tz-modal-header {
        padding: 16px 20px;
    }
    
    .tz-modal-content {
        padding: 32px 32px 24px;
    }
    
    .tz-modal-icon {
        width: 64px;
        height: 64px;
        margin-bottom: 24px;
    }
    
    .tz-modal-title {
        font-size: 24px;
        margin-bottom: 12px;
    }
    
    .tz-modal-message {
        font-size: 16px;
        margin-bottom: 24px;
    }
    
    .tz-modal-timeline {
        padding: 16px;
        gap: 16px;
    }
    
    .tz-timeline-step {
        gap: 8px;
    }
    
    .tz-timeline-icon {
        width: 32px;
        height: 32px;
        font-size: 14px;
    }
    
    .tz-timeline-time {
        font-size: 12px;
    }
    
    .tz-timeline-label {
        font-size: 12px;
    }
    
    .tz-contact-methods {
        flex-direction: row;
    }
    
    .tz-contact-method {
        flex: 1;
        justify-content: center;
        font-size: 13px;
        padding: 10px;
    }
    
    .tz-contact-method:hover {
        background: #F0FDF4;
    }
    
    .tz-modal-actions {
        gap: 12px;
    }
    
    .tz-btn {
        font-size: 14px;
    }
    
    .tz-btn:hover {
        transform: translateY(-1px);
        box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    }
    
    .tz-btn:active {
        transform: translateY(0);
    }
    
    .tz-modal-footer {
        background: transparent;
        border: none;
        padding: 0 32px 24px;
    }
    
    .tz-auto-close {
        font-size: 12px;
    }
}

/* Landscape Mobile */
@media (max-height: 500px) and (orientation: landscape) {
    .tz-modal {
        max-height: 90vh;
    }
    
    .tz-modal-content {
        padding: 16px 20px;
    }
    
    .tz-modal-icon {
        width: 40px;
        height: 40px;
        margin-bottom: 12px;
    }
    
    .tz-modal-timeline {
        display: none;
    }
}

/* Reduced Motion */
@media (prefers-reduced-motion: reduce) {
    .tz-modal,
    .tz-modal-backdrop,
    .tz-btn,
    .tz-modal-close,
    .tz-auto-close-progress {
        transition: none;
    }
    
    .tz-modal-icon,
    .tz-auto-close-ring {
        animation: none;
    }
}

/* Ultra-compact styles for small mobile screens */
@media (max-height: 700px) {
    .tz-modal {
        max-height: 85vh; /* More room on small screens */
    }
    
    .tz-modal-content {
        padding: 16px 20px;
    }
    
    .tz-modal-icon {
        width: 40px;
        height: 40px;
        margin-bottom: 12px;
    }
    
    .tz-modal-icon svg {
        width: 32px;
        height: 32px;
    }
    
    .tz-modal-title {
        font-size: 20px;
        margin-bottom: 8px;
    }
    
    .tz-modal-message {
        font-size: 14px;
        margin-bottom: 16px;
    }
    
    /* Compact timeline for small screens */
    .tz-modal-timeline {
        padding: 10px;
        margin: 0 0 16px;
        gap: 4px;
    }
    
    .tz-timeline-step {
        gap: 2px;
    }
    
    .tz-timeline-icon {
        width: 20px;
        height: 20px;
        font-size: 10px;
    }
    
    .tz-timeline-time {
        font-size: 10px;
    }
    
    .tz-timeline-label {
        font-size: 10px;
    }
    
    .tz-modal-actions {
        padding: 12px 20px;
        gap: 8px;
    }
    
    .tz-btn {
        height: 40px;
        font-size: 14px;
        padding: 0 16px;
    }
    
    .tz-modal-footer {
        padding: 8px 20px;
    }
    
    .tz-auto-close-text {
        font-size: 12px;
    }
}

/* Hide timeline labels on very small screens */
@media (max-height: 600px) {
    .tz-timeline-label {
        display: none;
    }
    
    .tz-modal-timeline {
        gap: 12px; /* More spacing when labels are hidden */
    }
}

/* Hide footer on extremely small screens */
@media (max-height: 550px) {
    .tz-modal-footer {
        display: none;
    }
    
    .tz-modal {
        max-height: 90vh;
    }
}

/* Loading State */
.tz-form-loading button[type="submit"],
.tz-form-loading input[type="submit"] {
    position: relative;
    color: transparent;
}

.tz-form-loading button[type="submit"]:after,
.tz-form-loading input[type="submit"]:after {
    content: "";
    position: absolute;
    width: 16px;
    height: 16px;
    top: 50%;
    left: 50%;
    margin: -8px 0 0 -8px;
    border: 2px solid var(--tz-primary-dark);
    border-radius: 50%;
    border-top-color: transparent;
    animation: tz-spinner 0.8s linear infinite;
}

@keyframes tz-spinner {
    to { transform: rotate(360deg); }
}

/* iOS Safe Areas */
@supports (padding: max(0px)) {
    .tz-modal {
        padding-bottom: max(20px, env(safe-area-inset-bottom));
    }
    
    .tz-modal-footer {
        padding-bottom: max(12px, env(safe-area-inset-bottom));
    }
}