/* ========================================
   HIS Animal Rescue - Custom Styles
   Bootstrap 5 + Custom Design System
======================================== */

/* ========================================
   1. TYPOGRAPHY & BASE
======================================== */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');

:root {
    /* Color Palette - Blue Theme */
    --primary-blue: #1235ad;           /* Main brand color */
    --primary-blue-dark: #0d2680;      /* Darker shade for hover states */
    --primary-blue-light: #1a47d9;     /* Lighter shade for highlights */
    --primary-blue-lighter: #4d6fd9;   /* Even lighter for backgrounds */
    --accent-blue: #2563eb;            /* Accent blue for variety */
    --accent-yellow: #FFC107;          /* Keep yellow for warnings */
    --accent-yellow-dark: #FFA000;
    --error-red: #D32F2F;
    --primary-green: #2E7D32;
    --primary-green-light: #388E3C;
    --grey-50: #FAFAFA;
    --grey-100: #F5F5F5;
    --grey-200: #EEEEEE;
    --grey-300: #E0E0E0;
    --grey-400: #BDBDBD;
    --grey-500: #9E9E9E;
    --grey-600: #757575;
    --grey-700: #616161;
    --grey-800: #424242;
    --grey-900: #212121;
    
    /* Spacing */
    --sidebar-width: 260px;
    --navbar-height: 64px;
    --content-padding: 24px;
    
    /* Transitions */
    --transition-base: all 0.3s ease;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    font-size: 14px;
    height: 100%;
}

@media (min-width: 768px) {
    html {
        font-size: 16px;
    }
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background-color: var(--grey-100);
    color: var(--grey-900);
    min-height: 100%;
    overflow-x: hidden;
}

h1, h2, h3, h4, h5, h6 {
    font-weight: 600;
    color: var(--grey-900);
    margin-bottom: 1rem;
}

h1 { font-size: 2rem; }
h2 { font-size: 1.75rem; }
h3 { font-size: 1.5rem; }
h4 { font-size: 1.25rem; }
h5 { font-size: 1.1rem; }
h6 { font-size: 1rem; }

/* ========================================
   2. LAYOUT STRUCTURE
======================================== */
.app-wrapper {
    display: flex;
    min-height: 100vh;
}

/* Sidebar Navigation */
.sidebar {
    width: var(--sidebar-width);
    background: white;
    border-right: 1px solid var(--grey-300);
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    overflow-y: auto;
    overflow-x: hidden;
    transition: var(--transition-base);
    z-index: 1000;
    scroll-behavior: smooth;
}

.sidebar-header {
    padding: 1.5rem 1.25rem;
    border-bottom: 1px solid var(--grey-300);
    background: var(--primary-blue);
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    text-decoration: none;
    color: white;
}

.sidebar-brand-icon {
    width: 40px;
    height: 40px;
    background: white;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    color: var(--primary-blue);
}

.sidebar-brand-text {
    font-size: 1.25rem;
    font-weight: 700;
}

.sidebar-subtitle {
    font-size: 0.75rem;
    opacity: 0.9;
    margin-top: 0.25rem;
}

.sidebar-nav {
    padding: 1rem 0;
}

.nav-section-title {
    padding: 1rem 1.25rem 0.5rem;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--grey-600);
}

.sidebar-nav-item {
    list-style: none;
}

.sidebar-nav-link {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1.25rem;
    color: var(--grey-700);
    text-decoration: none;
    transition: var(--transition-base);
    border-left: 3px solid transparent;
}

.sidebar-nav-link:hover {
    background: var(--grey-100);
    color: var(--primary-blue);
}

.sidebar-nav-link.active {
    background: rgba(18, 53, 173, 0.08);
    color: var(--primary-blue);
    border-left-color: var(--primary-blue);
    font-weight: 600;
}

.sidebar-nav-icon {
    width: 20px;
    text-align: center;
    font-size: 1.1rem;
}

.sidebar-badge {
    margin-left: auto;
    font-size: 0.75rem;
}

/* Main Content Area */
.main-content {
    flex: 1;
    margin-left: var(--sidebar-width);
    transition: var(--transition-base);
    display: flex;
    flex-direction: column;
    height: 100vh;
    overflow: hidden;
}

