/**
 * MSA Order Engine - Frontend UX Styles
 * Toast Notifications, Loading States, Form Enhancements
 */

/* ========================================
   CSS VARIABLES
   ======================================== */

:root {
    /* MSA Brand Colors */
    --msaoe-primary: #f97316;       /* Orange - MSA Hauptfarbe */
    --msaoe-primary-dark: #ea580c;  /* Darker Orange */
    --msaoe-secondary: #7c3aed;     /* Purple - MSA Akzentfarbe */
    --msaoe-secondary-dark: #6d28d9;
    --msaoe-success: #10b981;
    --msaoe-error: #ef4444;
    --msaoe-warning: #f59e0b;
    --msaoe-info: #7c3aed;          /* Purple statt Blau */
    --msaoe-gray-100: #f3f4f6;
    --msaoe-gray-200: #e5e7eb;
    --msaoe-gray-300: #d1d5db;
    --msaoe-gray-500: #6b7280;
    --msaoe-gray-700: #374151;
    --msaoe-gray-900: #111827;
    --msaoe-shadow: 0 10px 40px rgba(0,0,0,0.15);
    --msaoe-radius: 8px;
    --msaoe-transition: 0.3s ease;
}

/* ========================================
   TOAST NOTIFICATIONS
   ======================================== */

.msaoe-toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 99999;
    display: flex;
    flex-direction: column;
    gap: 10px;
    max-width: 400px;
}

.msaoe-toast {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 18px;
    background: white;
    border-radius: var(--msaoe-radius);
    box-shadow: var(--msaoe-shadow);
    transform: translateX(120%);
    opacity: 0;
    transition: all var(--msaoe-transition);
}

.msaoe-toast-visible {
    transform: translateX(0);
    opacity: 1;
}

.msaoe-toast-icon {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    font-weight: bold;
    flex-shrink: 0;
}

