/* ===== BUTTONS COMPONENT ===== */
/* This component handles all button styling and loading states across the application */
/* Used by: All pages that have buttons, form submissions, navigation elements */
/* JavaScript dependencies: button-states.js, ajax-forms.js */

/* ===== BUTTON STATES ===== */
/* Loading state for buttons */
.btn-loading {
    position: relative;
    color: transparent;
}

.btn-loading::after {
    content: '';
    position: absolute;
    width: 16px;
    height: 16px;
    top: 50%;
    left: 50%;
    margin-left: -8px;
    margin-top: -8px;
    border: 2px solid transparent;
    border-top-color: currentColor;
    border-radius: 50%;
    animation: button-loading-spinner 1s ease infinite;
}

/* Larger loading spinner for large buttons */
.btn-large.btn-loading::after {
    width: 20px;
    height: 20px;
    margin-left: -10px;
    margin-top: -10px;
}

/* Ready state for buttons (used by button-states.js) */
.btn-ready {
    position: relative;
    overflow: hidden;
}

.btn-ready::after {
    content: '✓';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    opacity: 0;
    color: currentColor;
    font-size: 1rem;
    font-weight: bold;
}

.btn-ready.show-ready::after {
    opacity: 1;
}

/* Base button styles */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: var(--space-3) var(--space-6);
    font-size: 1.1rem;
    font-weight: 500;
    text-decoration: none;
    border: none;
    border-radius: var(--radius);
    cursor: pointer;
    line-height: 1;
    gap: var(--space-2);
    min-height: 44px; /* WCAG touch target size */
}

.btn:focus {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
}

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

.btn-primary:hover {
    background: var(--primary-hover);
    color: white;
    text-decoration: none;
}

.btn-secondary {
    background: var(--bg-secondary);
    color: var(--text-primary);
    border: 1px solid var(--border);
}

.btn-secondary:hover {
    background: var(--bg-tertiary);
    color: var(--text-primary);
    text-decoration: none;
}

.btn-danger {
    background: var(--error);
    color: var(--contrast);
}

.btn-danger:hover {
    background: #b91c1c;
    color: white;
    text-decoration: none;
}

.btn-large {
    padding: var(--space-4) var(--space-8);
    font-size: 1.125rem;
    min-height: 52px;
}

.btn-small {
    padding: var(--space-2) var(--space-4);
    font-size: 0.875rem;
    min-height: 32px;
}

.btn-block {
    width: 100%;
}

.btn-icon {
    font-size: 1rem;
    flex-shrink: 0;
}

.btn-large .btn-icon {
    font-size: 1.1rem;
}

.btn-small .btn-icon {
    font-size: 0.9rem;
}

/* ===== AUTH FORM BUTTONS ===== */
/* Enhanced styling for authentication pages (login, signup, reset password) */
.auth-form .btn {
    height: 52px;
    font-size: 1.1rem;
    font-weight: 600;
    letter-spacing: 0.025em;
    border-radius: var(--radius-lg);
    box-shadow: 0 4px 12px var(--shadow-primary);
}

.auth-form .btn-primary:hover {
    box-shadow: 0 8px 20px var(--shadow-primary-lg);
}

.auth-form .btn-primary:active {
}

.auth-form .btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

/* ===== FORM BUTTONS ===== */
/* Styling for buttons in form containers */
.form-buttons {
    display: flex;
    gap: var(--space-3);
    align-items: center;
    justify-content: flex-start;
}

.form-buttons .btn {
    min-width: 120px;
}

/* ===== NAVIGATION BUTTONS ===== */
/* Theme toggle and navigation controls */
.nav-button {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    padding: 0;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text-primary);
    cursor: pointer;
}

.nav-button:hover {
    background: var(--bg-tertiary);
    border-color: var(--primary);
    color: var(--primary);
    text-decoration: none;
}

.nav-button:focus {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
}

/* ===== ADMIN BUTTONS ===== */
/* Admin interface specific buttons */
.admin-btn {
    padding: var(--space-2) var(--space-4);
    font-size: 0.9rem;
    border-radius: var(--radius);
    font-weight: 500;
    background: linear-gradient(135deg, var(--primary) 0%, var(--accent) 100%);
    border: none;
    box-shadow: 0 4px 15px var(--shadow-primary-lg);
}

