/**
 * Church Management System
 * Glassmorphism Light Blue Theme
 * Modern, Professional, Clean
 */

/* =====================================================
   CSS VARIABLES
   ===================================================== */
:root {
    /* Primary Colors */
    --primary-50: #e3f2fd;
    --primary-100: #bbdefb;
    --primary-200: #90caf9;
    --primary-300: #64b5f6;
    --primary-400: #42a5f5;
    --primary-500: #1565c0;
    --primary-600: #1565c0;
    --primary-700: #0d47a1;
    --primary-800: #0a3d8f;
    --primary-900: #072a63;

    /* Neutral Colors */
    --gray-50: #f8fafc;
    --gray-100: #f1f5f9;
    --gray-200: #e2e8f0;
    --gray-300: #cbd5e1;
    --gray-400: #94a3b8;
    --gray-500: #64748b;
    --gray-600: #475569;
    --gray-700: #334155;
    --gray-800: #1e293b;
    --gray-900: #0f172a;

    /* Status Colors */
    --success: #10b981;
    --success-light: #d1fae5;
    --warning: #f59e0b;
    --warning-light: #fef3c7;
    --danger: #ef4444;
    --danger-light: #fee2e2;
    --info: #3b82f6;
    --info-light: #dbeafe;

    /* Background */
    --bg-body: #f0f8ff;
    --bg-card: rgba(255, 255, 255, 0.85);
    --bg-glass: rgba(255, 255, 255, 0.7);
    --bg-sidebar: linear-gradient(180deg, #1565c0 0%, #0d47a1 100%);

    /* Shadows */
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --shadow-md: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    --shadow-lg: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
    --shadow-glass: 0 8px 32px 0 rgba(31, 38, 135, 0.15);

    /* Typography */
    --font-family: 'Inter', 'Segoe UI', system-ui, -apple-system, sans-serif;
    --font-mono: 'JetBrains Mono', 'Fira Code', monospace;

    /* Border Radius */
    --radius-sm: 0.375rem;
    --radius: 0.5rem;
    --radius-md: 0.75rem;
    --radius-lg: 1rem;
    --radius-xl: 1.5rem;
    --radius-full: 9999px;

    /* Transitions */
    --transition: all 0.2s ease-in-out;
    --transition-slow: all 0.3s ease-in-out;
}

/* =====================================================
   BASE STYLES
   ===================================================== */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    scroll-behavior: smooth;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    font-family: var(--font-family);
    font-size: 0.9375rem;
    line-height: 1.6;
    color: var(--gray-700);
    background-color: var(--bg-body);
    min-height: 100vh;
}

/* =====================================================
   TYPOGRAPHY
   ===================================================== */
h1, h2, h3, h4, h5, h6 {
    font-weight: 600;
    color: var(--gray-800);
    line-height: 1.3;
    margin-bottom: 0.5rem;
}

h1 { font-size: 2rem; }
h2 { font-size: 1.75rem; }
h3 { font-size: 1.5rem; }
h4 { font-size: 1.25rem; }
h5 { font-size: 1.125rem; }
h6 { font-size: 1rem; }

p {
    margin-bottom: 1rem;
    color: var(--gray-600);
}

a {
    color: var(--primary-600);
    text-decoration: none;
    transition: var(--transition);
}

a:hover {
    color: var(--primary-700);
}

/* =====================================================
   GLASSMORPHISM CARDS
   ===================================================== */
.card {
    background: var(--bg-card);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-glass);
    transition: var(--transition);
}

.card:hover {
    box-shadow: var(--shadow-lg);
    transform: translateY(-2px);
}

.card-header {
    background: transparent;
    border-bottom: 1px solid rgba(0, 0, 0, 0.05);
    padding: 1.25rem 1.5rem;
}

.card-body {
    padding: 1.5rem;
}

.card-footer {
    background: rgba(0, 0, 0, 0.02);
    border-top: 1px solid rgba(0, 0, 0, 0.05);
    padding: 1rem 1.5rem;
}

.card-title {
    font-size: 1.125rem;
    font-weight: 600;
    color: var(--gray-800);
    margin-bottom: 0;
}

/* Glass Card Variant */
.card-glass {
    background: var(--bg-glass);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.5);
}