/* Top Navbar */
.top-navbar {
    height: var(--navbar-height);
    background: white;
    border-bottom: 1px solid var(--grey-300);
    display: flex;
    align-items: center;
    padding: 0 var(--content-padding);
    position: sticky;
    top: 0;
    z-index: 999;
}

.navbar-left {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.navbar-right {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 1.5rem;
}

.page-title {
    font-size: 1.5rem;
    font-weight: 600;
    margin: 0;
}

/* Search Bar */
.search-bar {
    position: relative;
    width: 300px;
}

.search-bar input {
    width: 100%;
    padding: 0.5rem 1rem 0.5rem 2.5rem;
    border: 1px solid var(--grey-300);
    border-radius: 8px;
    transition: var(--transition-base);
}

.search-bar input:focus {
    outline: none;
    border-color: var(--primary-blue);
    box-shadow: 0 0 0 3px rgba(18, 53, 173, 0.1);
}

.search-icon {
    position: absolute;
    left: 0.75rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--grey-500);
}

/* Sync Indicator */
.sync-indicator {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    border-radius: 8px;
    font-size: 0.875rem;
    font-weight: 500;
}

.sync-indicator.online {
    background: rgba(46, 125, 50, 0.1);
    color: var(--primary-green);
}

.sync-indicator.offline {
    background: rgba(211, 47, 47, 0.1);
    color: var(--error-red);
}

.sync-indicator.syncing {
    background: rgba(255, 193, 7, 0.1);
    color: var(--accent-yellow-dark);
}

.sync-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: currentColor;
}

/* User Profile Dropdown */
.user-profile {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    cursor: pointer;
    padding: 0.5rem 1rem;
    border-radius: 8px;
    transition: var(--transition-base);
}

.user-profile:hover {
    background: var(--grey-100);
}

.user-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--primary-green);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
}

.user-info {
    display: flex;
    flex-direction: column;
}

.user-name {
    font-weight: 600;
    font-size: 0.875rem;
}

.user-role {
    font-size: 0.75rem;
    color: var(--grey-600);
}

/* Content Container */
.content-container {
    padding: var(--content-padding);
    max-width: 1400px;
    overflow-y: auto;
    height: calc(100vh - var(--navbar-height));
}

.content-container.full-width {
    max-width: 100%;
}

/* ========================================
   3. BOOTSTRAP OVERRIDES & COMPONENTS
======================================== */

/* Buttons */
.btn {
    padding: 0.625rem 1.25rem;
    border-radius: 8px;
    font-weight: 500;
    transition: var(--transition-base);
    border: none;
}

.btn-primary {
    background: var(--primary-blue);
    color: white;
}

.btn-primary:hover {
    background: var(--primary-blue-dark);
}

.btn-success {
    background: var(--primary-green-light);
}

.btn-warning {
    background: var(--accent-yellow);
    color: var(--grey-900);
}

.btn-warning:hover {
    background: var(--accent-yellow-dark);
}

.btn-danger {
    background: var(--error-red);
}

.btn-outline-primary {
    border: 2px solid var(--primary-blue);
    color: var(--primary-blue);
    background: transparent;
}

.btn-outline-primary:hover {
    background: var(--primary-blue);
    color: white;
}

.btn-lg {
    padding: 0.875rem 2rem;
    font-size: 1.1rem;
}

.btn-sm {
    padding: 0.375rem 0.875rem;
    font-size: 0.875rem;
}

/* Cards */
.card {
    border: 1px solid var(--grey-300);
    border-radius: 20px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
    margin-bottom: 1.5rem;
    background: white;
    overflow: hidden;
}

.card-header {
    background: white;
    border-bottom: 1px solid var(--grey-300);
    padding: 1.25rem 1.5rem;
    font-weight: 600;
    font-size: 1.1rem;
}

.card-body {
    padding: 1.5rem;
}

.card-stats {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.card-stats-icon {
    width: 48px;
    height: 48px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
}

.card-stats-icon.green {
    background: rgba(46, 125, 50, 0.1);
    color: var(--primary-green);
}

.card-stats-icon.yellow {
    background: rgba(255, 193, 7, 0.1);
    color: var(--accent-yellow-dark);
}

.card-stats-icon.red {
    background: rgba(211, 47, 47, 0.1);
    color: var(--error-red);
}

.card-stats-content {
    flex: 1;
}

.card-stats-label {
    font-size: 0.875rem;
    color: var(--grey-600);
    margin-bottom: 0.25rem;
}

.card-stats-value {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--grey-900);
}

