/**
 * PDFDaddy - Production Utilities CSS
 * Styles for toasts, loading overlays, accessibility
 */

/* =============================================================================
   SKIP LINK (Accessibility)
   ============================================================================= */

.skip-link {
    position: absolute;
    top: -40px;
    left: 0;
    background: var(--color-primary);
    color: white;
    padding: 8px 16px;
    text-decoration: none;
    z-index: 10000;
    border-radius: 0 0 4px 0;
    font-weight: 600;
}

.skip-link:focus {
    top: 0;
}

/* =============================================================================
   LOADING OVERLAY
   ============================================================================= */

.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    animation: fadeIn 0.2s ease;
}

.loading-spinner {
    background: white;
    padding: 2rem 3rem;
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-2xl);
    text-align: center;
    max-width: 300px;
}

.spinner {
    width: 50px;
    height: 50px;
    border: 4px solid rgba(0, 0, 0, 0.1);
    border-top-color: var(--color-accent);
    border-radius: 50%;
    margin: 0 auto 1rem;
    animation: spin 1s linear infinite;
}

#loading-text {
    margin: 0;
    color: var(--color-text-primary);
    font-weight: 600;
}

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

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

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

#toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 10000;
    display: flex;
    flex-direction: column;
    gap: 12px;
    pointer-events: none;
    max-width: 400px;
}

.toast {
    background: white;
    padding: 16px 20px;
    border-radius: var(--radius-lg);
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.15);
    display: flex;
    align-items: center;
    gap: 12px;
    border-left: 4px solid;
    opacity: 0;
    transform: translateX(400px);
    transition: all 0.3s cubic-bezier(0.68, -0.55, 0.265, 1.55);
    pointer-events: auto;
    min-width: 300px;
}

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

.toast-icon {
    font-size: 20px;
    flex-shrink: 0;
    width: 24px;
    text-align: center;
}

.toast-message {
    flex: 1;
    color: var(--color-text-primary);
    font-size: 14px;
    line-height: 1.5;
}

.toast-close {
    background: none;
    border: none;
    color: var(--color-text-muted);
    font-size: 20px;
    cursor: pointer;
    padding: 0;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    transition: all 0.2s;
    flex-shrink: 0;
}

.toast-close:hover {
    background: rgba(0, 0, 0, 0.05);
    color: var(--color-text-primary);
}

/* Toast Types */
.toast-success {
    border-left-color: var(--color-success);
}

.toast-success .toast-icon {
    color: var(--color-success);
}

.toast-error {
    border-left-color: var(--color-error);
}

.toast-error .toast-icon {
    color: var(--color-error);
}

.toast-warning {
    border-left-color: var(--color-warning);
}

.toast-warning .toast-icon {
    color: var(--color-warning);
}

.toast-info {
    border-left-color: var(--color-info);
}

.toast-info .toast-icon {
    color: var(--color-info);
}

/* Mobile Toast */
@media (max-width: 768px) {
    #toast-container {
        left: 20px;
        right: 20px;
        top: auto;
        bottom: 20px;
        max-width: none;
    }
    
    .toast {
        min-width: auto;
        transform: translateY(400px);
    }
    
    .toast-show {
        transform: translateY(0);
    }
}

/* =============================================================================
   FLASH MESSAGES (Enhanced)
   ============================================================================= */