/* =====================================================
   BUTTONS
   ===================================================== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.625rem 1.25rem;
    font-size: 0.875rem;
    font-weight: 500;
    line-height: 1.5;
    border-radius: var(--radius);
    border: none;
    cursor: pointer;
    transition: var(--transition);
    text-decoration: none;
}

.btn:focus {
    outline: none;
    box-shadow: 0 0 0 3px rgba(21, 101, 192, 0.3);
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary-500) 0%, var(--primary-700) 100%);
    color: white;
    box-shadow: 0 4px 14px 0 rgba(21, 101, 192, 0.4);
}

.btn-primary:hover {
    background: linear-gradient(135deg, var(--primary-600) 0%, var(--primary-800) 100%);
    transform: translateY(-1px);
    box-shadow: 0 6px 20px 0 rgba(21, 101, 192, 0.5);
    color: white;
}

.btn-secondary {
    background: var(--gray-100);
    color: var(--gray-700);
    border: 1px solid var(--gray-200);
}

.btn-secondary:hover {
    background: var(--gray-200);
    color: var(--gray-800);
}

.btn-success {
    background: linear-gradient(135deg, var(--success) 0%, #059669 100%);
    color: white;
}

.btn-success:hover {
    background: linear-gradient(135deg, #059669 0%, #047857 100%);
    color: white;
}

.btn-danger {
    background: linear-gradient(135deg, var(--danger) 0%, #dc2626 100%);
    color: white;
}

.btn-danger:hover {
    background: linear-gradient(135deg, #dc2626 0%, #b91c1c 100%);
    color: white;
}

.btn-outline-primary {
    background: transparent;
    color: var(--primary-600);
    border: 2px solid var(--primary-600);
}

.btn-outline-primary:hover {
    background: var(--primary-600);
    color: white;
}

.btn-lg {
    padding: 0.875rem 1.75rem;
    font-size: 1rem;
}

.btn-sm {
    padding: 0.375rem 0.875rem;
    font-size: 0.8125rem;
}

.btn-icon {
    width: 2.5rem;
    height: 2.5rem;
    padding: 0;
    border-radius: var(--radius-full);
}

/* =====================================================
   FORMS
   ===================================================== */
.form-label {
    display: block;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--gray-700);
    margin-bottom: 0.5rem;
}

.form-control {
    display: block;
    width: 100%;
    padding: 0.75rem 1rem;
    font-size: 0.9375rem;
    font-family: var(--font-family);
    color: var(--gray-800);
    background: white;
    border: 1px solid var(--gray-200);
    border-radius: var(--radius);
    transition: var(--transition);
}

.form-control:focus {
    outline: none;
    border-color: var(--primary-400);
    box-shadow: 0 0 0 3px rgba(21, 101, 192, 0.15);
}

.form-control::placeholder {
    color: var(--gray-400);
}

.form-control.is-invalid {
    border-color: var(--danger);
}

.form-control.is-valid {
    border-color: var(--success);
}

.invalid-feedback {
    display: block;
    font-size: 0.8125rem;
    color: var(--danger);
    margin-top: 0.25rem;
}

.form-select {
    display: block;
    width: 100%;
    padding: 0.75rem 2.5rem 0.75rem 1rem;
    font-size: 0.9375rem;
    color: var(--gray-800);
    background-color: white;
    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;
    border: 1px solid var(--gray-200);
    border-radius: var(--radius);
    appearance: none;
    transition: var(--transition);
}

.form-select:focus {
    outline: none;
    border-color: var(--primary-400);
    box-shadow: 0 0 0 3px rgba(21, 101, 192, 0.15);
}

.form-check {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
}

.form-check-input {
    width: 1.125rem;
    height: 1.125rem;
    cursor: pointer;
    accent-color: var(--primary-600);
}

.form-check-label {
    font-size: 0.875rem;
    color: var(--gray-700);
    cursor: pointer;
}

/* =====================================================
   TABLES
   ===================================================== */
.table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.875rem;
}

.table th,
.table td {
    padding: 1rem;
    text-align: left;
    border-bottom: 1px solid var(--gray-100);
}