.card-stats-change {
    font-size: 0.875rem;
    margin-top: 0.25rem;
}

.card-stats-change.positive {
    color: var(--primary-green);
}

.card-stats-change.negative {
    color: var(--error-red);
}

/* Badges */
.badge {
    padding: 0.375rem 0.75rem;
    border-radius: 6px;
    font-weight: 600;
    font-size: 0.75rem;
    letter-spacing: 0.3px;
}

.badge-status-active {
    background: rgba(46, 125, 50, 0.1);
    color: var(--primary-green);
}

.badge-status-pending {
    background: rgba(255, 193, 7, 0.1);
    color: var(--accent-yellow-dark);
}

.badge-status-critical {
    background: rgba(211, 47, 47, 0.1);
    color: var(--error-red);
}

.badge-status-completed {
    background: rgba(46, 125, 50, 0.1);
    color: var(--primary-green);
}

.badge-status-deceased {
    background: rgba(0, 0, 0, 0.7);
    color: white;
}

.badge-status-released {
    background: rgba(33, 150, 243, 0.1);
    color: #1976D2;
}

/* Forms */
.form-label {
    font-weight: 600;
    color: var(--grey-800);
    margin-bottom: 0.5rem;
    font-size: 0.875rem;
}

.form-control, .form-select {
    padding: 0.75rem 1rem;
    border: 1px solid var(--grey-300);
    border-radius: 8px;
    transition: var(--transition-base);
    font-size: 0.938rem;
}

.form-control:focus, .form-select:focus {
    border-color: var(--primary-blue);
    box-shadow: 0 0 0 3px rgba(18, 53, 173, 0.1);
}

.form-section {
    background: white;
    padding: 1.5rem;
    border-radius: 16px;
    border: 1px solid var(--grey-300);
    margin-bottom: 1.5rem;
}

.form-section-title {
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: 1.25rem;
    padding-bottom: 0.75rem;
    border-bottom: 2px solid var(--grey-200);
}

.form-row {
    margin-bottom: 1.25rem;
}

.form-actions {
    display: flex;
    gap: 1rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--grey-300);
}

/* Tables */
.table-container {
    background: white;
    border-radius: 12px;
    border: 1px solid var(--grey-300);
    overflow: hidden;
    margin-bottom: 1.5rem;
}

.table {
    margin: 0;
}

.table thead th {
    background: var(--grey-50);
    color: var(--grey-800);
    font-weight: 600;
    font-size: 0.875rem;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    border-bottom: 2px solid var(--grey-300);
    padding: 1rem;
    white-space: nowrap;
}

.table tbody td {
    padding: 1rem;
    vertical-align: middle;
    border-bottom: 1px solid var(--grey-200);
}

.table tbody tr:last-child td {
    border-bottom: none;
}

.table tbody tr:hover {
    background: var(--grey-50);
}

.table-actions {
    display: flex;
    gap: 0.0rem;
    flex-wrap: nowrap;
}

