/**
 * Styles pour les contrôleurs Stimulus partagés
 * - Modal
 * - Toast
 * - Confirm
 * - Loading
 */

/* ============================================================
   MODAL CONTROLLER
   ============================================================ */

.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0.5);
    align-items: center;
    justify-content: center;
    z-index: 1000;
    opacity: 0;
    transition: opacity 0.2s ease-in-out;
    display: none;
}

/* Dynamic modal - always on top of other modals */
.modal-overlay.dynamic-modal-overlay {
    z-index: 10005;
    backdrop-filter: blur(4px);
}

/* Ensure full width for dynamic modal content */
.modal-overlay.dynamic-modal-overlay .modal-body {
    box-sizing: border-box;
}

.modal-overlay.dynamic-modal-overlay .modal-body > * {
    width: 100%;
    box-sizing: border-box;
}

/* Gift card selection specific styles */
.gift-card-selection {
    width: 100%;
}

.gift-card-option {
    width: 100%;
    box-sizing: border-box;
}

.gift-card-option:last-child {
    border-bottom: none !important;
}

.modal-overlay.active {
    opacity: 1;
    display: flex !important;
}

.modal-overlay.hidden {
    display: none !important;
}

.modal-dialog {
    background: white;
    border-radius: 8px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
    max-width: 90vw;
    max-height: 90vh;
    overflow: auto;
    transform: scale(0.9);
    transition: transform 0.2s ease-in-out;
}

.modal-overlay.active .modal-dialog {
    transform: scale(1);
}

/* Tailles de modales */
.modal-dialog.modal-small {
    width: 400px;
}

.modal-dialog.modal-medium {
    width: 600px;
}

.modal-dialog.modal-large {
    width: 900px;
}

.modal-dialog.modal-xlarge {
    width: 1100px;
}

.modal-dialog.modal-fullwidth {
    width: calc(100vw - 2rem);
    max-width: none;
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1.5rem;
    border-bottom: 1px solid #e5e7eb;
}

.modal-header h3 {
    margin: 0;
    font-size: 1.25rem;
    font-weight: 600;
    color: #111827;
}

.modal-header button {
    background: none;
    border: none;
    cursor: pointer;
    padding: 0.5rem;
    color: #6b7280;
    transition: color 0.2s;
}

.modal-header button:hover {
    color: #111827;
}

.modal-body {
    padding: 1.5rem;
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 0.75rem;
    padding: 1.5rem;
    border-top: 1px solid #e5e7eb;
}

/* ============================================================
   TOAST CONTROLLER
   ============================================================ */

.toast-container {
    position: fixed !important;
    top: 1rem !important;
    right: 1rem !important;
    left: auto !important;
    z-index: 9999 !important;
    display: flex !important;
    flex-direction: column !important;
    gap: 0.5rem !important;
    pointer-events: none !important;
    max-width: 400px !important;
}

.toast {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 1rem 1.25rem;
    background: white;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    min-width: 300px;
    max-width: 400px;
    opacity: 0;
    transform: translateX(100%);
    transition: all 0.3s ease-in-out;
    pointer-events: auto;
}

.toast.show {
    opacity: 1;
    transform: translateX(0);
}

.toast-icon {
    font-size: 1.25rem;
    flex-shrink: 0;
}

.toast-message {
    flex: 1;
    font-size: 0.95rem;
    color: #111827;
}

.toast-close {
    background: none;
    border: none;
    cursor: pointer;
    padding: 0.25rem;
    color: #6b7280;
    transition: color 0.2s;
    flex-shrink: 0;
}

.toast-close:hover {
    color: #111827;
}

/* Toast types */
.toast-success {
    border-left: 4px solid #10b981;
}

.toast-success .toast-icon {
    color: #10b981;
}

.toast-error {
    border-left: 4px solid #ef4444;
}

.toast-error .toast-icon {
    color: #ef4444;
}

.toast-warning {
    border-left: 4px solid #f59e0b;
}