.admin-btn:hover {
    background: var(--primary-hover);
}

.admin-nav .btn {
    margin: 0 var(--space-1);
    padding: var(--space-2) var(--space-3);
    font-size: 0.85rem;
    background: var(--bg-white-overlay);
    color: white;
    border: 1px solid var(--border-white-overlay);
    backdrop-filter: blur(10px);
}

.admin-nav .btn:hover {
    background: var(--border-white-overlay);
    color: white;
    text-decoration: none;
}

/* ===== DASHBOARD BUTTONS ===== */
/* View toggle buttons for dashboard tabs */
.view-toggle-btn {
    display: inline-flex;
    align-items: center;
    gap: var(--space-2);
    padding: var(--space-2) var(--space-4);
    border-radius: var(--radius);
    background: transparent;
    color: var(--text-secondary);
    text-decoration: none;
    font-weight: 500;
    font-size: 0.9rem;
    cursor: pointer;
}

.view-toggle-btn:hover {
    background: var(--bg-secondary);
    color: var(--primary-text-hover);
}

.view-toggle-btn.active {
    background: var(--primary);
    color: white;
}

.view-toggle-btn span {
    margin-left: var(--space-1);
}

/* Photo action buttons */
.photo-actions .btn {
    padding: var(--space-2) var(--space-3);
    font-size: 0.85rem;
    min-height: 36px;
    flex: 1;
    min-width: 150px;
}

/* Link action buttons */
.link-actions .btn {
    padding: var(--space-1) var(--space-2);
    font-size: 0.8rem;
    min-height: 32px;
}

/* ===== ACTION BUTTONS ===== */

/* Action buttons container */
.action-buttons {
    display: flex;
    gap: var(--space-3);
    justify-content: center;
    margin-top: var(--space-6);
    flex-wrap: wrap;
}
/* Action buttons */

.action-buttons .btn {
    min-width: 100px;
}

.action-buttons {
    display: flex;
    gap: var(--space-2);
    align-items: center;
}


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

.btn-success:hover {
    background: #047857;
    color: white;
    text-decoration: none;
}

.btn-warning {
    background: var(--warning);
    color: var(--contrast);
}

.btn-warning:hover {
    background: #b45309;
    color: white;
    text-decoration: none;
}

/* Copy URL button */
.copy-url-btn {
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: var(--space-2);
    cursor: pointer;
    min-width: 36px;
    min-height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-primary);
}

.copy-url-btn:hover {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

.copy-url-btn:focus {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
}

/* Social login buttons */
.social-buttons {
    display: flex;
    gap: var(--space-3);
}

.btn-social {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-2);
    padding: var(--space-3);
    border: 2px solid var(--border);
    background: var(--bg-primary);
    color: var(--text-primary);
    font-weight: 500;
    border-radius: var(--radius-lg);
    text-decoration: none;
}

.btn-social:hover {
    border-color: var(--primary);
    background: var(--bg-secondary);
    text-decoration: none;
}

/* Alert dismiss button */
.alert-dismiss {
    position: absolute;
    top: var(--space-2);
    right: var(--space-2);
    background: none;
    border: none;
    font-size: 1.25rem;
    color: currentColor;
    cursor: pointer;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius);
}

.alert-dismiss:hover {
    opacity: 1;
    background: var(--bg-black-overlay);
}

.alert-dismiss:focus {
    outline: 2px solid currentColor;
    outline-offset: 2px;
}

/* Delete form buttons */
.delete-form {
    flex-shrink: 0;
}

.delete-form .btn-danger {
    padding: var(--space-2) var(--space-3);
    font-size: 0.85rem;
    min-height: 36px;
}

/* Button groups */
.btn-group {
    display: flex;
    gap: var(--space-2);
    align-items: center;
}

.btn-group .btn {
    min-width: auto;
}

/* CTA buttons */
.cta-buttons {
    display: flex;
    gap: var(--space-4);
    margin: var(--space-6) 0;
    flex-wrap: wrap;
}

