/**
 * App Standardized CSS - Global styles for the standardized application
 * This file contains common styles that work across all components
 */

/* =============================================================================
   Reset and Base Styles
   ========================================================================== */

/* Ensure consistent box sizing */
*,
*::before,
*::after {
    box-sizing: border-box;
}

/* Smooth scrolling */
html {
    scroll-behavior: smooth;
}

/* Body improvements */
body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    line-height: 1.6;
    color: #333;
    background-color: #f8f9fa;
}

/* =============================================================================
   Layout Utilities
   ========================================================================== */

/* Content wrapper improvements */
.content-wrapper {
    width: 100%;
    max-width: 100%;
    margin: 0 auto;
    padding: 1rem;
}

@media (min-width: 768px) {
    .content-wrapper {
        padding: 2rem;
    }
}

/* Container improvements */
.container {
    width: 100%;
    max-width: 1400px;
    margin: 0 auto;
    padding-left: 15px;
    padding-right: 15px;
}

/* =============================================================================
   Card Components
   ========================================================================== */

.card {
    background: #ffffff;
    border: 1px solid rgba(0, 0, 0, 0.08);
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    transition: all 0.3s ease;
    margin-bottom: 1.5rem;
    overflow: hidden;
}

.card:hover {
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.12);
    transform: translateY(-1px);
}

.card-header {
    background-color: #f8f9fa;
    border-bottom: 1px solid #e9ecef;
    padding: 1.25rem;
    font-weight: 600;
    color: #495057;
}

.card-body {
    padding: 1.25rem;
}

.card-footer {
    background-color: #f8f9fa;
    border-top: 1px solid #e9ecef;
    padding: 1rem 1.25rem;
}

/* =============================================================================
   Form Controls
   ========================================================================== */

.form-control,
.form-select {
    border-radius: 8px;
    border: 1px solid #ced4da;
    transition: all 0.3s ease;
    font-size: 1rem;
    padding: 0.5rem 0.75rem;
}

.form-control:focus,
.form-select:focus {
    border-color: #667eea;
    box-shadow: 0 0 0 0.2rem rgba(102, 126, 234, 0.25);
    outline: none;
}

.form-control:disabled,
.form-select:disabled {
    background-color: #f8f9fa;
    opacity: 0.7;
}

/* Form groups */
.form-group {
    margin-bottom: 1rem;
}

.form-group label {
    font-weight: 500;
    margin-bottom: 0.5rem;
    color: #495057;
}

/* Form validation */
.is-invalid {
    border-color: #dc3545;
}

.is-invalid:focus {
    border-color: #dc3545;
    box-shadow: 0 0 0 0.2rem rgba(220, 53, 69, 0.25);
}

.invalid-feedback {
    display: block;
    font-size: 0.875rem;
    color: #dc3545;
    margin-top: 0.25rem;
}

/* =============================================================================
   Button Components
   ========================================================================== */

.btn {
    border-radius: 8px;
    font-weight: 500;
    padding: 0.5rem 1rem;
    transition: all 0.3s ease;
    border: 1px solid transparent;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    text-decoration: none;
}

.btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

.btn:active {
    transform: translateY(0);
}

.btn-primary {
    background-color: #667eea;
    border-color: #667eea;
    color: #ffffff;
}

.btn-primary:hover {
    background-color: #5a6fd8;
    border-color: #5a6fd8;
}

.btn-secondary {
    background-color: #6c757d;
    border-color: #6c757d;
    color: #ffffff;
}

.btn-success {
    background-color: #28a745;
    border-color: #28a745;
    color: #ffffff;
}

.btn-danger {
    background-color: #dc3545;
    border-color: #dc3545;
    color: #ffffff;
}

.btn-outline-primary {
    color: #667eea;
    border-color: #667eea;
    background-color: transparent;
}

.btn-outline-primary:hover {
    background-color: #667eea;
    color: #ffffff;
}

/* Button sizes */
.btn-sm {
    padding: 0.375rem 0.75rem;
    font-size: 0.875rem;
}

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

/* =============================================================================
   Modal Components
   ========================================================================== */

.modal-content {
    border: none;
    border-radius: 12px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.15);
}

