/* ============================================
   Toast Notifications
   ============================================ */
.toast {
    position: fixed;
    top: 1rem;
    right: -500px;
    z-index: 9999;
    min-width: 300px;
    max-width: 500px;
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    transition: right 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.toast.show {
    right: 1rem;
    animation: toast-slide-in 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.toast.hide {
    right: -500px;
    animation: toast-slide-out 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes toast-slide-in {
    from {
        right: -500px;
        opacity: 0;
        transform: translateX(100%);
    }
    to {
        right: 1rem;
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes toast-slide-out {
    from {
        right: 1rem;
        opacity: 1;
        transform: translateX(0);
    }
    to {
        right: -500px;
        opacity: 0;
        transform: translateX(100%);
    }
}

/* ============================================
   Loading Modal
   ============================================ */
#loading-modal {
    backdrop-filter: blur(2px);
    background-color: rgba(0, 0, 0, 0.5);
}

#loading-modal .modal-content {
    animation: modal-fade-in 0.2s ease-out;
}

/* ============================================
   Progress Bar Animation
   ============================================ */
.progress-bar {
    transition: width 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    height: 100%;
    border-radius: 0.25rem;
}

.progress-bar-striped {
    background-image: linear-gradient(
        45deg,
        rgba(255, 255, 255, 0.15) 25%,
        transparent 25%,
        transparent 50%,
        rgba(255, 255, 255, 0.15) 50%,
        rgba(255, 255, 255, 0.15) 75%,
        transparent 75%,
        transparent
    );
    background-size: 1rem 1rem;
    animation: progress-bar-stripes 1s linear infinite;
}

@keyframes progress-bar-stripes {
    0% {
        background-position: 1rem 0;
    }
    100% {
        background-position: 0 0;
    }
}

.progress-container {
    width: 100%;
    height: 1rem;
    background-color: rgba(0, 0, 0, 0.1);
    border-radius: 0.25rem;
    overflow: hidden;
}

/* ============================================
   Modal Animations
   ============================================ */
.modal {
    animation: modal-backdrop-fade-in 0.2s ease-out;
}

.modal-enter {
    animation: modal-fade-in 0.2s ease-out;
}

.modal-exit {
    animation: modal-fade-out 0.2s ease-in;
}

@keyframes modal-backdrop-fade-in {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

@keyframes modal-fade-in {
    from {
        opacity: 0;
        transform: scale(0.95) translateY(-20px);
    }
    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

@keyframes modal-fade-out {
    from {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
    to {
        opacity: 0;
        transform: scale(0.95) translateY(-20px);
    }
}

/* Link Item Animation */
.link-item {
    animation: fade-in 0.3s ease-out;
}

@keyframes fade-in {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Button Hover Effects */
button:active {
    transform: scale(0.98);
}

/* Smooth Transitions */
* {
    transition-property: color, background-color, border-color, text-decoration-color, fill, stroke;
    transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1);
    transition-duration: 200ms;
}

/* ============================================
   Loading Spinner
   ============================================ */
.spinner {
    border: 3px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    border-top-color: white;
    width: 40px;
    height: 40px;
    animation: spin 1s linear infinite;
}

.spinner-sm {
    border-width: 2px;
    width: 20px;
    height: 20px;
}

.spinner-lg {
    border-width: 4px;
    width: 60px;
    height: 60px;
}

.spinner-primary {
    border-color: rgba(99, 102, 241, 0.3);
    border-top-color: #6366f1;
}

.spinner-success {
    border-color: rgba(34, 197, 94, 0.3);
    border-top-color: #22c55e;
}

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

/* Input Focus States */
input:focus,
textarea:focus,
select:focus {
    outline: none;
    border-color: #6366f1;
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

/* ============================================
   Responsive Design
   ============================================ */

/* Mobile Breakpoint (< 768px) */
@media (max-width: 767px) {
    /* Single column layout */
    .grid-cols-2 {
        grid-template-columns: repeat(1, minmax(0, 1fr)) !important;
    }
    
    /* Adjust spacing */
    .max-w-7xl {
        padding-left: 1rem;
        padding-right: 1rem;
    }
    
    /* Stack form elements */
    .form-row {
        flex-direction: column;
    }
    
    /* Full width buttons on mobile */
    .btn-mobile-full {
        width: 100%;
    }
    
    /* Adjust modal width */
    .modal-content {
        width: 95% !important;
        margin: 1rem;
    }
    
    /* Smaller text on mobile */
    .text-responsive {
        font-size: 0.875rem;
    }
}

/* Touch-friendly targets (< 640px) */
@media (max-width: 640px) {
    button,
    a.button,
    input[type="submit"],
    .btn,
    .touch-target {
        min-height: 44px;
        min-width: 44px;
        padding: 0.75rem 1rem;
    }
    
    /* Larger tap targets for icons */
    .icon-button {
        padding: 0.75rem;
    }
    
    /* Hamburger menu */
    .mobile-menu {
        display: block;
    }
    
    .desktop-menu {
        display: none;
    }
    
    /* Mobile navigation */
    .mobile-nav {
        position: fixed;
        top: 0;
        left: -100%;
        width: 80%;
        height: 100vh;
        background-color: white;
        box-shadow: 2px 0 8px rgba(0, 0, 0, 0.1);
        transition: left 0.3s ease-in-out;
        z-index: 1000;
    }
    
    .mobile-nav.open {
        left: 0;
    }
    
    /* Mobile overlay */
    .mobile-overlay {
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        height: 100vh;
        background-color: rgba(0, 0, 0, 0.5);
        opacity: 0;
        visibility: hidden;
        transition: opacity 0.3s ease-in-out, visibility 0.3s ease-in-out;
        z-index: 999;
    }
    
    .mobile-overlay.open {
        opacity: 1;
        visibility: visible;
    }
    
    /* Adjust table for mobile */
    .table-responsive {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
    
    table {
        min-width: 600px;
    }
}

/* Desktop menu (> 640px) */
@media (min-width: 641px) {
    .mobile-menu {
        display: none;
    }
    
    .desktop-menu {
        display: flex;
    }
}

/* Tablet adjustments (768px - 1024px) */
@media (min-width: 768px) and (max-width: 1024px) {
    .max-w-7xl {
        padding-left: 2rem;
        padding-right: 2rem;
    }
}

/* Device orientation */
@media (orientation: landscape) and (max-height: 500px) {
    /* Adjust modal height for landscape */
    .modal-content {
        max-height: 90vh;
        overflow-y: auto;
    }
}

/* Toast Container */
#toast-container {
    pointer-events: none;
}

#toast-container .toast {
    pointer-events: auto;
}
/* ============================================
   Color Scheme & Utilities
   ============================================ */

/* Primary Colors */
.bg-primary {
    background-color: #6366f1;
}

.text-primary {
    color: #6366f1;
}

.border-primary {
    border-color: #6366f1;
}

.hover\:bg-primary:hover {
    background-color: #4f46e5;
}

/* Success Colors */
.bg-success {
    background-color: #22c55e;
}

.text-success {
    color: #22c55e;
}

.border-success {
    border-color: #22c55e;
}

.hover\:bg-success:hover {
    background-color: #16a34a;
}

/* Error Colors */
.bg-error {
    background-color: #ef4444;
}

.text-error {
    color: #ef4444;
}

.border-error {
    border-color: #ef4444;
}

.hover\:bg-error:hover {
    background-color: #dc2626;
}

/* Warning Colors */
.bg-warning {
    background-color: #f59e0b;
}

.text-warning {
    color: #f59e0b;
}

.border-warning {
    border-color: #f59e0b;
}

.hover\:bg-warning:hover {
    background-color: #d97706;
}

/* Light variants for backgrounds */
.bg-primary-light {
    background-color: #eef2ff;
}

.bg-success-light {
    background-color: #f0fdf4;
}

.bg-error-light {
    background-color: #fef2f2;
}

.bg-warning-light {
    background-color: #fffbeb;
}

/* Status badges */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 0.25rem 0.75rem;
    border-radius: 9999px;
    font-size: 0.75rem;
    font-weight: 500;
    line-height: 1;
}

.badge-success {
    background-color: #dcfce7;
    color: #166534;
}

.badge-error {
    background-color: #fee2e2;
    color: #991b1b;
}

.badge-warning {
    background-color: #fef3c7;
    color: #92400e;
}

.badge-info {
    background-color: #dbeafe;
    color: #1e40af;
}

/* Text contrast - ensuring dark text on light backgrounds */
.text-contrast-light {
    color: #1f2937;
}

.text-contrast-dark {
    color: #ffffff;
}

/* Button variants with proper contrast */
.btn-primary {
    background-color: #6366f1;
    color: #ffffff;
    border: 1px solid #6366f1;
}

.btn-primary:hover {
    background-color: #4f46e5;
    border-color: #4f46e5;
}

.btn-success {
    background-color: #22c55e;
    color: #ffffff;
    border: 1px solid #22c55e;
}

.btn-success:hover {
    background-color: #16a34a;
    border-color: #16a34a;
}

.btn-error {
    background-color: #ef4444;
    color: #ffffff;
    border: 1px solid #ef4444;
}

.btn-error:hover {
    background-color: #dc2626;
    border-color: #dc2626;
}

.btn-warning {
    background-color: #f59e0b;
    color: #ffffff;
    border: 1px solid #f59e0b;
}

.btn-warning:hover {
    background-color: #d97706;
    border-color: #d97706;
}

.btn-secondary {
    background-color: #6b7280;
    color: #ffffff;
    border: 1px solid #6b7280;
}

.btn-secondary:hover {
    background-color: #4b5563;
    border-color: #4b5563;
}

.btn-outline {
    background-color: transparent;
    color: #6366f1;
    border: 1px solid #6366f1;
}

.btn-outline:hover {
    background-color: #6366f1;
    color: #ffffff;
}

/* Focus states with proper contrast */
.focus-primary:focus {
    outline: none;
    border-color: #6366f1;
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

.focus-error:focus {
    outline: none;
    border-color: #ef4444;
    box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.1);
}

/* Credit display colors */
.credit-normal {
    color: #22c55e;
}

.credit-low {
    color: #ef4444;
    font-weight: 600;
}

/* Link states */
a {
    color: #6366f1;
    text-decoration: none;
}

a:hover {
    color: #4f46e5;
    text-decoration: underline;
}

/* Disabled states */
.disabled,
[disabled] {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Card shadows */
.card-shadow {
    box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px 0 rgba(0, 0, 0, 0.06);
}

.card-shadow-lg {
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
}