.table-responsive {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

@media (max-width: 768px) {
    .table thead th,
    .table tbody td {
        padding: 0.75rem 0.5rem;
        font-size: 0.813rem;
    }
    
    .table thead th {
        font-size: 0.75rem;
    }
}

/* ========================================
   TABLE FIXED COLUMN WIDTHS
======================================== */

/* Base table layout for fixed columns */
.table-fixed {
    table-layout: fixed;
    width: 100%;
}

/* Common column widths */
.table thead th.col-name {
    width: 20%;
    min-width: 150px;
}

.table thead th.col-description {
    width: 30%;
    min-width: 200px;
}

.table thead th.col-status {
    width: 100px;
    min-width: 100px;
}

.table thead th.col-actions {
    width: 120px;
    min-width: 120px;
}

.table thead th.col-small {
    width: 100px;
    min-width: 100px;
}

.table thead th.col-medium {
    width: 150px;
    min-width: 150px;
}

.table thead th.col-large {
    width: 200px;
    min-width: 200px;
}

/* Fixed table styling - ensure table layout is fixed */
.table-fixed thead th {
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Text wrapping for table cells - force wrap on long content */
.table-fixed tbody td {
    word-wrap: break-word;
    overflow-wrap: break-word;
    white-space: normal;
    vertical-align: middle;
    max-width: 0; /* Forces cell to respect column width */
}

/* Prevent actions column from wrapping */
.table-fixed tbody td:last-child {
    white-space: nowrap;
    overflow: visible;
    max-width: none;
}

/* Long text handling */
.table .text-truncate-cell {
    max-width: 200px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.table .text-wrap-cell {
    word-wrap: break-word;
    overflow-wrap: break-word;
    white-space: normal;
}

/* Ensure text in fixed tables wraps properly */
.table-fixed .text-wrap-cell {
    word-break: break-word;
    hyphens: auto;
}

/* Responsive table adjustments */
@media (max-width: 992px) {
    .table-fixed {
        table-layout: auto;
    }
    
    .table-fixed tbody td {
        max-width: none;
    }
    
    .table thead th.col-name,
    .table thead th.col-description,
    .table thead th.col-medium,
    .table thead th.col-large {
        min-width: auto;
        width: auto;
    }
}

/* Alerts */
.alert {
    border-radius: 10px;
    border: none;
    padding: 1rem 1.25rem;
    margin-bottom: 1.5rem;
}

.alert-success {
    background: rgba(46, 125, 50, 0.1);
    color: var(--primary-green);
}

.alert-warning {
    background: rgba(255, 193, 7, 0.1);
    color: var(--accent-yellow-dark);
}

.alert-danger {
    background: rgba(211, 47, 47, 0.1);
    color: var(--error-red);
}

/* Modals */
.modal-content {
    border-radius: 12px;
    border: none;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.15);
    overflow: hidden;
}

.modal-header {
    border-bottom: 1px solid var(--grey-300);
    padding: 1.5rem;
}

.modal-title {
    font-weight: 600;
    font-size: 1.25rem;
}

.modal-body {
    padding: 1.5rem;
}

.modal-footer {
    border-top: 1px solid var(--grey-300);
    padding: 1.25rem 1.5rem;
}

/* ========================================
   4. CUSTOM COMPONENTS
======================================== */

/* Timeline */
.timeline {
    position: relative;
    padding-left: 1.7rem;
}

.timeline::before {
    content: '';
    position: absolute;
    left: 0.5rem;
    top: 0;
    bottom: 0;
    width: 2px;
    background: var(--grey-300);
}

.timeline-item {
    position: relative;
    padding-bottom: 2rem;
}

.timeline-item:last-child {
    padding-bottom: 0;
}

.timeline-marker {
    position: absolute;
    left: -1.5rem;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: var(--primary-blue);
    border: 3px solid white;
    box-shadow: 0 0 0 2px var(--grey-300);
}

.timeline-content {
    background: white;
    padding: 1rem;
    border-radius: 8px;
    border: 1px solid var(--grey-300);
}

.timeline-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.5rem;
}

.timeline-title {
    font-weight: 600;
    color: var(--grey-900);
}

.timeline-date {
    font-size: 0.75rem;
    color: var(--grey-600);
}

.timeline-body {
    color: var(--grey-700);
    font-size: 0.938rem;
}

/* Animal Card */
.animal-card {
    background: white;
    border: 1px solid var(--grey-300);
    border-radius: 12px;
    overflow: hidden;
    transition: var(--transition-base);
    cursor: pointer;
}

.animal-card:hover {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    transform: translateY(-2px);
}

.animal-card-image {
    width: 100%;
    height: 180px;
    object-fit: cover;
    background: var(--grey-200);
}

.animal-card-body {
    padding: 1rem;
}

.animal-card-id {
    font-size: 0.75rem;
    color: var(--grey-600);
    margin-bottom: 0.25rem;
}

.animal-card-name {
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
}

.animal-card-meta {
    display: flex;
    gap: 0.75rem;
    margin-bottom: 0.75rem;
    font-size: 0.875rem;
    color: var(--grey-700);
}

.animal-card-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-top: 0.75rem;
    border-top: 1px solid var(--grey-200);
}

