/* Base styles for the application */
:root {
    --primary-color: #e65100;
    --primary-hover: #ff6d00;
    --danger-color: #f56565;
    --success-color: #38a169;
    --warning-color: #d69e2e;
    --info-color: #4299e1;
    --text-color: #2d3748;
    --text-color-light: #718096;
    --background-color: #f7fafc;
    --card-bg: #ffffff;
    --border-color: #e2e8f0;
    --shadow-color: rgba(0, 0, 0, 0.1);
    --focus-ring-color: rgba(237, 137, 54, 0.4);
}

/* Application-wide styles */
body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    line-height: 1.5;
    transition: background-color 0.3s ease, color 0.3s ease;
}

/* Accessibility - focus styles */
a:focus, button:focus, input:focus, select:focus, textarea:focus {
    outline: none;
    box-shadow: 0 0 0 3px var(--focus-ring-color);
}

/* Improved button styles */
button, .btn, a.btn, input[type="submit"], input[type="button"] {
    position: relative;
    overflow: hidden;
    transition: all 0.3s ease;
}

/* Button ripple effect */
button::after, .btn::after, a.btn::after, 
input[type="submit"]::after, input[type="button"]::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    background-color: rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    transform: translate(-50%, -50%);
    opacity: 0;
    transition: width 0.3s ease, height 0.3s ease, opacity 0.3s ease;
}

button:active::after, .btn:active::after, a.btn:active::after,
input[type="submit"]:active::after, input[type="button"]:active::after {
    width: 150%;
    height: 150%;
    opacity: 1;
}

/* Touch active state for mobile */
.touch-active {
    transform: scale(0.98);
}

/* Form elements */
input, select, textarea {
    transition: border-color 0.3s ease, box-shadow 0.3s ease, background-color 0.3s ease;
}

/* Notification animation */
.notification {
    animation: slideInNotification 0.3s ease-out forwards;
    transition: opacity 0.3s ease;
}

@keyframes slideInNotification {
    from { transform: translateY(-20px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

/* Page transitions */
.page-transition {
    animation: fadeIn 0.3s ease-in-out;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Table row hover effects */
table tbody tr {
    transition: background-color 0.2s ease;
}

table tbody tr:hover {
    background-color: rgba(237, 137, 54, 0.05);
}

/* Card hover effects */
.shadow-md {
    transition: box-shadow 0.3s ease, transform 0.3s ease;
}

.shadow-md:hover {
    box-shadow: 0 8px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
}

/* Autocomplete styles */
.autocomplete-items {
    background-color: #ffffff;
    border: 1px solid #e2e8f0;
    border-top: none;
    z-index: 99;
    max-height: 250px;
    overflow-y: auto;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    border-radius: 0 0 0.375rem 0.375rem;
}

.autocomplete-items div {
    padding: 10px;
    cursor: pointer;
    border-bottom: 1px solid #e2e8f0;
    transition: background-color 0.2s ease;
}

.autocomplete-items div:hover {
    background-color: #f3f4f6;
}

.autocomplete-active {
    background-color: #e65100 !important;
    color: #ffffff;
}

/* User menu transitions */
#user-menu {
    transform-origin: top right;
    transition: opacity 0.2s ease, transform 0.2s ease, visibility 0.2s ease;
    opacity: 0;
    transform: scale(0.95);
    visibility: hidden;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
}

#user-menu:not(.hidden) {
    opacity: 1;
    transform: scale(1);
    visibility: visible;
}

/* Enhanced scrollbar */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 4px;
}

::-webkit-scrollbar-thumb {
    background: #e65100;
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: #ff6d00;
}

/* Print styles */
@media print {
    body {
        background-color: white !important;
        color: black !important;
    }
    
    .container, .bg-white, table, tr, td, th {
        background-color: white !important;
        color: black !important;
    }
    
    .pagebreak {
        page-break-before: always;
    }
    
    .no-print {
        display: none !important;
    }
    
    a {
        text-decoration: none !important;
        color: #000 !important;
    }
    
    @page {
        margin: 1.5cm;
    }
}

/* Mobile optimizations */
@media (max-width: 640px) {
    /* Enhanced touch targets */
    button, 
    a[href]:not(.inline-link),
    input[type="submit"],
    input[type="button"],
    select,
    .nav-link {
        min-height: 44px;
        min-width: 44px;
        padding: 0.5rem;
        display: inline-flex;
        align-items: center;
        justify-content: center;
    }
    
    /* Table adjustments */
    table {
        display: block;
        overflow-x: auto;
        white-space: nowrap;
    }
    
    /* Improve touch targets in tables */
    td a, th a {
        padding: 0.5rem;
        margin: -0.5rem;
        display: inline-block;
    }
    
    /* Padding for bottom mobile nav */
    body {
        padding-bottom: 5rem;
    }
    
    /* Improved form spacing */
    label {
        margin-bottom: 0.5rem;
        display: block;
    }
    
    input, select, textarea {
        font-size: 16px; /* Prevents iOS zoom on focus */
    }
    
    /* Add more space between form fields */
    .form-group + .form-group,
    .grid > div {
        margin-top: 1rem;
    }
    
    /* Make modal dialogs take up more screen space */
    .modal {
        width: 95%;
        margin: 0 auto;
    }
    
    /* Full-width buttons on mobile */
    .btn-group {
        flex-direction: column;
        width: 100%;
    }
    
    /* Adjust notification styles */
    .notification {
        width: 95%;
        margin: 0 auto 1rem;
    }
}

/* Tablet optimizations */
@media (min-width: 641px) and (max-width: 1024px) {
    /* Adjusted layout for tablets */
    .container {
        padding-left: 1rem;
        padding-right: 1rem;
    }
    
    /* Table responsive adjustments */
    .table-responsive {
        overflow-x: auto;
    }
    
    /* Better spacing for forms */
    .form-row > div {
        margin-bottom: 1rem;
    }
}

/* Helper classes */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border-width: 0;
}

.sr-only-focusable:not(:focus) {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border-width: 0;
}