.msaoe-toast-success .msaoe-toast-icon { background: #d1fae5; color: var(--msaoe-success); }
.msaoe-toast-error .msaoe-toast-icon { background: #fee2e2; color: var(--msaoe-error); }
.msaoe-toast-warning .msaoe-toast-icon { background: #fef3c7; color: var(--msaoe-warning); }
.msaoe-toast-info .msaoe-toast-icon { background: #dbeafe; color: var(--msaoe-info); }

.msaoe-toast-message {
    flex: 1;
    font-size: 14px;
    color: var(--msaoe-gray-700);
    line-height: 1.4;
}

.msaoe-toast-close {
    background: none;
    border: none;
    font-size: 20px;
    color: var(--msaoe-gray-300);
    cursor: pointer;
    padding: 0;
    line-height: 1;
    transition: color var(--msaoe-transition);
}

.msaoe-toast-close:hover {
    color: var(--msaoe-gray-500);
}

/* ========================================
   LOADING STATES
   ======================================== */

.msaoe-loading {
    position: relative;
    pointer-events: none;
}

.msaoe-loading-overlay {
    position: absolute;
    inset: 0;
    background: rgba(255,255,255,0.9);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 15px;
    z-index: 100;
    border-radius: var(--msaoe-radius);
}

.msaoe-spinner {
    width: 32px;
    height: 32px;
    border: 3px solid var(--msaoe-gray-200);
    border-top-color: var(--msaoe-primary);
    border-radius: 50%;
    animation: msaoe-spin 0.8s linear infinite;
}

.msaoe-spinner-large {
    width: 48px;
    height: 48px;
    border-width: 4px;
}

@keyframes msaoe-spin {
    to { transform: rotate(360deg); }
}

.msaoe-loading-text {
    font-size: 14px;
    color: var(--msaoe-gray-500);
}

/* Full page loading */
.msaoe-fullpage-loading {
    position: fixed;
    inset: 0;
    background: rgba(255,255,255,0.95);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 99998;
    opacity: 0;
    visibility: hidden;
    transition: all var(--msaoe-transition);
}

.msaoe-fullpage-loading.msaoe-visible {
    opacity: 1;
    visibility: visible;
}

.msaoe-loading-content {
    text-align: center;
}

/* Button loading state */
.msaoe-btn-loading {
    position: relative;
    color: transparent !important;
}

.msaoe-btn-spinner {
    display: inline-block;
    width: 16px;
    height: 16px;
    border: 2px solid currentColor;
    border-top-color: transparent;
    border-radius: 50%;
    animation: msaoe-spin 0.8s linear infinite;
    vertical-align: middle;
    margin-right: 8px;
}

.msaoe-btn-loading .msaoe-btn-spinner {
    border-color: rgba(255,255,255,0.3);
    border-top-color: white;
}

/* ========================================
   QUANTITY SELECTOR
   ======================================== */

.msaoe-qty-selector {
    display: inline-flex;
    align-items: center;
    border: 2px solid var(--msaoe-gray-200);
    border-radius: var(--msaoe-radius);
    overflow: hidden;
    margin-bottom: 12px;
}

.msaoe-qty-btn {
    width: 40px;
    height: 40px;
    border: none;
    background: var(--msaoe-gray-100);
    font-size: 20px;
    font-weight: bold;
    color: var(--msaoe-gray-700);
    cursor: pointer;
    transition: all var(--msaoe-transition);
    display: flex;
    align-items: center;
    justify-content: center;
}

.msaoe-qty-btn:hover {
    background: var(--msaoe-primary);
    color: white;
}

.msaoe-qty-btn:active {
    transform: scale(0.95);
}

.msaoe-qty-input {
    width: 50px;
    height: 40px;
    border: none;
    text-align: center;
    font-size: 16px;
    font-weight: 600;
    color: var(--msaoe-gray-900);
    background: white;
    -moz-appearance: textfield;
}

.msaoe-qty-input::-webkit-outer-spin-button,
.msaoe-qty-input::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

/* ========================================
   FLOATING CART WIDGET
   ======================================== */

.msaoe-cart-widget {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 9999;
    transform: translateY(100px);
    opacity: 0;
    transition: all var(--msaoe-transition);
}

.msaoe-cart-widget-visible {
    transform: translateY(0);
    opacity: 1;
}

.msaoe-cart-widget-inner {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 20px;
    background: var(--msaoe-primary);
    color: white;
    text-decoration: none;
    border-radius: 50px;
    box-shadow: var(--msaoe-shadow);
    font-weight: 600;
    transition: all var(--msaoe-transition);
}

.msaoe-cart-widget-inner:hover {
    background: var(--msaoe-primary-dark);
    transform: scale(1.05);
    color: white;
}

.msaoe-cart-icon {
    font-size: 20px;
}

.msaoe-cart-badge {
    background: white;
    color: var(--msaoe-primary);
    width: 24px;
    height: 24px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: bold;
}

.msaoe-cart-widget-pulse .msaoe-cart-badge {
    animation: msaoe-pulse 0.6s ease;
}

@keyframes msaoe-pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.3); }
}

/* ========================================
   FORM VALIDATION
   ======================================== */

.msaoe-form-field {
    position: relative;
    margin-bottom: 20px;
}

.msaoe-field-valid input {
    border-color: var(--msaoe-success) !important;
}

.msaoe-field-valid::after {
    content: '✓';
    position: absolute;
    right: 12px;
    top: 38px;
    color: var(--msaoe-success);
    font-size: 16px;
}

.msaoe-field-error input {
    border-color: var(--msaoe-error) !important;
    background: #fef2f2;
}

.msaoe-field-error-msg {
    color: var(--msaoe-error);
    font-size: 12px;
    margin-top: 5px;
    display: flex;
    align-items: center;
    gap: 5px;
}

.msaoe-field-error-msg::before {
    content: '⚠';
}

.msaoe-autofilled {
    background: #fef3c7 !important;
    transition: background 0.5s ease;
}

/* ========================================
   COUNTDOWN EXTENSION
   ======================================== */

.msaoe-countdown {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.msaoe-countdown-extend {
    background: var(--msaoe-gray-100);
    border: 1px solid var(--msaoe-gray-300);
    padding: 4px 10px;
    border-radius: 4px;
    font-size: 12px;
    cursor: pointer;
    transition: all var(--msaoe-transition);
}

.msaoe-countdown-extend:hover {
    background: var(--msaoe-primary);
    color: white;
    border-color: var(--msaoe-primary);
}

/* ========================================
   ORDERER IS PARTICIPANT CHECKBOX
   ======================================== */

.msaoe-orderer-checkbox {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 15px;
    background: var(--msaoe-gray-100);
    border-radius: var(--msaoe-radius);
    margin-bottom: 20px;
    cursor: pointer;
}

.msaoe-orderer-checkbox input[type="checkbox"] {
    width: 20px;
    height: 20px;
    accent-color: var(--msaoe-primary);
}

.msaoe-orderer-checkbox label {
    cursor: pointer;
    font-weight: 500;
}

/* ========================================
   TICKET TYPE LABEL
   ======================================== */

.ticket-type-label {
    display: inline-block;
    background: var(--msaoe-gray-100);
    color: var(--msaoe-gray-700);
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 11px;
    margin-top: 4px;
}

/* ========================================
   MOBILE RESPONSIVE
   ======================================== */

@media (max-width: 768px) {
    .msaoe-toast-container {
        top: auto;
        bottom: 80px;
        left: 10px;
        right: 10px;
        max-width: none;
    }
    
    .msaoe-toast {
        transform: translateY(100%);
    }
    
    .msaoe-toast-visible {
        transform: translateY(0);
    }
    
    .msaoe-cart-widget {
        bottom: 10px;
        right: 10px;
        left: 10px;
    }
    
    .msaoe-cart-widget-inner {
        justify-content: center;
        width: 100%;
    }
    
    /* Better touch targets */
    .msaoe-qty-btn {
        width: 48px;
        height: 48px;
    }
    
    .msaoe-qty-input {
        width: 60px;
        height: 48px;
        font-size: 18px;
    }
    
    /* Form fields larger on mobile */
    .msaoe-form-field input,
    .msaoe-form-field select {
        height: 48px;
        font-size: 16px;
        padding: 12px;
    }
    
    /* Buttons larger on mobile */
    .msaoe-button {
        min-height: 48px;
        font-size: 16px;
    }
    
    /* Progress steps stack on mobile */
    .msaoe-progress {
        flex-direction: column;
        gap: 10px;
    }
    
    .msaoe-progress-step {
        flex-direction: row;
        gap: 10px;
        padding: 10px;
        background: var(--msaoe-gray-100);
        border-radius: var(--msaoe-radius);
    }
    
    /* Checkout summary full width */
    .msaoe-order-summary {
        margin-top: 20px;
    }
    
    /* Coupon input stack */
    .msaoe-coupon-input-row {
        flex-direction: column;
    }
}

/* Small phones */
@media (max-width: 375px) {
    .msaoe-toast-container {
        left: 5px;
        right: 5px;
    }
    
    .msaoe-toast {
        padding: 10px 12px;
        font-size: 13px;
    }
}

/* ========================================
   PRINT STYLES
   ======================================== */

@media print {
    .msaoe-toast-container,
    .msaoe-cart-widget,
    .msaoe-countdown-extend,
    .msaoe-fullpage-loading {
        display: none !important;
    }
}