/* Photo Uploader */
.photo-uploader {
    border: 2px dashed var(--grey-300);
    border-radius: 12px;
    padding: 2rem;
    text-align: center;
    cursor: pointer;
    transition: var(--transition-base);
}

.photo-uploader:hover {
    border-color: var(--primary-blue);
    background: rgba(18, 53, 173, 0.02);
}

.photo-uploader-icon {
    font-size: 3rem;
    color: var(--grey-400);
    margin-bottom: 1rem;
}

.photo-uploader-text {
    color: var(--grey-600);
    font-size: 0.938rem;
}

.photo-preview {
    margin-top: 1rem;
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
}

.photo-preview-item {
    position: relative;
    width: 100px;
    height: 100px;
    border-radius: 8px;
    overflow: hidden;
}

.photo-preview-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.photo-preview-remove {
    position: absolute;
    top: 4px;
    right: 4px;
    background: rgba(211, 47, 47, 0.9);
    color: white;
    border: none;
    border-radius: 50%;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}

/* Kennel Grid */
.kennel-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    gap: 1rem;
    padding: 1rem 0;
}

.kennel-cell {
    aspect-ratio: 1;
    border: 2px solid var(--grey-300);
    border-radius: 10px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: var(--transition-base);
    background: white;
}

.kennel-cell:hover {
    border-color: var(--primary-blue);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.kennel-cell.occupied {
    background: rgba(46, 125, 50, 0.05);
    border-color: var(--primary-green);
}

.kennel-cell.empty {
    background: white;
}

.kennel-cell.critical {
    background: rgba(211, 47, 47, 0.05);
    border-color: var(--error-red);
}

.kennel-number {
    font-size: 1.25rem;
    font-weight: 700;
    margin-bottom: 0.25rem;
}

.kennel-status {
    font-size: 0.75rem;
    color: var(--grey-600);
}

/* Stats Grid */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}

/* Quick Actions */
.quick-actions {
    display: flex;
    gap: 1rem;
    margin-bottom: 2rem;
    flex-wrap: wrap;
}

.quick-action-btn {
    flex: 1;
    min-width: 200px;
    padding: 1.25rem;
    background: white;
    border: 2px solid var(--grey-300);
    border-radius: 12px;
    display: flex;
    align-items: center;
    gap: 1rem;
    cursor: pointer;
    transition: var(--transition-base);
}