.modal-header {
    background-color: #f8f9fa;
    border-bottom: 1px solid #e9ecef;
    border-radius: 12px 12px 0 0;
    padding: 1.25rem;
}

.modal-title {
    font-weight: 600;
    color: #495057;
}

.modal-body {
    padding: 1.5rem;
    max-height: 70vh;
    overflow-y: auto;
}

.modal-footer {
    background-color: #f8f9fa;
    border-top: 1px solid #e9ecef;
    border-radius: 0 0 12px 12px;
    padding: 1rem 1.25rem;
}

/* =============================================================================
   Table Components
   ========================================================================== */

.table {
    background: #ffffff;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    margin-bottom: 1.5rem;
}

.table thead th {
    background-color: #f8f9fa;
    border-bottom: 2px solid #e9ecef;
    font-weight: 600;
    text-transform: uppercase;
    font-size: 0.875rem;
    letter-spacing: 0.5px;
    color: #495057;
    padding: 1rem 0.75rem;
    border-top: none;
}

.table tbody tr {
    transition: background-color 0.2s ease;
}

.table tbody tr:hover {
    background-color: #f8f9fa;
}

.table td {
    padding: 0.75rem;
    vertical-align: middle;
    border-top: 1px solid #e9ecef;
}

.table-responsive {
    border-radius: 12px;
    overflow: hidden;
}

/* =============================================================================
   Alert Components
   ========================================================================== */

.alert {
    border: none;
    border-radius: 8px;
    padding: 1rem 1.25rem;
    margin-bottom: 1rem;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.08);
}

.alert-success {
    background-color: #d4edda;
    color: #155724;
}

.alert-danger {
    background-color: #f8d7da;
    color: #721c24;
}

.alert-warning {
    background-color: #fff3cd;
    color: #856404;
}

.alert-info {
    background-color: #d1ecf1;
    color: #0c5460;
}

/* =============================================================================
   Badge Components
   ========================================================================== */