.cta-primary {
    order: 1;
}

.cta-secondary {
    order: 2;
}

/* Button animations */
@keyframes button-loading-spinner {
    from { 
        transform: rotate(0turn); 
    }
    to { 
        transform: rotate(1turn); 
    }
}

/* Pulse animation for special buttons */
@keyframes pulse {
    0%, 100% { 
        transform: scale(1); 
    }
    50% { 
        transform: scale(1.05); 
    }
}

.btn-pulse {
    animation: pulse 2s infinite;
}

/* Hover effects for enhanced buttons */
.btn-enhanced:hover {
    box-shadow: 0 8px 20px var(--shadow-primary-lg);
}

.btn-enhanced:active {
}

/* Responsive design */
@media (max-width: 768px) {
    .action-buttons {
        flex-direction: column;
        align-items: center;
        gap: var(--space-3);
    }
    
    .action-buttons .btn {
        width: 100%;
        max-width: 300px;
    }
    
    /* Mobile adjustments for form buttons */
    .form-buttons {
        flex-direction: column;
        align-items: stretch;
        gap: var(--space-2);
    }
    
    .form-buttons .btn {
        width: 100%;
        min-width: auto;
    }
    
    .social-buttons {
        flex-direction: column;
    }
    
    .cta-buttons {
        flex-direction: column;
        gap: var(--space-3);
    }
    
    .cta-buttons .btn {
        width: 100%;
        max-width: 300px;
    }
    
    .btn-group {
        flex-direction: column;
        align-items: stretch;
        gap: var(--space-2);
    }
    
    .btn-group .btn {
        width: 100%;
        justify-content: center;
    }
    
    /* Dashboard-specific button layouts */
    .link-actions .btn {
        width: 100%;
    }
    
    /* Admin action buttons mobile */
    .action-buttons .btn-small {
        width: 100%;
        justify-content: center;
    }
}

@media (max-width: 480px) {
    /* Mobile button sizing */
    .btn {
        padding: var(--space-2) var(--space-4);
        min-height: 40px;
    }
    
    .btn-large {
        padding: var(--space-3) var(--space-5);
        min-height: 48px;
        font-size: 1rem;
    }
    
    .action-buttons .btn,
    .cta-buttons .btn {
        max-width: none;
    }
    
    .copy-url-btn {
        min-width: 32px;
        min-height: 32px;
        padding: var(--space-1);
    }
    
    /* Auth form mobile adjustments */
    .auth-form .btn {
        height: 48px;
        font-size: 1rem;
    }

    .view-toggle-btn {
        flex-direction: column;
        gap: var(--space-1);
        padding: var(--space-2) var(--space-2);
    }
}

/* High contrast mode */
@media (prefers-contrast: high) {
    .btn,
    .btn-social,
    .copy-url-btn {
        border-width: 2px;
    }
    
    .btn-primary {
        border: 2px solid var(--primary);
    }
    
    .btn-danger {
        border: 2px solid var(--error);
    }
    
    .btn-secondary {
        border: 2px solid var(--border);
    }
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
    .btn-loading::after,
    .btn-pulse {
        animation: none;
    }
    
    .btn-enhanced:hover,
    .btn-social:hover,
    .copy-url-btn:hover {
    }
    
    .btn,
    .btn-social,
    .copy-url-btn,
    .alert-dismiss {
    }
}

/* Dark theme enhancements */
[data-theme="dark"] .alert-dismiss:hover,
[data-theme="system"].system-dark .alert-dismiss:hover {
    background: var(--bg-white-overlay);
}

[data-theme="dark"] .copy-url-btn,
[data-theme="system"].system-dark .copy-url-btn {
    background: var(--bg-secondary);
    border-color: var(--border-light);
}

[data-theme="dark"] .view-toggle-btn.active,
[data-theme="system"].system-dark .view-toggle-btn.active {
    background: var(--primary);
    color: white;
}


/* Focus management */
.btn:focus-visible,
.btn-social:focus-visible,
.copy-url-btn:focus-visible,
.alert-dismiss:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
}