.quick-action-btn:hover {
    border-color: var(--primary-blue);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.quick-action-icon {
    width: 48px;
    height: 48px;
    background: rgba(46, 125, 50, 0.1);
    color: var(--primary-green);
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
}

.quick-action-text h4 {
    margin: 0 0 0.25rem 0;
    font-size: 1rem;
}

.quick-action-text p {
    margin: 0;
    font-size: 0.875rem;
    color: var(--grey-600);
}

/* Filter Bar */
.filter-bar {
    background: white;
    padding: 1.25rem;
    border-radius: 12px;
    border: 1px solid var(--grey-300);
    margin-bottom: 1.5rem;
}

.filter-bar .row {
    align-items: end;
}

.filter-bar .col-md-2,
.filter-bar .col-lg-2,
.filter-bar .col-lg-3,
.filter-bar .col-md-3 {
    margin-bottom: 1rem;
}

@media (max-width: 768px) {
    .filter-bar .row > div {
        margin-bottom: 0.75rem;
    }
    
    .filter-bar .row > div:last-child {
        margin-bottom: 0;
    }
}

/* ========================================
   5. RESPONSIVE DESIGN
======================================== */

/* Mobile Sidebar Toggle */
.sidebar-toggle {
    display: none;
    background: none;
    border: none;
    font-size: 1.5rem;
    color: var(--grey-700);
    cursor: pointer;
}

/* Tablet & Mobile */
@media (max-width: 991px) {
    .sidebar {
        transform: translateX(-100%);
    }
    
    .sidebar.active {
        transform: translateX(0);
    }
    
    .sidebar-toggle {
        display: block;
    }
    
    .main-content {
        margin-left: 0;
    }
    
    .search-bar {
        display: none;
    }
    
    .content-container {
        padding: 1rem;
        height: calc(100vh - var(--navbar-height));
        overflow-y: auto;
    }
    
    .stats-grid {
        grid-template-columns: 1fr;
        gap: 1rem;
    }
    
    .quick-actions {
        flex-direction: column;
    }
    
    .quick-action-btn {
        width: 100%;
    }
    
    .user-info {
        display: none;
    }
    
    .kennel-grid {
        grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
        gap: 0.75rem;
    }
    
    .table-container {
        margin-bottom: 1rem;
    }
    
    .filter-bar {
        padding: 1rem;
    }
}

@media (max-width: 576px) {
    .page-title {
        font-size: 1.25rem;
    }
    
    .navbar-right {
        gap: 0.75rem;
    }
    
    h1 { font-size: 1.5rem; }
    h2 { font-size: 1.25rem; }
    h3 { font-size: 1.1rem; }
    
    .content-container {
        padding: 0.75rem;
        height: calc(100vh - var(--navbar-height));
        overflow-y: auto;
    }
    
    .stats-grid {
        gap: 0.75rem;
    }
    
    .card-body {
        padding: 1rem;
    }
    
    .filter-bar {
        padding: 0.75rem;
    }
    
    .table-responsive {
        border-radius: 8px;
    }
}

/* Print Styles */
@media print {
    .sidebar, .top-navbar, .btn, .form-actions, .no-print {
        display: none !important;
    }
    
    .main-content {
        margin-left: 0;
    }
    
    body {
        background: white !important;
    }
    
    .card {
        page-break-inside: avoid;
        border: 1px solid #000 !important;
        box-shadow: none !important;
        margin-bottom: 20px;
    }
    
    .card-header {
        background: #f5f5f5 !important;
        border-bottom: 2px solid #000 !important;
        print-color-adjust: exact;
        -webkit-print-color-adjust: exact;
    }
    
    h1, h2, h3, h4, h5, h6 {
        page-break-after: avoid;
        color: #000 !important;
    }
    
    .table {
        page-break-inside: auto;
    }
    
    .table tr {
        page-break-inside: avoid;
        page-break-after: auto;
    }
    
    .table thead {
        display: table-header-group;
    }
    
    .badge {
        border: 1px solid #000 !important;
        print-color-adjust: exact;
        -webkit-print-color-adjust: exact;
    }
    
    a[href]:after {
        content: none !important;
    }
    
    .content-container {
        max-width: 100%;
        padding: 0;
        overflow: visible;
        height: auto;
    }
    
    .alert {
        border: 1px solid #000 !important;
        print-color-adjust: exact;
        -webkit-print-color-adjust: exact;
    }
}

/* Additional Responsive Fixes */
@media (max-width: 1200px) {
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 768px) {
    .stats-grid {
        grid-template-columns: 1fr;
    }
    
    .d-flex.justify-content-between {
        flex-direction: column;
        gap: 1rem;
        align-items: flex-start !important;
    }
    
    .d-flex.justify-content-between .d-flex.gap-2 {
        width: 100%;
    }
    
    .d-flex.justify-content-between .d-flex.gap-2 button,
    .d-flex.justify-content-between .d-flex.gap-2 a {
        flex: 1;
    }
}

/* Ensure body and html don't create extra scrollbars */
html, body {
    overflow: hidden;
    height: 100%;
}

.app-wrapper {
    height: 100vh;
    overflow: hidden;
}

/* Smooth scrolling for content container */
.content-container {
    scroll-behavior: smooth;
}

.content-container::-webkit-scrollbar {
    width: 8px;
}

.content-container::-webkit-scrollbar-track {
    background: var(--grey-100);
}

.content-container::-webkit-scrollbar-thumb {
    background: var(--grey-400);
    border-radius: 4px;
}

.content-container::-webkit-scrollbar-thumb:hover {
    background: var(--grey-500);
}

/* Sidebar Navigation */
.sidebar {
    width: var(--sidebar-width);
    background: white;
    border-right: 1px solid var(--grey-300);
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    overflow-y: auto;
    overflow-x: hidden;
    transition: var(--transition-base);
    z-index: 1000;
    scroll-behavior: smooth;
}

/* Custom scrollbar for sidebar */
.sidebar::-webkit-scrollbar {
    width: 6px;
}

.sidebar::-webkit-scrollbar-track {
    background: var(--grey-100);
}

.sidebar::-webkit-scrollbar-thumb {
    background: var(--grey-400);
    border-radius: 3px;
}

.sidebar::-webkit-scrollbar-thumb:hover {
    background: var(--grey-500);
}

/* ========================================
   AUTOCOMPLETE & DROPDOWN ENHANCEMENTS
======================================== */

/* Enhanced autocomplete styling */
input[list]::-webkit-calendar-picker-indicator {
    opacity: 0.6;
    cursor: pointer;
}

input[list]:hover::-webkit-calendar-picker-indicator {
    opacity: 1;
}

/* Datalist styling (limited support) */
datalist {
    display: none;
}

/* Custom autocomplete dropdown */
.autocomplete-wrapper {
    position: relative;
}

.autocomplete-suggestions {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: white;
    border: 1px solid var(--grey-300);
    border-top: none;
    border-radius: 0 0 8px 8px;
    max-height: 200px;
    overflow-y: auto;
    z-index: 1000;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    display: none;
}

.autocomplete-suggestions.active {
    display: block;
}

.autocomplete-suggestion {
    padding: 0.75rem 1rem;
    cursor: pointer;
    transition: var(--transition-base);
    border-bottom: 1px solid var(--grey-200);
}

.autocomplete-suggestion:last-child {
    border-bottom: none;
}

.autocomplete-suggestion:hover,
.autocomplete-suggestion.selected {
    background: var(--grey-100);
    color: var(--primary-blue);
}

/* Enhanced select dropdowns */
.form-select {
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3e%3cpath fill='none' stroke='%23343a40' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M2 5l6 6 6-6'/%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: right 0.75rem center;
    background-size: 16px 12px;
    cursor: pointer;
}

.form-select:focus {
    border-color: var(--primary-blue);
    box-shadow: 0 0 0 3px rgba(18, 53, 173, 0.1);
}

.form-select:disabled {
    background-color: var(--grey-100);
    cursor: not-allowed;
}

/* Multi-select styling */
.form-select[multiple] {
    padding: 0.5rem;
}

.form-select[multiple] option {
    padding: 0.5rem;
    border-radius: 4px;
    margin-bottom: 2px;
}

.form-select[multiple] option:checked {
    background: var(--primary-blue);
    color: white;
}

/* Required field indicator */
.form-label .text-danger {
    font-size: 1.1rem;
    margin-left: 2px;
}

/* Form field icons */
.form-field-icon {
    position: relative;
}

.form-field-icon input,
.form-field-icon select {
    padding-left: 2.5rem;
}

.form-field-icon .field-icon {
    position: absolute;
    left: 1rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--grey-500);
    pointer-events: none;
}