.flash-messages {
    position: fixed;
    top: 80px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 9998;
    max-width: 600px;
    width: calc(100% - 40px);
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.alert {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px 20px;
    border-radius: var(--radius-lg);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
    animation: slideDown 0.3s ease;
    border-left: 4px solid;
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.alert-icon {
    font-size: 20px;
    flex-shrink: 0;
}

.alert-message {
    flex: 1;
    font-size: 14px;
    line-height: 1.5;
}

.alert-close {
    background: none;
    border: none;
    color: inherit;
    font-size: 20px;
    cursor: pointer;
    padding: 0;
    width: 24px;
    height: 24px;
    opacity: 0.6;
    transition: opacity 0.2s;
}

.alert-close:hover {
    opacity: 1;
}

.alert-success {
    background: #F0FDF4;
    color: #166534;
    border-left-color: #22C55E;
}

.alert-error {
    background: #FEF2F2;
    color: #991B1B;
    border-left-color: #EF4444;
}

.alert-warning {
    background: #FFFBEB;
    color: #92400E;
    border-left-color: #F59E0B;
}

.alert-info {
    background: #EFF6FF;
    color: #1E40AF;
    border-left-color: #3B82F6;
}

/* =============================================================================
   USAGE BADGE (Navbar)
   ============================================================================= */

.usage-badge {
    padding: 6px 12px;
    background: var(--color-background);
    border-radius: var(--radius-full);
    font-size: 13px;
    font-weight: 600;
    color: var(--color-text-secondary);
    white-space: nowrap;
}

.badge-pro {
    background: linear-gradient(135deg, #667EEA 0%, #764BA2 100%);
    color: white;
    padding: 4px 12px;
    border-radius: var(--radius-full);
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.5px;
}

#files-used {
    color: var(--color-accent);
    font-weight: 700;
}

/* =============================================================================
   FORM ERROR STATES
   ============================================================================= */

.form-input.error,
.form-select.error {
    border-color: var(--color-error);
    background: #FEF2F2;
}

.form-input.error:focus,
.form-select.error:focus {
    border-color: var(--color-error);
    box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.1);
}

.form-error {
    color: var(--color-error);
    font-size: 13px;
    margin-top: 6px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.form-error::before {
    content: "⚠";
}

/* =============================================================================
   DRAG & DROP STATES
   ============================================================================= */

.file-upload-label.drag-over {
    background: var(--color-highlight-subtle);
    border-color: var(--color-accent);
    transform: scale(1.02);
}

.file-upload-label.file-selected {
    border-color: var(--color-success);
    background: linear-gradient(135deg, #F0FDF4 0%, #DCFCE7 100%);
}

/* =============================================================================
   ACCESSIBILITY IMPROVEMENTS
   ============================================================================= */

/* Focus Visible (Only show on keyboard navigation) */
*:focus-visible {
    outline: 2px solid var(--color-accent);
    outline-offset: 2px;
}

*:focus:not(:focus-visible) {
    outline: none;
}

/* Reduced Motion */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* High Contrast Mode */
@media (prefers-contrast: high) {
    .btn {
        border-width: 2px;
    }
    
    .card {
        border-width: 2px;
    }
}

/* Dark Mode Support (Future) */
@media (prefers-color-scheme: dark) {
    /* Will be implemented when dark mode is added */
}

/* =============================================================================
   PROGRESS BAR (For File Upload)
   ============================================================================= */

.progress-bar {
    width: 100%;
    height: 8px;
    background: var(--color-border-light);
    border-radius: var(--radius-full);
    overflow: hidden;
    margin-top: 12px;
}

.progress-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--color-accent) 0%, var(--color-accent-dark) 100%);
    border-radius: var(--radius-full);
    transition: width 0.3s ease;
    width: 0%;
}

/* =============================================================================
   SKELETON LOADERS (For Loading States)
   ============================================================================= */

.skeleton {
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
    border-radius: var(--radius-md);
}

@keyframes shimmer {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

.skeleton-text {
    height: 16px;
    margin-bottom: 8px;
}

.skeleton-title {
    height: 24px;
    width: 60%;
    margin-bottom: 12px;
}

.skeleton-card {
    height: 200px;
}

/* =============================================================================
   EMPTY STATES
   ============================================================================= */

.empty-state {
    text-align: center;
    padding: 4rem 2rem;
    color: var(--color-text-muted);
}

.empty-state-icon {
    font-size: 4rem;
    margin-bottom: 1rem;
    opacity: 0.5;
}

.empty-state-title {
    font-size: var(--font-size-xl);
    font-weight: 600;
    color: var(--color-text-secondary);
    margin-bottom: 0.5rem;
}

.empty-state-message {
    font-size: var(--font-size-base);
    margin-bottom: 1.5rem;
}

/* =============================================================================
   MOBILE NAVBAR TOGGLE
   ============================================================================= */

.navbar-toggle {
    display: none;
    flex-direction: column;
    gap: 4px;
    background: none;
    border: none;
    padding: 8px;
    cursor: pointer;
}

.navbar-toggle span {
    display: block;
    width: 24px;
    height: 2px;
    background: var(--color-text-primary);
    transition: all 0.3s;
}

.navbar-toggle[aria-expanded="true"] span:nth-child(1) {
    transform: rotate(45deg) translate(6px, 6px);
}

.navbar-toggle[aria-expanded="true"] span:nth-child(2) {
    opacity: 0;
}

.navbar-toggle[aria-expanded="true"] span:nth-child(3) {
    transform: rotate(-45deg) translate(6px, -6px);
}

@media (max-width: 768px) {
    .navbar-toggle {
        display: flex;
    }
    
    .navbar-menu {
        position: absolute;
        top: 100%;
        left: 0;
        right: 0;
        background: white;
        box-shadow: var(--shadow-lg);
        padding: 1rem;
        display: none;
    }
    
    .navbar-menu.show {
        display: block;
    }
    
    .navbar-nav {
        flex-direction: column;
        gap: 0.5rem;
    }
}

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

@media print {
    .navbar,
    .footer,
    .flash-messages,
    #toast-container,
    .loading-overlay,
    .btn,
    .skip-link {
        display: none !important;
    }
    
    body {
        font-size: 12pt;
        line-height: 1.5;
        color: black;
        background: white;
    }
    
    .card {
        border: 1px solid #ddd;
        box-shadow: none;
        page-break-inside: avoid;
    }
}