.table th {
    font-weight: 600;
    color: var(--gray-600);
    background: var(--gray-50);
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.table tbody tr {
    transition: var(--transition);
}

.table tbody tr:hover {
    background: rgba(21, 101, 192, 0.04);
}

.table-striped tbody tr:nth-of-type(odd) {
    background: rgba(0, 0, 0, 0.02);
}

/* =====================================================
   BADGES & PILLS
   ===================================================== */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 0.25rem 0.625rem;
    font-size: 0.75rem;
    font-weight: 500;
    border-radius: var(--radius-full);
}

.badge-primary {
    background: var(--primary-100);
    color: var(--primary-700);
}

.badge-success {
    background: var(--success-light);
    color: #059669;
}

.badge-warning {
    background: var(--warning-light);
    color: #d97706;
}

.badge-danger {
    background: var(--danger-light);
    color: #dc2626;
}

.badge-info {
    background: var(--info-light);
    color: #2563eb;
}

.badge-secondary {
    background: #e2e8f0;
    color: #475569;
}

.badge-dark {
    background: #1e293b;
    color: #f8fafc;
}

/* =====================================================
   ALERTS
   ===================================================== */
.alert {
    padding: 1rem 1.25rem;
    border-radius: var(--radius);
    border-left: 4px solid;
    margin-bottom: 1rem;
}

.alert-success {
    background: var(--success-light);
    border-color: var(--success);
    color: #065f46;
}

.alert-danger {
    background: var(--danger-light);
    border-color: var(--danger);
    color: #991b1b;
}

.alert-warning {
    background: var(--warning-light);
    border-color: var(--warning);
    color: #92400e;
}

.alert-info {
    background: var(--info-light);
    border-color: var(--info);
    color: #1e40af;
}

/* =====================================================
   LAYOUT - SIDEBAR
   ===================================================== */
.layout {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    width: 260px;
    background: var(--bg-sidebar);
    color: white;
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 100;
    overflow-y: auto;
    transition: var(--transition-slow);
}

.sidebar-header {
    padding: 1.5rem 1rem 1.25rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    text-align: center;
}

.sidebar-logo {
    display: block;
    color: white;
    text-decoration: none;
}

.sidebar-logo:hover {
    color: rgba(255, 255, 255, 0.85);
}

.sidebar-brand {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.6rem;
}

.sidebar-logo-img {
    width: 64px;
    height: 64px;
    border-radius: 14px;
    overflow: hidden;
    background: rgba(255, 255, 255, 0.12);
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.25);
    border: 2px solid rgba(255, 255, 255, 0.15);
}

.sidebar-logo-img img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    padding: 4px;
}

.sidebar-logo-icon {
    width: 64px;
    height: 64px;
    border-radius: 14px;
    background: rgba(255, 255, 255, 0.12);
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.25);
    border: 2px solid rgba(255, 255, 255, 0.15);
}

.sidebar-logo-icon i {
    font-size: 1.75rem;
    color: rgba(255, 255, 255, 0.9);
}

.sidebar-church-name {
    display: block;
    font-size: 0.72rem;
    font-weight: 600;
    line-height: 1.35;
    letter-spacing: 0.02em;
    color: rgba(255, 255, 255, 0.85);
    word-wrap: break-word;
    overflow-wrap: break-word;
    max-width: 160px;
    text-transform: uppercase;
}

.sidebar-nav {
    padding: 1rem 0;
}

.nav-section {
    padding: 0 1rem;
    margin-bottom: 0.5rem;
}

.nav-section-title {
    font-size: 0.6875rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: rgba(255, 255, 255, 0.5);
    padding: 0.5rem 0.75rem;
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    color: rgba(255, 255, 255, 0.8);
    border-radius: var(--radius);
    margin: 0.125rem 0;
    font-size: 0.875rem;
    transition: var(--transition);
}

.nav-link:hover {
    background: rgba(255, 255, 255, 0.1);
    color: white;
}

.nav-link.active {
    background: rgba(255, 255, 255, 0.2);
    color: white;
    font-weight: 500;
}

.nav-link i {
    width: 1.25rem;
    text-align: center;
    font-size: 1rem;
}

/* =====================================================
   LAYOUT - MAIN CONTENT
   ===================================================== */