/* Input validation states */
.form-control.is-valid,
.form-select.is-valid {
    border-color: var(--primary-green);
    padding-right: calc(1.5em + 0.75rem);
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 8 8'%3e%3cpath fill='%232E7D32' d='M2.3 6.73L.6 4.53c-.4-1.04.46-1.4 1.1-.8l1.1 1.4 3.4-3.8c.6-.63 1.6-.27 1.2.7l-4 4.6c-.43.5-.8.4-1.1.1z'/%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: right calc(0.375em + 0.1875rem) center;
    background-size: calc(0.75em + 0.375rem) calc(0.75em + 0.375rem);
}

.form-control.is-invalid,
.form-select.is-invalid {
    border-color: var(--error-red);
    padding-right: calc(1.5em + 0.75rem);
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12' width='12' height='12' fill='none' stroke='%23D32F2F'%3e%3ccircle cx='6' cy='6' r='4.5'/%3e%3cpath stroke-linejoin='round' d='M5.8 3.6h.4L6 6.5z'/%3e%3ccircle cx='6' cy='8.2' r='.6' fill='%23D32F2F' stroke='none'/%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: right calc(0.375em + 0.1875rem) center;
    background-size: calc(0.75em + 0.375rem) calc(0.75em + 0.375rem);
}

.invalid-feedback,
.valid-feedback {
    display: none;
    font-size: 0.875rem;
    margin-top: 0.25rem;
}