.toast-warning .toast-icon {
    color: #f59e0b;
}

.toast-info {
    border-left: 4px solid #3b82f6;
}

.toast-info .toast-icon {
    color: #3b82f6;
}

/* Mobile responsive */
@media (max-width: 640px) {
    .toast-container {
        top: 0.5rem;
        right: 0.5rem;
        left: 0.5rem;
    }

    .toast {
        min-width: auto;
        max-width: none;
    }
}

/* ============================================================
   CONFIRM CONTROLLER
   ============================================================ */

.modal-content {
    background: white;
    border-radius: 8px;
    overflow: hidden;
}

.modal-icon {
    font-size: 2rem;
    margin-right: 1rem;
}

.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 0.75rem;
    padding: 1.5rem;
    border-top: 1px solid #e5e7eb;
    background: #f9fafb;
}

/* ============================================================
   LOADING CONTROLLER
   ============================================================ */

.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0.6);
    align-items: center;
    justify-content: center;
    z-index: 10000;
    opacity: 0;
    transition: opacity 0.2s ease-in-out;
    display: none;
}

.loading-overlay.active {
    opacity: 1;
    display: flex !important;
}

.loading-overlay.hidden {
    display: none !important;
}

.loading-spinner {
    text-align: center;
    background-color: rgba(255, 255, 255, 0.95);
    padding: 2rem 3rem;
    border-radius: 12px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
}

.spinner {
    display: inline-block;
    width: 50px;
    height: 50px;
    border: 4px solid rgba(107, 114, 128, 0.3);
    border-top-color: #6A2FB3;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

.loading-spinner p {
    color: #1f2937 !important;
    margin-top: 1rem;
    font-size: 1rem;
    font-weight: 500;
}

/* ============================================================
   UTILITAIRES
   ============================================================ */

.hidden {
    display: none !important;
}

.flex {
    display: flex !important;
}

/* Animations */
@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

@keyframes fadeOut {
    from {
        opacity: 1;
    }
    to {
        opacity: 0;
    }
}

@keyframes slideInRight {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

@keyframes slideOutRight {
    from {
        transform: translateX(0);
        opacity: 1;
    }
    to {
        transform: translateX(100%);
        opacity: 0;
    }
}

/* ============================================================
   BOUTONS (pour les modales et confirm)
   ============================================================ */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.5rem 1rem;
    border: 1px solid transparent;
    border-radius: 6px;
    font-size: 0.95rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    text-decoration: none;
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn-primary {
    background-color: #6A2FB3;
    color: white;
    border-color: #6A2FB3;
}

.btn-primary:hover:not(:disabled) {
    background-color: #5a27a0;
    border-color: #5a27a0;
}

.btn-secondary {
    background-color: #6b7280;
    color: white;
    border-color: #6b7280;
}

.btn-secondary:hover:not(:disabled) {
    background-color: #4b5563;
    border-color: #4b5563;
}

.btn-success {
    background-color: #10b981;
    color: white;
    border-color: #10b981;
}

.btn-success:hover:not(:disabled) {
    background-color: #059669;
    border-color: #059669;
}

.btn-danger {
    background-color: #ef4444;
    color: white;
    border-color: #ef4444;
}

.btn-danger:hover:not(:disabled) {
    background-color: #dc2626;
    border-color: #dc2626;
}

.btn-warning {
    background-color: #f59e0b;
    color: white;
    border-color: #f59e0b;
}

.btn-warning:hover:not(:disabled) {
    background-color: #d97706;
    border-color: #d97706;
}

.btn-outline-primary {
    background-color: transparent;
    color: #6A2FB3;
    border-color: #6A2FB3;
}

.btn-outline-primary:hover:not(:disabled) {
    background-color: #6A2FB3;
    color: white;
}

.btn-outline-secondary {
    background-color: transparent;
    color: #6b7280;
    border-color: #6b7280;
}

.btn-outline-secondary:hover:not(:disabled) {
    background-color: #6b7280;
    color: white;
}

/* Tailles de boutons */
.btn-sm {
    padding: 0.375rem 0.75rem;
    font-size: 0.875rem;
}

.btn-lg {
    padding: 0.75rem 1.5rem;
    font-size: 1.125rem;
}

.btn-block {
    display: flex;
    width: 100%;
}

/* Icônes dans les boutons */
.btn i {
    margin-right: 0.5rem;
}

.btn i:last-child:only-child {
    margin-right: 0;
}

/* ============================================================
   PDF VIEWER CONTROLLER
   ============================================================ */

.pdf-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0.95);
    z-index: 9999;
    opacity: 0;
    transition: opacity 0.2s ease-in-out;
    display: none;
}