.main-content {
    flex: 1;
    margin-left: 260px;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.topbar {
    background: var(--bg-card);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid rgba(0, 0, 0, 0.05);
    padding: 1rem 1.5rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 50;
}

.topbar-left {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.topbar-right {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.page-title {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--gray-800);
    margin: 0;
}

.user-menu {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.5rem 1rem;
    background: var(--gray-50);
    border-radius: var(--radius-full);
    cursor: pointer;
    transition: var(--transition);
}

.user-menu:hover {
    background: var(--gray-100);
}

.user-avatar {
    width: 36px;
    height: 36px;
    border-radius: var(--radius-full);
    background: linear-gradient(135deg, var(--primary-500) 0%, var(--primary-700) 100%);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 0.875rem;
}

.user-info {
    display: flex;
    flex-direction: column;
}

.user-name {
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--gray-800);
}

.user-role {
    font-size: 0.75rem;
    color: var(--gray-500);
    text-transform: capitalize;
}

.content {
    flex: 1;
    padding: 1.5rem;
}

/* =====================================================
   STATS CARDS
   ===================================================== */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 1.5rem;
    margin-bottom: 1.5rem;
}

.stat-card {
    background: var(--bg-card);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    box-shadow: var(--shadow-glass);
    transition: var(--transition);
}

.stat-card:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow-lg);
}

.stat-info h3 {
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--gray-500);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 0.5rem;
}

.stat-value {
    font-size: 1.875rem;
    font-weight: 700;
    color: var(--gray-800);
    line-height: 1;
}