.form-control.is-invalid ~ .invalid-feedback,
.form-select.is-invalid ~ .invalid-feedback {
    display: block;
    color: var(--error-red);
}

.form-control.is-valid ~ .valid-feedback,
.form-select.is-valid ~ .valid-feedback {
    display: block;
    color: var(--primary-green);
}

/* Inline form groups */
.form-inline-group {
    display: flex;
    gap: 0.5rem;
    align-items: end;
}

.form-inline-group .form-row {
    flex: 1;
    margin-bottom: 0;
}

/* Help text */
.form-text {
    font-size: 0.813rem;
    color: var(--grey-600);
    margin-top: 0.25rem;
}

/* ========================================
   FORM LAYOUT OPTIMIZATION
======================================== */

/* Prevent horizontal scrolling in forms */
.form-section .row {
    margin-left: 0;
    margin-right: 0;
}

.form-section .row > [class*='col-'] {
    padding-left: 0.5rem;
    padding-right: 0.5rem;
}

/* Desktop optimization - reduce padding on large screens */
@media (min-width: 992px) {
    .form-section {
        padding: 1.25rem;
    }
    
    .form-row {
        margin-bottom: 1rem;
    }
    
    .card-body {
        padding: 1.25rem;
    }
    
    .content-container {
        max-width: 100%;
        padding: 1.5rem;
    }
}

/* Large desktop optimization */
@media (min-width: 1400px) {
    .content-container {
        padding: 2rem;
    }
    
    .form-section {
        padding: 1.5rem;
    }
}

/* Compact form inputs on desktop */
@media (min-width: 992px) {
    .form-control,
    .form-select {
        padding: 0.625rem 0.875rem;
        font-size: 0.875rem;
    }
    
    .form-label {
        margin-bottom: 0.375rem;
        font-size: 0.813rem;
    }
}

/* Ensure no overflow on smaller columns */
.form-section .col-lg-3,
.form-section .col-md-3,
.form-section .col-md-4,
.form-section .col-md-6 {
    min-width: 0;
}

/* Better spacing for multi-select */
.form-select[multiple] {
    min-height: 120px;
}

@media (min-width: 992px) {
    .form-select[multiple] {
        min-height: 100px;
    }
}

/* ========================================
   TABLE ENHANCEMENTS - SORTABLE HEADERS
======================================== */

/* Sortable table headers */
.table thead th.sortable {
    cursor: pointer;
    user-select: none;
    position: relative;
    padding-right: 2rem;
}

.table thead th.sortable:hover {
    background: var(--grey-100);
}

.table thead th.sortable i {
    position: absolute;
    right: 0.75rem;
    top: 50%;
    transform: translateY(-50%);
    font-size: 0.75rem;
    color: var(--grey-500);
    transition: var(--transition-base);
}

.table thead th.sortable:hover i {
    color: var(--primary-blue);
}

.table thead th.sortable.sorting-asc i::before {
    content: "\F145";
    color: var(--primary-blue);
}

.table thead th.sortable.sorting-desc i::before {
    content: "\F149";
    color: var(--primary-blue);
}
}

/* ========================================
   TOAST NOTIFICATIONS
======================================== */

.toast-container {
    z-index: 9999 !important;
}

.toast {
    min-width: 300px;
    max-width: 400px;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.toast .toast-header {
    border-radius: 8px 8px 0 0;
    padding: 0.75rem 1rem;
}

.toast .toast-body {
    padding: 1rem;
    font-size: 0.938rem;
}

.toast .toast-header.bg-success {
    background-color: var(--primary-green) !important;
}

.toast .toast-header.bg-danger {
    background-color: var(--error-red) !important;
}

/* ========================================
   FORM VALIDATION STYLES
======================================== */

.form-control.is-invalid,
.form-select.is-invalid {
    border-color: var(--error-red) !important;
    box-shadow: 0 0 0 2px rgba(211, 47, 47, 0.1);
}

.invalid-feedback {
    display: none;
    color: var(--error-red);
    font-size: 0.813rem;
    margin-top: 0.25rem;
}

.form-control.is-invalid + .invalid-feedback,
.form-select.is-invalid + .invalid-feedback {
    display: block;
}