.pdf-modal-overlay.active {
    opacity: 1;
    display: flex !important;
}

.pdf-modal-overlay.hidden {
    display: none !important;
}

.pdf-modal-container {
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    background: #1f2937;
}

.pdf-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1.5rem;
    background: #111827;
    border-bottom: 1px solid #374151;
    flex-shrink: 0;
}

.pdf-modal-title {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    color: white;
    font-size: 1.125rem;
    font-weight: 600;
}

.pdf-modal-title i {
    font-size: 1.5rem;
    color: #ef4444;
}

.pdf-modal-actions {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.pdf-modal-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.625rem 1.25rem;
    background: #374151;
    color: white;
    border: 1px solid #4b5563;
    border-radius: 6px;
    font-size: 0.95rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    text-decoration: none;
}

.pdf-modal-btn:hover {
    background: #4b5563;
    border-color: #6b7280;
    transform: translateY(-1px);
}

.pdf-modal-btn-download {
    background: #6A2FB3;
    border-color: #6A2FB3;
}

.pdf-modal-btn-download:hover {
    background: #5a27a0;
    border-color: #5a27a0;
}

.pdf-modal-btn-close {
    background: transparent;
    border: 1px solid #4b5563;
    padding: 0.625rem 1rem;
}

.pdf-modal-btn-close:hover {
    background: #374151;
    border-color: #6b7280;
}

.pdf-modal-btn-close i {
    font-size: 1.125rem;
}

.pdf-modal-btn-nav {
    background: transparent;
    border: 1px solid #4b5563;
    padding: 0.5rem;
    min-width: auto;
}

.pdf-modal-btn-nav:hover {
    background: #374151;
    border-color: #6b7280;
}

.pdf-page-info {
    margin-left: 1rem;
    color: #9ca3af;
    font-size: 0.95rem;
    font-weight: 400;
}

.pdf-page-controls {
    display: flex;
    gap: 0.25rem;
    margin-right: 1rem;
}

.pdf-modal-content {
    flex: 1;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #1f2937;
    overflow: auto;
}

.pdf-canvas-wrapper {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    width: 100%;
    height: 100%;
}

.pdf-canvas {
    max-width: 100%;
    max-height: 100%;
    background: white;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.pdf-loader {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    text-align: center;
    color: white;
}

.pdf-loader-spinner {
    font-size: 3rem;
    color: #6A2FB3;
    margin-bottom: 1rem;
}

.pdf-loader-spinner i {
    animation: spin 1s linear infinite;
}

.pdf-loader-text {
    font-size: 1.125rem;
    color: #d1d5db;
}

/* Responsive */
@media (max-width: 768px) {
    .pdf-modal-header {
        padding: 0.75rem 1rem;
    }

    .pdf-modal-title {
        font-size: 1rem;
    }

    .pdf-modal-title i {
        font-size: 1.25rem;
    }

    .pdf-modal-btn {
        padding: 0.5rem 0.875rem;
        font-size: 0.875rem;
    }

    .pdf-modal-btn span {
        display: none;
    }

    .pdf-modal-btn i {
        margin: 0;
    }

    .pdf-loader-spinner {
        font-size: 2rem;
    }

    .pdf-loader-text {
        font-size: 0.95rem;
    }
}