.stat-change {
    font-size: 0.75rem;
    margin-top: 0.5rem;
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

.stat-change.positive {
    color: var(--success);
}

.stat-change.negative {
    color: var(--danger);
}

.stat-icon {
    width: 48px;
    height: 48px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
}

.stat-icon.primary {
    background: rgba(21, 101, 192, 0.1);
    color: var(--primary-600);
}

.stat-icon.success {
    background: rgba(16, 185, 129, 0.1);
    color: var(--success);
}

.stat-icon.warning {
    background: rgba(245, 158, 11, 0.1);
    color: var(--warning);
}

.stat-icon.danger {
    background: rgba(239, 68, 68, 0.1);
    color: var(--danger);
}

/* =====================================================
   UTILITY CLASSES
   ===================================================== */
.text-center { text-align: center; }
.text-right { text-align: right; }
.text-muted { color: var(--gray-500); }
.text-primary { color: var(--primary-600); }
.text-success { color: var(--success); }
.text-danger { color: var(--danger); }
.text-warning { color: var(--warning); }

.fw-light { font-weight: 300; }
.fw-normal { font-weight: 400; }
.fw-medium { font-weight: 500; }
.fw-semibold { font-weight: 600; }
.fw-bold { font-weight: 700; }

.mt-1 { margin-top: 0.25rem; }
.mt-2 { margin-top: 0.5rem; }
.mt-3 { margin-top: 1rem; }
.mt-4 { margin-top: 1.5rem; }
.mt-5 { margin-top: 2rem; }

.mb-1 { margin-bottom: 0.25rem; }
.mb-2 { margin-bottom: 0.5rem; }
.mb-3 { margin-bottom: 1rem; }
.mb-4 { margin-bottom: 1.5rem; }
.mb-5 { margin-bottom: 2rem; }

.me-2 { margin-right: 0.5rem; }
.ms-2 { margin-left: 0.5rem; }

.p-3 { padding: 1rem; }
.p-4 { padding: 1.5rem; }

.d-flex { display: flex; }
.align-items-center { align-items: center; }
.justify-content-between { justify-content: space-between; }
.justify-content-center { justify-content: center; }
.gap-2 { gap: 0.5rem; }
.gap-3 { gap: 1rem; }

.w-100 { width: 100%; }
.h-100 { height: 100%; }

.rounded { border-radius: var(--radius); }
.rounded-lg { border-radius: var(--radius-lg); }
.rounded-full { border-radius: var(--radius-full); }

.shadow { box-shadow: var(--shadow); }
.shadow-lg { box-shadow: var(--shadow-lg); }

.overflow-hidden { overflow: hidden; }
.overflow-auto { overflow: auto; }

/* =====================================================
   TEXT OVERFLOW & WORD BREAK
   ===================================================== */

/* All table cells: break long unbreakable strings (emails, URLs, long words) */
.table td,
.table th {
    overflow-wrap: break-word;
    word-break: break-word;
    max-width: 320px;          /* cap any single column so it can't blow out the layout */
}

/* Text inside cards / list items */
.card p,
.card-body p,
.border-bottom p,
.border-bottom small {
    overflow-wrap: break-word;
    word-break: break-word;
}

/* Inline elements that often carry long values */
td span,
td a,
td strong,
td small {
    display: inline-block;
    overflow-wrap: break-word;
    word-break: break-word;
    max-width: 100%;
}

/* Utility: single-line truncate with ellipsis */
.text-truncate {
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
    max-width: 100%;
    display: block;
}

/* Utility: multi-line clamp helpers */
.line-clamp-1 { display: -webkit-box; -webkit-line-clamp: 1; -webkit-box-orient: vertical; overflow: hidden; }
.line-clamp-2 { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.line-clamp-3 { display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }

/* Notification / prayer-request / pastoral-notes content blocks */
.border-bottom {
    overflow-wrap: break-word;
    word-break: break-word;
}

/* =====================================================
   RESPONSIVE
   ===================================================== */

/* --- Globally scrollable card tables (all screen sizes) --- */
.card-body {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

/* Prevent card hover lift from clipping dropdown menus */
.card:hover {
    overflow: visible;
}

/* Filter/action bars: allow wrapping on narrow viewports */
.filter-bar,
.card-body > form {
    flex-wrap: wrap;
}

/* Notification dropdown: cap width on small screens */
#notifDropdown {
    max-width: calc(100vw - 2rem);
}

/* Tablets and below — matches Bootstrap xl (1200px) so hamburger and sidebar collapse together */
@media (max-width: 1199px) {
    .sidebar {
        transform: translateX(-100%);
    }

    .sidebar.open {
        transform: translateX(0);
        box-shadow: var(--shadow-lg);
    }

    .main-content {
        margin-left: 0;
        width: 100%;
    }

    /* Two-column grids become single column on tablets */
    .stats-grid {
        grid-template-columns: repeat(2, 1fr) !important;
    }

    /* Tables scroll horizontally on tablets */
    .table {
        min-width: 540px;
    }
}

/* Mobile devices (portrait) */
@media (max-width: 768px) {
    /* All grids become single column */
    .stats-grid,
    .card-grid {
        grid-template-columns: 1fr !important;
    }

    /* Collapse ANY inline grid-template-columns layout to single column on mobile */
    div[style*="grid-template-columns"] {
        grid-template-columns: 1fr !important;
    }

    /* Reduce padding on mobile */
    .topbar {
        padding: 0.75rem 1rem;
    }

    .content {
        padding: 1rem;
    }

    .page-title {
        font-size: 1.125rem;
    }

    /* Hide user info text, show only avatar */
    .user-info {
        display: none;
    }

    /* Chevron in user menu — hide on mobile too */
    .user-menu .fa-chevron-down {
        display: none;
    }

    /* Stack form layouts */
    form > div[style*="grid-template-columns"] {
        display: block !important;
    }

    form > div[style*="grid-template-columns"] > div {
        margin-bottom: 1rem;
    }

    /* Form controls with hardcoded inline widths — override to full width */
    .form-control[style*="width"],
    .form-select[style*="width"],
    input[style*="width"],
    select[style*="width"] {
        width: 100% !important;
    }

    /* Filter/action bar: wrap to multiple rows */
    .d-flex.align-items-center,
    .d-flex.gap-2,
    .d-flex.gap-3 {
        flex-wrap: wrap;
    }

    /* Page-level d-flex rows (e.g. justify-content-between) should also wrap */
    .d-flex.justify-content-between {
        flex-wrap: wrap;
        gap: 0.75rem;
    }

    /* ms-auto inside flex-wrap rows: don't push buttons off screen */
    .d-flex.flex-wrap > .ms-auto {
        margin-left: 0 !important;
        width: 100%;
    }

    /* Mobile-friendly buttons */
    .btn {
        padding: 0.5rem 1rem;
        font-size: 0.875rem;
    }

    /* Cards */
    .card {
        border-radius: var(--radius);
    }

    .card-body {
        padding: 1rem;
    }

    .card-header {
        padding: 1rem;
    }

    /* Modal adjustments */
    .modal-dialog {
        margin: 1rem;
        max-width: calc(100% - 2rem);
    }

    /* Tables scroll horizontally */
    .table {
        min-width: 560px;
    }

    /* Notification dropdown */
    #notifDropdown {
        width: calc(100vw - 2rem) !important;
        right: -4rem !important;
    }

    /* User menu dropdown */
    #userMenuDropdown {
        right: 0;
        left: auto;
    }
}