.badge {
    padding: 0.375rem 0.75rem;
    border-radius: 6px;
    font-weight: 500;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* =============================================================================
   Accordion Components
   ========================================================================== */

.accordion {
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.accordion-item {
    border: none;
    border-bottom: 1px solid #e9ecef;
}

.accordion-item:last-child {
    border-bottom: none;
}

.accordion-header {
    background-color: #f8f9fa;
}

.accordion-button {
    background-color: #f8f9fa;
    border: none;
    padding: 1.25rem;
    font-weight: 600;
    color: #495057;
}

.accordion-button:not(.collapsed) {
    background-color: #667eea;
    color: #ffffff;
}

.accordion-body {
    padding: 1.25rem;
}

/* =============================================================================
   Loading States
   ========================================================================== */

.loading {
    opacity: 0.6;
    pointer-events: none;
    position: relative;
}

.loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 20px;
    height: 20px;
    margin: -10px 0 0 -10px;
    border: 2px solid #f3f3f3;
    border-top: 2px solid #667eea;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Spinner component */
.spinner-border-sm {
    width: 1rem;
    height: 1rem;
}

/* =============================================================================
   Navigation Improvements
   ========================================================================== */

.navbar {
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    border-bottom: 1px solid rgba(0, 0, 0, 0.1);
}

.nav-link {
    transition: color 0.3s ease;
    font-weight: 500;
}

.nav-link:hover {
    color: #667eea;
}

/* =============================================================================
   Utility Classes
   ========================================================================== */

/* Text utilities */
.text-muted {
    color: #6c757d !important;
}

.text-primary {
    color: #667eea !important;
}

.text-success {
    color: #28a745 !important;
}

.text-danger {
    color: #dc3545 !important;
}

.text-warning {
    color: #ffc107 !important;
}

/* Background utilities */
.bg-light {
    background-color: #f8f9fa !important;
}

/* =============================================================================
   Page Header Components (Standardized)
   ========================================================================== */

/* Standard Page Header */
.tw-page-header {
    border-radius: 0.5rem;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    padding: 1.5rem;
    margin-bottom: 1.5rem;
    background: linear-gradient(to right, #2563eb, #1e40af);
    color: white;
    position: relative;
    overflow: hidden;
}

.tw-page-header::before {
    content: '';
    position: absolute;
    top: 0;
    right: 0;
    bottom: 0;
    left: 0;
    background: linear-gradient(to right, #2563eb, #1d4ed8, #1e40af);
    opacity: 0.9;
}

.tw-page-header-content {
    position: relative;
    z-index: 10;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 1rem;
}

.tw-page-header-text {
    flex: 1;
    min-width: 0;
}

.tw-page-header-actions {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.tw-page-title {
    font-size: 1.875rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
    line-height: 1.25;
    margin-top: 0;
}

.tw-page-subtitle {
    font-size: 1.125rem;
    font-weight: 300;
    opacity: 0.9;
    line-height: 1.625;
    margin-bottom: 0;
}

/* Header Color Variants */
.tw-page-header-primary {
    background: linear-gradient(to right, #667eea, #764ba2);
}

.tw-page-header-primary::before {
    background: linear-gradient(to right, #667eea, #7c3aed, #764ba2);
}

.tw-page-header-success {
    background: linear-gradient(to right, #059669, #047857);
}

.tw-page-header-success::before {
    background: linear-gradient(to right, #059669, #0d9488, #047857);
}

.tw-page-header-warning {
    background: linear-gradient(to right, #d97706, #b45309);
}

.tw-page-header-warning::before {
    background: linear-gradient(to right, #d97706, #ca8a04, #b45309);
}

.tw-page-header-danger {
    background: linear-gradient(to right, #dc2626, #b91c1c);
}

.tw-page-header-danger::before {
    background: linear-gradient(to right, #dc2626, #e11d48, #b91c1c);
}

.tw-page-header-info {
    background: linear-gradient(to right, #0891b2, #0e7490);
}

.tw-page-header-info::before {
    background: linear-gradient(to right, #0891b2, #0284c7, #0e7490);
}

.tw-page-header-secondary {
    background: linear-gradient(to right, #4b5563, #374151);
}

.tw-page-header-secondary::before {
    background: linear-gradient(to right, #4b5563, #6b7280, #374151);
}

.tw-page-header-dark {
    background: linear-gradient(to right, #1f2937, #111827);
}

.tw-page-header-dark::before {
    background: linear-gradient(to right, #1f2937, #374151, #111827);
}

/* Responsive adjustments for page headers */
@media (max-width: 768px) {
    .tw-page-header {
        padding: 1rem;
        margin-bottom: 1rem;
    }
    
    .tw-page-header-content {
        flex-direction: column;
        align-items: stretch;
    }
    
    .tw-page-header-actions {
        align-items: center;
        margin-top: 0.5rem;
    }
    
    .tw-page-title {
        font-size: 1.5rem;
        margin-bottom: 0.25rem;
    }
    
    .tw-page-subtitle {
        font-size: 1rem;
    }
}

/* =============================================================================
   Search Bar Components (Standardized)
   ========================================================================== */

/* Search Bar Container */
.tw-search-bar {
    position: relative;
    display: flex;
    align-items: center;
    max-width: 400px;
    width: 100%;
}

/* Search Input */
.tw-search-input {
    width: 100%;
    padding: 0.75rem 1rem;
    padding-left: 2.5rem;
    border: 1px solid #d1d5db;
    border-radius: 0.5rem;
    font-size: 0.875rem;
    background-color: white;
    color: #374151;
    transition: all 0.2s ease-in-out;
}

.tw-search-input:focus {
    outline: none;
    border-color: #2563eb;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.tw-search-input::placeholder {
    color: #9ca3af;
}

/* Search Icon */
.tw-search-icon {
    position: absolute;
    left: 0.75rem;
    top: 50%;
    transform: translateY(-50%);
    color: #6b7280;
    z-index: 10;
    pointer-events: none;
}

/* Search Clear Button */
.tw-search-clear {
    position: absolute;
    right: 3rem;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    color: #6b7280;
    cursor: pointer;
    padding: 0.25rem;
    display: none;
    z-index: 10;
}

.tw-search-clear:hover {
    color: #374151;
}

.tw-search-clear.show {
    display: block;
}

/* Search Bar Variants */
.tw-search-bar-compact {
    max-width: 300px;
}

.tw-search-bar-expanded {
    max-width: 600px;
}

.tw-search-bar-full {
    max-width: none;
}

/* Search Bar with Button */
.tw-search-with-button {
    display: flex;
    max-width: 500px;
    width: 100%;
}

.tw-search-with-button .tw-search-input,
.tw-filter-bar .tw-search-bar .tw-search-input {
    border-top-right-radius: 0;
    border-bottom-right-radius: 0;
    border-right: none;
}

.tw-search-with-button .tw-search-button,
.tw-search-button {
    padding: 0.80rem 1rem;
    background-color: #1f2937;
    color: white;
    border: 1px solid #1f2937;
    border-top-right-radius: 0.5rem;
    border-bottom-right-radius: 0.5rem;
    cursor: pointer;
    transition: all 0.2s ease-in-out;
    white-space: nowrap;
    font-size: 0.875rem;
    font-weight: 500;
}

.tw-search-with-button .tw-search-button:hover,
.tw-search-button:hover {
    background-color: #111827;
    border-color: #111827;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
}

.tw-search-with-button .tw-search-button:focus,
.tw-search-button:focus {
    outline: none;
    background-color: #111827;
    border-color: #111827;
    box-shadow: 0 0 0 3px rgba(75, 85, 99, 0.1);
}

/* =============================================================================
   Filter Bar Components (Standardized)
   ========================================================================== */

/* Filter Bar Container */
.tw-filter-bar {
    background-color: white;
    border-radius: 0.5rem;
    box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px 0 rgba(0, 0, 0, 0.06);
    border: 1px solid #e5e7eb;
    padding: 1rem 1.5rem;
    margin-bottom: 1.5rem;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 1rem;
}

/* Filter Bar Left Section - Search and Filters */
.tw-filter-bar-left {
    display: flex;
    align-items: center;
    gap: 1rem;
    flex: 1;
    min-width: 0;
    flex-wrap: wrap;
}

/* Filter Bar Right Section - Status Tabs and Counter */
.tw-filter-bar-right {
    display: flex;
    align-items: center;
    gap: 1rem;
    flex-shrink: 0;
}

/* Filter Bar Field Group */
.tw-filter-field-group {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

/* Filter Bar Field Label */
.tw-filter-field-label {
    font-size: 0.875rem;
    font-weight: 500;
    color: #374151;
    white-space: nowrap;
}

/* Filter Bar Counter */
.tw-filter-counter {
    background-color: #f3f4f6;
    color: #374151;
    padding: 0.375rem 0.75rem;
    border-radius: 0.375rem;
    font-size: 0.875rem;
    font-weight: 500;
    border: 1px solid #d1d5db;
}

/* Filter Bar Date Input */
.tw-filter-date-input {
    padding: 0.375rem 0.75rem;
    border: 1px solid #d1d5db;
    border-radius: 0.375rem;
    font-size: 0.875rem;
    background-color: white;
    width: 140px;
    transition: border-color 0.15s ease-in-out;
}

.tw-filter-date-input:focus {
    outline: none;
    border-color: #2563eb;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

/* Filter Bar Select Input */
.tw-filter-select-input {
    padding: 0.375rem 0.75rem;
    border: 1px solid #d1d5db;
    border-radius: 0.375rem;
    font-size: 0.875rem;
    background-color: white;
    width: 140px;
    transition: border-color 0.15s ease-in-out;
}

.tw-filter-select-input:focus {
    outline: none;
    border-color: #2563eb;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

/* Connected Button Group Filter Tabs */
.tw-filter-tabs {
    display: flex;
}

.tw-filter-tab {
    padding: 0.5rem 1rem;
    text-align: center;
    font-size: 0.875rem;
    transition: all 0.2s ease-in-out;
    cursor: pointer;
    border: none;
    background: transparent;
    color: #64748b;
    text-decoration: none;
    white-space: nowrap;
    position: relative;
    z-index: 1;
}

.tw-filter-tab:hover {
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    color: white;
    background-color: #1e293b;
    text-decoration: none;
    z-index: 2;
}

.tw-filter-tab:focus {
    color: white;
    background-color: #1e293b;
    z-index: 2;
    outline: none;
}

.tw-filter-tab.active {
    color: white;
    background-color: #1e293b;
    z-index: 2;
}

.tw-filter-tab.active:hover {
    background-color: #0f172a;
}

.tw-filter-tab:disabled {
    pointer-events: none;
    opacity: 0.5;
    box-shadow: none;
}

/* First tab (Active) - rounded left, straight right */
.tw-filter-tab:first-child {
    border-radius: 0.375rem 0 0 0.375rem;
}

/* Middle tab (Archive) - no border radius, add left border divisor */
.tw-filter-tab:nth-child(2) {
    border-radius: 0;
    border-left: 1px solid #cbd5e1;
}

.tw-filter-tab:nth-child(2):hover {
    border-left: 1px solid #1e293b;
}

.tw-filter-tab:nth-child(2):focus,
.tw-filter-tab:nth-child(2).active {
    border-left: 1px solid #1e293b;
}

/* Last tab (All) - straight left, rounded right, add left border divisor */
.tw-filter-tab:last-child {
    border-radius: 0 0.375rem 0.375rem 0;
    border-left: 1px solid #cbd5e1;
}

.tw-filter-tab:last-child:hover {
    border-left: 1px solid #1e293b;
}

.tw-filter-tab:last-child:focus,
.tw-filter-tab:last-child.active {
    border-left: 1px solid #1e293b;
}

/* Responsive adjustments for search and filter bars */
@media (max-width: 768px) {
    .tw-search-bar {
        max-width: none;
    }
    
    .tw-search-with-button {
        max-width: none;
    }
    
    .tw-filter-bar {
        flex-direction: column;
        align-items: stretch;
        gap: 1rem;
    }
    
    .tw-filter-bar-left {
        flex-direction: column;
        align-items: stretch;
        gap: 0.75rem;
    }
    
    .tw-filter-bar-right {
        justify-content: center;
        flex-wrap: wrap;
    }
    
    .tw-filter-field-group {
        justify-content: space-between;
    }
    
    .tw-filter-date-input,
    .tw-filter-select-input {
        width: auto;
        flex: 1;
    }
    
    .tw-filter-tabs {
        justify-content: center;
    }
}

.bg-white {
    background-color: #ffffff !important;
}

.bg-primary {
    background-color: #667eea !important;
}

/* Border utilities */
.border-0 {
    border: 0 !important;
}

.border-top {
    border-top: 1px solid #e9ecef !important;
}

.border-bottom {
    border-bottom: 1px solid #e9ecef !important;
}

/* Shadow utilities */
.shadow-sm {
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.08) !important;
}

.shadow {
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08) !important;
}

.shadow-lg {
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.12) !important;
}

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

/* Hide on mobile */
@media (max-width: 767.98px) {
    .d-md-block {
        display: none !important;
    }
    
    .d-md-none {
        display: block !important;
    }
    
    /* Smaller padding on mobile */
    .card-body {
        padding: 1rem;
    }
    
    .modal-body {
        padding: 1rem;
    }
    
    /* Stack buttons on mobile */
    .btn-group-mobile .btn {
        display: block;
        width: 100%;
        margin-bottom: 0.5rem;
    }
}

/* Hide on desktop */
@media (min-width: 768px) {
    .d-md-none {
        display: none !important;
    }
    
    .d-md-block {
        display: block !important;
    }
}

/* =============================================================================
   Accessibility Improvements
   ========================================================================== */

/* Focus indicators */
.btn:focus,
.form-control:focus,
.form-select:focus {
    outline: 2px solid #667eea;
    outline-offset: 2px;
}

/* Skip links */
.skip-link {
    position: absolute;
    top: -40px;
    left: 6px;
    background: #000;
    color: #fff;
    padding: 8px;
    text-decoration: none;
    z-index: 100;
}

.skip-link:focus {
    top: 6px;
}

/* Screen reader only content */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* =============================================================================
   Print Styles
   ========================================================================== */

@media print {
    .no-print {
        display: none !important;
    }
    
    .card {
        box-shadow: none;
        border: 1px solid #000;
    }
    
    .btn {
        background: none !important;
        border: 1px solid #000 !important;
        color: #000 !important;
    }
}