/* 2fr/1fr side-by-side layouts become single column on tablet */
@media (max-width: 900px) {
    .donations-layout,
    div[style*="grid-template-columns: 2fr 1fr"],
    div[style*="grid-template-columns: 1fr 1fr"] {
        grid-template-columns: 1fr !important;
    }
}

/* Small mobile devices */
@media (max-width: 480px) {
    #notifDropdown {
        position: fixed !important;
        left: 10px !important;
        right: 10px !important;
        top: 60px !important;
        width: auto !important;
        max-width: none !important;
    }

    .sidebar {
        width: 85%;
        max-width: 280px;
    }

    .topbar {
        padding: 0.5rem 0.75rem;
    }

    .content {
        padding: 0.75rem;
    }

    .page-title {
        font-size: 1rem;
    }

    h1 { font-size: 1.375rem; }
    h2 { font-size: 1.25rem; }
    h3 { font-size: 1.125rem; }

    /* Smaller buttons */
    .btn {
        padding: 0.5rem 0.875rem;
        font-size: 0.8125rem;
    }

    /* Action button rows: stretch to full width */
    .d-flex.gap-2 > .btn,
    .d-flex.gap-3 > .btn,
    .d-flex.gap-2 > a.btn,
    .d-flex.gap-3 > a.btn {
        flex: 1 1 auto;
        min-width: 0;
    }

    /* Stat value smaller on phones */
    .stat-value {
        font-size: 1.5rem;
    }

    /* Card header flex: stack if needed */
    .card-header.d-flex {
        flex-wrap: wrap;
        gap: 0.5rem;
    }
}

/* Landscape orientation optimizations */
@media (max-height: 600px) and (orientation: landscape) {
    .sidebar-header {
        padding: 1rem;
    }

    .nav-link {
        padding: 0.5rem 1rem;
    }

    .topbar {
        padding: 0.5rem 1rem;
    }
}

/* Print styles */
@media print {
    .sidebar,
    .topbar,
    .btn,
    .nav-link {
        display: none !important;
    }

    .main-content {
        margin-left: 0;
        width: 100%;
    }

    .content {
        padding: 0;
    }

    .card {
        break-inside: avoid;
        box-shadow: none;
        border: 1px solid #ddd;
    }
}

/* =====================================================
   ANIMATIONS
   ===================================================== */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes pulse {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.5;
    }
}

@keyframes spin {
    from {
        transform: rotate(0deg);
    }
    to {
        transform: rotate(360deg);
    }
}

.fade-in {
    animation: fadeIn 0.3s ease-out;
}

.pulse {
    animation: pulse 2s infinite;
}

.spin {
    animation: spin 1s linear infinite;
}

/* =====================================================
   LOADING STATES
   ===================================================== */
.loading {
    position: relative;
    pointer-events: none;
}

.loading::after {
    content: '';
    position: absolute;
    inset: 0;
    background: rgba(255, 255, 255, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
}

.spinner {
    width: 24px;
    height: 24px;
    border: 3px solid var(--gray-200);
    border-top-color: var(--primary-600);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

/* =====================================================
   EMPTY STATES
   ===================================================== */
.empty-state {
    text-align: center;
    padding: 3rem 1.5rem;
}

.empty-state-icon {
    width: 80px;
    height: 80px;
    margin: 0 auto 1.5rem;
    background: var(--gray-100);
    border-radius: var(--radius-full);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2rem;
    color: var(--gray-400);
}

.empty-state h4 {
    margin-bottom: 0.5rem;
}

.empty-state p {
    color: var(--gray-500);
    margin-bottom: 1.5rem;
}
