/* Animal Database UK - Complete Responsive Stylesheet */

/* CSS Variables */
:root {
    --primary-color: #0090e7;
    --primary-dark: #0063cc;
    --success-color: #059669;
    --warning-color: #d97706;
    --danger-color: #dc2626;
    --info-color: #2563eb;
    
    --gray-50: #f8fafc;
    --gray-100: #f1f5f9;
    --gray-200: #e2e8f0;
    --gray-300: #cbd5e0;
    --gray-400: #94a3b8;
    --gray-500: #64748b;
    --gray-600: #475569;
    --gray-700: #334155;
    --gray-800: #1e293b;
    --gray-900: #0f172a;
    
    --text-dark: #1e293b;
    --text-muted: #64748b;
    
    --border-color: #e2e8f0;
    --radius-sm: 0.25rem;
    --radius-md: 0.5rem;
    --radius-lg: 0.75rem;
    --radius-xl: 1rem;
    
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
    --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1);
    
    --transition: all 0.15s ease;
    --transition-slow: all 0.3s ease;
    
    --sidebar-width: 260px;
    --header-height: 64px;
    
    --z-dropdown: 1000;
    --z-sticky: 1020;
    --z-fixed: 1030;
    --z-modal-backdrop: 1040;
    --z-modal: 1050;
    --z-popover: 1060;
    --z-tooltip: 1070;
    --z-toast: 10000;
}

/* Base Styles */
* {
    box-sizing: border-box;
}

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

html {
    font-size: 16px;
    -webkit-text-size-adjust: 100%;
    -ms-text-size-adjust: 100%;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    font-size: 14px;
    line-height: 1.5;
    color: var(--text-dark);
    background-color: var(--gray-50);
    margin: 0;
    padding: 0;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    overflow-x: hidden;
}

/* Typography */
h1, h2, h3, h4, h5, h6 {
    font-weight: 600;
    line-height: 1.25;
    margin: 0 0 1rem 0;
    color: var(--text-dark);
}

h1 { font-size: clamp(1.75rem, 4vw, 2rem); }
h2 { font-size: clamp(1.25rem, 3vw, 1.5rem); }
h3 { font-size: clamp(1.125rem, 2.5vw, 1.25rem); }
h4 { font-size: clamp(1rem, 2vw, 1.125rem); }
h5 { font-size: 1rem; }
h6 { font-size: 0.875rem; }

p {
    margin: 0 0 1rem 0;
    color: var(--text-muted);
}

a {
    color: var(--primary-color);
    text-decoration: none;
    transition: var(--transition);
}

a:hover {
    color: var(--primary-dark);
}

a:focus {
    outline: 2px solid var(--primary-color);
    outline-offset: 2px;
}

/* Layout System - Fixed for all menu types */
.app-layout {
    display: flex;
    min-height: 100vh;
    width: 100%;
    position: relative;
}

/* Universal sidebar/menu styles - handles all possible class/id names */
.app-sidebar,
.sidebar,
.menu-sidebar,
#sidebar,
#menu,
.nav-sidebar,
.side-menu {
    position: fixed;
    left: 0;
    top: 0;
    width: var(--sidebar-width);
    height: 100vh;
    background: white;
    border-right: 1px solid var(--border-color);
    transition: var(--transition-slow);
    overflow-y: auto;
    overflow-x: hidden;
}

/* Desktop - sidebar stays in place, content flows beside it */
@media (min-width: 993px) {
    .app-sidebar,
    .sidebar,
    .menu-sidebar,
    #sidebar,
    #menu,
    .nav-sidebar,
    .side-menu {
        transform: translateX(0);
        z-index: 100; /* Low z-index - sidebar doesn't overlay content on desktop */
    }
}

/* Mobile - sidebar is overlay with high z-index */
@media (max-width: 992px) {
    .app-sidebar,
    .sidebar,
    .menu-sidebar,
    #sidebar,
    #menu,
    .nav-sidebar,
    .side-menu {
        transform: translateX(-100%);
        z-index: var(--z-modal); /* High z-index - sidebar overlays content on mobile */
    }
    
    .app-sidebar.show,
    .sidebar.show,
    .menu-sidebar.show,
    #sidebar.show,
    #menu.show,
    .nav-sidebar.show,
    .side-menu.show,
    .app-sidebar.active,
    .sidebar.active,
    .menu-sidebar.active,
    #sidebar.active,
    #menu.active,
    .nav-sidebar.active,
    .side-menu.active {
        transform: translateX(0);
    }
}

.main-content {
    flex: 1;
    min-height: 100vh;
    background: var(--gray-50);
    width: 100%;
    transition: var(--transition-slow);
    position: relative;
    z-index: 1;
}

/* Desktop - add margin for sidebar */
@media (min-width: 993px) {
    .main-content {
        margin-left: var(--sidebar-width);
        width: calc(100% - var(--sidebar-width));
    }
}

/* Mobile - no margin */
@media (max-width: 992px) {
    .main-content {
        margin-left: 0;
        width: 100%;
    }
}

/* Remove dynamic layout classes - handled by media queries above */

.sidebar-overlay,
.menu-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: calc(var(--z-fixed) - 1);
    opacity: 0;
    visibility: hidden;
    transition: var(--transition-slow);
    display: none;
}

@media (max-width: 992px) {
    .sidebar-overlay,
    .menu-overlay {
        display: block;
    }
}

.sidebar-overlay.show {
    opacity: 1;
    visibility: visible;
}

/* ===== TOAST NOTIFICATION SYSTEM ===== */
.toast-container {
    position: fixed !important;
    top: 20px !important;
    right: 20px !important;
    left: auto !important;
    z-index: var(--z-toast) !important;
    pointer-events: none !important;
    max-width: calc(100vw - 40px);
}

.toast {
    background: white;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    padding: 16px;
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    max-width: 400px;
    width: 100%;
    transform: translateX(100%);
    transition: var(--transition-slow);
    pointer-events: auto;
    border-left: 4px solid var(--success-color);
    opacity: 0;
    visibility: hidden;
}

.toast.show {
    transform: translateX(0) !important;
    opacity: 1 !important;
    visibility: visible !important;
}

.toast i {
    margin-right: 12px;
    font-size: 1.1em;
    flex-shrink: 0;
}

.toast .toast-content {
    flex: 1;
    min-width: 0;
}

.toast .toast-title {
    font-weight: 600;
    margin-bottom: 2px;
    font-size: 14px;
}

.toast .toast-message {
    font-size: 13px;
    color: var(--text-muted);
    word-wrap: break-word;
}

.toast button {
    background: none;
    border: none;
    cursor: pointer;
    margin-left: 12px;
    color: var(--gray-400);
    padding: 4px;
    border-radius: var(--radius-sm);
    font-size: 14px;
    transition: var(--transition);
    flex-shrink: 0;
}

.toast button:hover {
    color: var(--gray-600);
    background: var(--gray-100);
}

.toast.toast-success { border-left-color: var(--success-color); }
.toast.toast-warning { border-left-color: var(--warning-color); }
.toast.toast-error { border-left-color: var(--danger-color); }
.toast.toast-info { border-left-color: var(--info-color); }

/* Form Elements */
.form-group {
    margin-bottom: 1.5rem;
    min-width: 0;
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
    color: var(--text-dark);
    font-size: 0.875rem;
}

.form-control {
    width: 100%;
    max-width: 100%;
    min-width: 0;
    box-sizing: border-box;
    padding: 12px 16px;
    border: 2px solid var(--border-color);
    border-radius: var(--radius-md);
    font-size: 14px;
    font-family: inherit;
    background-color: white;
    color: var(--text-dark);
    transition: var(--transition);
    outline: none;
    line-height: 1.4;
}

.form-control::placeholder {
    color: var(--gray-400);
}

.form-control:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(0, 144, 231, 0.1);
}

.form-control:disabled {
    background-color: var(--gray-100);
    color: var(--text-muted);
    cursor: not-allowed;
    opacity: 0.7;
}

.form-control.is-invalid {
    border-color: var(--danger-color);
}

.form-control.is-valid {
    border-color: var(--success-color);
}

select.form-control {
    cursor: pointer;
    background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 4 5'%3E%3Cpath fill='%2364748b' d='m2 0-2 2h4zm0 5 2-2h-4z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    background-size: 12px;
    padding-right: 40px;
    appearance: none;
}

textarea.form-control {
    resize: vertical;
    min-height: 100px;
    line-height: 1.5;
}

.form-row {
    display: flex;
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.form-col {
    flex: 1;
}

.invalid-feedback {
    display: block;
    width: 100%;
    margin-top: 0.25rem;
    font-size: 0.875rem;
    color: var(--danger-color);
}

.valid-feedback {
    display: block;
    width: 100%;
    margin-top: 0.25rem;
    font-size: 0.875rem;
    color: var(--success-color);
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 12px 24px;
    font-size: 14px;
    font-weight: 500;
    line-height: 1;
    border: none;
    border-radius: var(--radius-md);
    cursor: pointer;
    text-decoration: none;
    transition: var(--transition);
    user-select: none;
    white-space: nowrap;
    position: relative;
    overflow: hidden;
}

.btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    pointer-events: none;
}

.btn:focus {
    outline: 2px solid var(--primary-color);
    outline-offset: 2px;
}

.btn i {
    margin-right: 0.75rem !important; /* Force it */
}

.btn i:only-child {
    margin-right: 0;
}

.btn-xs {
    padding: 4px 8px;
    font-size: 12px;
}

.btn-sm {
    padding: 8px 16px;
    font-size: 13px;
}

.btn-lg {
    padding: 16px 32px;
    font-size: 16px;
}

.btn-xl {
    padding: 20px 40px;
    font-size: 18px;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-dark) 100%);
    color: white;
    box-shadow: 0 4px 6px rgba(0, 144, 231, 0.2);
}

.btn-primary:hover {
    background: linear-gradient(135deg, var(--primary-dark) 0%, #004fb3 100%);
    transform: translateY(-1px);
    box-shadow: 0 6px 8px rgba(0, 144, 231, 0.3);
}

.btn-secondary {
    background: var(--gray-500);
    color: white;
}

.btn-secondary:hover {
    background: var(--gray-600);
}

.btn-success {
    background: var(--success-color);
    color: white;
}

.btn-success:hover {
    background: #047857;
}

.btn-warning {
    background: var(--warning-color);
    color: white;
}

.btn-warning:hover {
    background: #b45309;
}

.btn-danger {
    background: var(--danger-color);
    color: white;
}

.btn-danger:hover {
    background: #b91c1c;
}

.btn-outline {
    background: transparent;
    border: 2px solid var(--border-color);
    color: var(--text-dark);
}

.btn-outline:hover {
    background: var(--gray-50);
    border-color: var(--gray-300);
}

.btn-outline-primary {
    background: transparent;
    border: 2px solid var(--primary-color);
    color: var(--primary-color);
}

.btn-outline-primary:hover {
    background: var(--primary-color);
    color: white;
}

.btn-ghost {
    background: transparent;
    border: none;
    color: var(--text-muted);
}

.btn-ghost:hover {
    background: var(--gray-100);
    color: var(--text-dark);
}

.btn-block {
    width: 100%;
}

.btn-group {
    display: inline-flex;
    border-radius: var(--radius-md);
    overflow: hidden;
}

.btn-group .btn {
    border-radius: 0;
    border-right: 1px solid rgba(255, 255, 255, 0.2);
}

.btn-group .btn:first-child {
    border-radius: var(--radius-md) 0 0 var(--radius-md);
}

.btn-group .btn:last-child {
    border-radius: 0 var(--radius-md) var(--radius-md) 0;
    border-right: none;
}

/* Cards */
.card {
    background: white;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
    transition: var(--transition);
}

.card:hover {
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
}

.card-header {
    padding: 1rem 1.5rem;
    background: var(--gray-50);
    border-bottom: 1px solid var(--border-color);
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.card-body {
    padding: 1.5rem;
}

.card-footer {
    padding: 1rem 1.5rem;
    background: var(--gray-50);
    border-top: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
}

.card-img {
    width: 100%;
    height: 200px;
    object-fit: cover;
}

.card-img-top {
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
}

/* Alerts */
.alert {
    padding: 1rem;
    border-radius: var(--radius-md);
    margin-bottom: 1rem;
    border: 1px solid transparent;
    display: flex;
    align-items: flex-start;
    font-size: 14px;
    gap: 0.75rem;
}

.alert i {
    font-size: 1.1em;
    margin-top: 2px;
    flex-shrink: 0;
}

.alert-content {
    flex: 1;
    min-width: 0;
}

.alert-title {
    font-weight: 600;
    margin-bottom: 0.25rem;
}

.alert-message {
    margin: 0;
}

.alert-success {
    background-color: rgba(5, 150, 105, 0.1);
    border-color: var(--success-color);
    color: #047857;
}

.alert-warning {
    background-color: rgba(217, 119, 6, 0.1);
    border-color: var(--warning-color);
    color: #b45309;
}

.alert-error,
.alert-danger {
    background-color: rgba(220, 38, 38, 0.1);
    border-color: var(--danger-color);
    color: #b91c1c;
}

.alert-info {
    background-color: rgba(37, 99, 235, 0.1);
    border-color: var(--info-color);
    color: #1d4ed8;
}

.alert-dismissible {
    padding-right: 4rem;
    position: relative;
}

.alert-dismiss {
    position: absolute;
    top: 0.5rem;
    right: 0.5rem;
    background: none;
    border: none;
    color: inherit;
    opacity: 0.7;
    cursor: pointer;
    padding: 0.25rem;
    border-radius: var(--radius-sm);
}

.alert-dismiss:hover {
    opacity: 1;
}

/* Tables */
.table-responsive {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.table {
    width: 100%;
    min-width: 600px;
    border-collapse: collapse;
    margin-bottom: 1rem;
    background: white;
    border-radius: var(--radius-md);
    overflow: hidden;
    box-shadow: var(--shadow-sm);
}

.table th,
.table td {
    padding: 0.75rem 1rem;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
    vertical-align: middle;
}

.table th {
    background: var(--gray-50);
    font-weight: 600;
    color: var(--text-dark);
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    white-space: nowrap;
}

.table tbody tr {
    transition: var(--transition);
}

.table tbody tr:hover {
    background: var(--gray-50);
}

.table tbody tr:last-child td {
    border-bottom: none;
}

.table-striped tbody tr:nth-child(odd) {
    background: rgba(248, 250, 252, 0.5);
}

.table-bordered {
    border: 1px solid var(--border-color);
}

.table-bordered th,
.table-bordered td {
    border: 1px solid var(--border-color);
}

.table-sm th,
.table-sm td {
    padding: 0.5rem;
}

/* Modals - STICKY FOOTER & ROUNDED CORNERS */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: var(--z-modal);
    opacity: 0;
    visibility: hidden;
    transition: var(--transition-slow);
    padding: 1rem;
    overflow-y: auto;
    overflow-x: hidden;
}

.modal.show {
    opacity: 1;
    visibility: visible;
}

.modal-dialog {
    background: white;
    border-radius: 16px;
    box-shadow: var(--shadow-xl);
    width: 100%;
    max-width: 650px;
    max-height: calc(100vh - 2rem);
    transform: scale(0.8);
    transition: var(--transition-slow);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.modal.show .modal-dialog {
    transform: scale(1);
}

.modal-dialog-sm { max-width: 300px; }
.modal-dialog-lg { max-width: 800px; }
.modal-dialog-xl { max-width: 1140px; }

.modal-header {
    padding: 1.5rem;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
    background: white;
    position: sticky;
    top: 0;
    z-index: 10;
    border-radius: 16px 16px 0 0;
}

.modal-title {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--text-dark);
    margin: 0;
}

.modal-close {
    background: none;
    border: none;
    font-size: 1.25rem;
    color: var(--text-muted);
    cursor: pointer;
    padding: 0;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-md);
    transition: var(--transition);
}

.modal-close:hover {
    background: var(--gray-100);
    color: var(--text-dark);
}

.modal-body {
    padding: 1.5rem;
    flex: 1 1 auto;
    overflow-y: auto;
    overflow-x: visible;
    position: relative;
    min-height: 0;
}

body.modal-open {
    overflow: hidden;
    padding-right: 0 !important;
}

.modal-footer {
    padding: 1rem 1.5rem;
    border-top: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 1rem;
    flex-shrink: 0;
    background: white;
    position: sticky;
    bottom: 0;
    z-index: 10;
    box-shadow: 0 -4px 12px rgba(0, 0, 0, 0.08);
    border-radius: 0 0 16px 16px;
}

.modal-footer .btn {
    min-width: 120px;
}
/* ===== EMAIL MODAL ENHANCEMENTS ===== */
#emailModal .modal-dialog {
    max-width: 540px;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
    border-radius: 16px;
}

#emailModal .modal-header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-bottom: none;
    padding: 24px 24px 20px 24px;
}

#emailModal .modal-title {
    color: white;
    font-size: 20px;
    font-weight: 700;
}

#emailModal .modal-close {
    color: white;
    opacity: 0.9;
    font-size: 28px;
    width: 36px;
    height: 36px;
    transition: all 0.2s;
}

#emailModal .modal-close:hover {
    opacity: 1;
    transform: rotate(90deg);
    background: rgba(255, 255, 255, 0.2);
}

#emailModal .modal-body {
    padding: 24px;
}

/* Order info box */
#emailModal .modal-body > div:first-child {
    background: linear-gradient(135deg, #dbeafe 0%, #bfdbfe 100%);
    border: 2px solid #3b82f6;
    border-radius: 12px;
    padding: 20px;
    margin-bottom: 28px;
    box-shadow: 0 4px 6px -1px rgba(59, 130, 246, 0.1);
}

#emailModal .modal-body > div:first-child > div:first-child {
    font-weight: 700;
    color: #1e3a8a;
    font-size: 15px;
    margin-bottom: 8px;
}

#emailModal .modal-body > div:first-child > div:last-child {
    color: #1e40af;
    font-size: 14px;
}

/* Section title */
#emailModal h6 {
    font-weight: 700;
    font-size: 14px;
    color: var(--gray-700);
    margin-bottom: 16px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Enhanced checkbox labels */
#emailModal label {
    display: flex;
    align-items: flex-start;
    gap: 14px;
    padding: 16px 18px;
    background: white;
    border: 2px solid #e5e7eb;
    border-radius: 12px;
    margin-bottom: 12px;
    cursor: pointer;
    transition: all 0.2s;
    box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.05);
}

#emailModal label:hover {
    background: #fafafa;
    border-color: #d1d5db;
    transform: translateY(-1px);
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
}

#emailModal label:has(input:checked) {
    background: linear-gradient(135deg, #ecfdf5 0%, #d1fae5 100%);
    border-color: #10b981;
    box-shadow: 0 4px 6px -1px rgba(16, 185, 129, 0.2);
}

#emailModal input[type="checkbox"] {
    width: 20px;
    height: 20px;
    min-width: 20px;
    margin-top: 2px;
    cursor: pointer;
    accent-color: #10b981;
}

#emailModal label > div {
    flex: 1;
}

#emailModal label > div > div:first-child {
    font-weight: 600;
    color: #1f2937;
    font-size: 15px;
    margin-bottom: 4px;
    display: flex;
    align-items: center;
    gap: 8px;
}

#emailModal label > div > div:last-child {
    font-size: 13px;
    color: #6b7280;
    line-height: 1.5;
}

/* Icon styling in labels */
#emailModal label i {
    font-size: 18px;
}

/* Gift notification */
#gift_email_option label {
    background: linear-gradient(135deg, #ecfdf5 0%, #d1fae5 100%);
    border: 2px solid #34d399;
}

#gift_email_option label:hover {
    border-color: #10b981;
    transform: translateY(-1px);
}

#gift_email_option label > div > div:first-child {
    color: #065f46;
}

#gift_recipients {
    font-size: 12px;
    color: #065f46;
    margin-top: 10px;
    padding: 10px 14px;
    background: rgba(255, 255, 255, 0.6);
    border-radius: 8px;
    border: 1px solid rgba(16, 185, 129, 0.2);
}

/* Warning box */
#emailModal .modal-body > div:last-child {
    background: linear-gradient(135deg, #fffbeb 0%, #fef3c7 100%);
    border: 2px solid #fbbf24;
    border-left: 4px solid #f59e0b;
    border-radius: 12px;
    padding: 16px 18px;
    font-size: 13px;
    color: #78350f;
    display: flex;
    align-items: flex-start;
    gap: 12px;
    margin-top: 24px;
    box-shadow: 0 1px 3px 0 rgba(251, 191, 36, 0.1);
}

#emailModal .modal-body > div:last-child i {
    font-size: 16px;
    color: #f59e0b;
    margin-top: 2px;
}

#emailModal .modal-footer {
    background: #f9fafb;
    padding: 16px 24px;
    border-top: 1px solid #e5e7eb;
}

#emailModal .modal-footer .btn {
    padding: 12px 24px;
    font-weight: 600;
    font-size: 14px;
}

/* Icon colors */
#emailModal .fa-certificate { color: #3b82f6; }
#emailModal .fa-file-alt { color: #10b981; }
#emailModal .fa-file-pdf { color: #ef4444; }
#emailModal .fa-gift { color: #10b981; }
#emailModal .fa-info-circle { color: #f59e0b; }

/* Mobile */
@media (max-width: 640px) {
    #emailModal .modal-dialog {
        max-width: 100%;
        margin: 0;
        border-radius: 16px 16px 0 0;
        max-height: 95vh;
    }
    
    #emailModal .modal-header {
        padding: 20px;
    }
    
    #emailModal .modal-body {
        padding: 20px;
    }
    
    #emailModal label {
        padding: 14px 16px;
    }
}
/* Dashboard Styles */
.dashboard-content {
    padding: 24px;
    max-width: 1400px;
    margin: 0 auto;
    width: 100%;
}

.page-header {
    margin-bottom: 32px;
}

.welcome-title {
    font-size: clamp(24px, 4vw, 28px);
    font-weight: 700;
    color: var(--gray-900);
    margin: 0 0 8px 0;
}

.welcome-subtitle {
    color: var(--text-muted);
    font-size: clamp(14px, 2vw, 16px);
    margin: 0 0 12px 0;
}

/* (Old .breadcrumb rules removed — superseded by the canonical block at
   the bottom of this file. Kept this comment so anyone searching for
   .breadcrumb sees the migration note.) */

/* Stats Grid */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 20px;
    margin-bottom: 32px;
}

.stat-card {
    background: white;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 24px;
    transition: var(--transition);
    position: relative;
}

.stat-card:hover {
    border-color: var(--gray-300);
    box-shadow: var(--shadow-md);
}

.stat-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
}

.stat-icon {
    width: 40px;
    height: 40px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    color: white;
    flex-shrink: 0;
}

.stat-trend {
    font-size: 12px;
    font-weight: 500;
    padding: 2px 6px;
    border-radius: var(--radius-sm);
}

.stat-trend.up {
    background: #dcfce7;
    color: #166534;
}

.stat-trend.down {
    background: #fef2f2;
    color: #991b1b;
}

.stat-trend.stable {
    background: var(--gray-100);
    color: var(--gray-600);
}

.stat-value {
    font-size: clamp(24px, 6vw, 32px);
    font-weight: 700;
    color: var(--gray-900);
    margin-bottom: 4px;
    line-height: 1;
}

.stat-label {
    color: var(--text-muted);
    font-weight: 500;
    font-size: 14px;
}

.stat-meta {
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid var(--gray-100);
    font-size: 12px;
    color: var(--gray-400);
}

/* Action Cards */
.actions-section {
    margin-bottom: 32px;
}

.section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
    flex-wrap: wrap;
    gap: 1rem;
}

.section-title {
    font-size: 18px;
    font-weight: 600;
    color: var(--gray-900);
    margin: 0;

}

.actions-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 16px;
}

.action-card {
    background: white;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 20px;
    text-decoration: none;
    color: inherit;
    transition: var(--transition);
    display: flex;
    align-items: center;
    gap: 16px;
}

.action-card:hover {
    border-color: var(--primary-color);
    box-shadow: var(--shadow-md);
    text-decoration: none;
    color: inherit;
    transform: translateY(-1px);
}

.action-card:focus {
    outline: 2px solid var(--primary-color);
    outline-offset: 2px;
}

.action-icon {
    width: 48px;
    height: 48px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    color: white;
    flex-shrink: 0;
}

.action-content {
    flex: 1;
    min-width: 0;
}

.action-content h3 {
    font-weight: 600;
    color: var(--gray-900);
    margin: 0 0 4px 0;
    font-size: 16px;
}

.action-content p {
    color: var(--text-muted);
    font-size: 14px;
    margin: 0;
    line-height: 1.4;
}

/* Status Colors */
.status-success { background: var(--success-color); }
.status-warning { background: var(--warning-color); }
.status-danger { background: var(--danger-color); }
.status-info { background: var(--info-color); }
.status-secondary { background: var(--gray-500); }
.status-primary { background: #7c3aed; }

/* Loading States */
.loading {
    position: relative;
    overflow: hidden;
}

.loading::after {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.4), transparent);
    animation: loading 1.5s infinite;
}

@keyframes loading {
    0% { left: -100%; }
    100% { left: 100%; }
}

.spinner {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 2px solid #f3f3f3;
    border-top: 2px solid var(--primary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

/* Utility Classes */
.text-left { text-align: left; }
.text-center { text-align: center; }
.text-right { text-align: right; }
.text-justify { text-align: justify; }

.text-muted { color: var(--text-muted); }
.text-primary { color: var(--primary-color); }
.text-success { color: var(--success-color); }
.text-warning { color: var(--warning-color); }
.text-danger { color: var(--danger-color); }
.text-info { color: var(--info-color); }

.font-weight-light { font-weight: 300; }
.font-weight-normal { font-weight: 400; }
.font-weight-medium { font-weight: 500; }
.font-weight-semibold { font-weight: 600; }
.font-weight-bold { font-weight: 700; }

.font-size-xs { font-size: 12px; }
.font-size-sm { font-size: 14px; }
.font-size-base { font-size: 16px; }
.font-size-lg { font-size: 18px; }
.font-size-xl { font-size: 20px; }

.d-none { display: none; }
.d-inline { display: inline; }
.d-inline-block { display: inline-block; }
.d-block { display: block; }
.d-flex { display: flex; }
.d-inline-flex { display: inline-flex; }
.d-grid { display: grid; }

.flex-column { flex-direction: column; }
.flex-row { flex-direction: row; }
.flex-wrap { flex-wrap: wrap; }
.flex-nowrap { flex-wrap: nowrap; }

.justify-content-start { justify-content: flex-start; }
.justify-content-end { justify-content: flex-end; }
.justify-content-center { justify-content: center; }
.justify-content-between { justify-content: space-between; }
.justify-content-around { justify-content: space-around; }
.justify-content-evenly { justify-content: space-evenly; }

.align-items-start { align-items: flex-start; }
.align-items-end { align-items: flex-end; }
.align-items-center { align-items: center; }
.align-items-baseline { align-items: baseline; }
.align-items-stretch { align-items: stretch; }

.align-self-start { align-self: flex-start; }
.align-self-end { align-self: flex-end; }
.align-self-center { align-self: center; }
.align-self-baseline { align-self: baseline; }
.align-self-stretch { align-self: stretch; }

.flex-fill { flex: 1 1 auto; }
.flex-grow-0 { flex-grow: 0; }
.flex-grow-1 { flex-grow: 1; }
.flex-shrink-0 { flex-shrink: 0; }
.flex-shrink-1 { flex-shrink: 1; }

.w-25 { width: 25%; }
.w-50 { width: 50%; }
.w-75 { width: 75%; }
.w-100 { width: 100%; }
.w-auto { width: auto; }

.h-25 { height: 25%; }
.h-50 { height: 50%; }
.h-75 { height: 75%; }
.h-100 { height: 100%; }
.h-auto { height: auto; }

.mw-100 { max-width: 100%; }
.mh-100 { max-height: 100%; }

.position-static { position: static; }
.position-relative { position: relative; }
.position-absolute { position: absolute; }
.position-fixed { position: fixed; }
.position-sticky { position: sticky; }

.overflow-auto { overflow: auto; }
.overflow-hidden { overflow: hidden; }
.overflow-visible { overflow: visible; }
.overflow-scroll { overflow: scroll; }

/* Spacing Utilities */
.m-0 { margin: 0; }
.m-1 { margin: 0.25rem; }
.m-2 { margin: 0.5rem; }
.m-3 { margin: 1rem; }
.m-4 { margin: 1.5rem; }
.m-5 { margin: 3rem; }
.m-auto { margin: auto; }

.mx-0 { margin-left: 0; margin-right: 0; }
.mx-1 { margin-left: 0.25rem; margin-right: 0.25rem; }
.mx-2 { margin-left: 0.5rem; margin-right: 0.5rem; }
.mx-3 { margin-left: 1rem; margin-right: 1rem; }
.mx-4 { margin-left: 1.5rem; margin-right: 1.5rem; }
.mx-5 { margin-left: 3rem; margin-right: 3rem; }
.mx-auto { margin-left: auto; margin-right: auto; }

.my-0 { margin-top: 0; margin-bottom: 0; }
.my-1 { margin-top: 0.25rem; margin-bottom: 0.25rem; }
.my-2 { margin-top: 0.5rem; margin-bottom: 0.5rem; }
.my-3 { margin-top: 1rem; margin-bottom: 1rem; }
.my-4 { margin-top: 1.5rem; margin-bottom: 1.5rem; }
.my-5 { margin-top: 3rem; margin-bottom: 3rem; }
.my-auto { margin-top: auto; margin-bottom: auto; }

.mt-0 { margin-top: 0; }
.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: 3rem; }
.mt-auto { margin-top: auto; }

.mb-0 { margin-bottom: 0; }
.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: 3rem; }
.mb-auto { margin-bottom: auto; }

.ml-0 { margin-left: 0; }
.ml-1 { margin-left: 0.25rem; }
.ml-2 { margin-left: 0.5rem; }
.ml-3 { margin-left: 1rem; }
.ml-4 { margin-left: 1.5rem; }
.ml-5 { margin-left: 3rem; }
.ml-auto { margin-left: auto; }

.mr-0 { margin-right: 0; }
.mr-1 { margin-right: 0.25rem; }
.mr-2 { margin-right: 0.5rem; }
.mr-3 { margin-right: 1rem; }
.mr-4 { margin-right: 1.5rem; }
.mr-5 { margin-right: 3rem; }
.mr-auto { margin-right: auto; }

.p-0 { padding: 0; }
.p-1 { padding: 0.25rem; }
.p-2 { padding: 0.5rem; }
.p-3 { padding: 1rem; }
.p-4 { padding: 1.5rem; }
.p-5 { padding: 3rem; }

.px-0 { padding-left: 0; padding-right: 0; }
.px-1 { padding-left: 0.25rem; padding-right: 0.25rem; }
.px-2 { padding-left: 0.5rem; padding-right: 0.5rem; }
.px-3 { padding-left: 1rem; padding-right: 1rem; }
.px-4 { padding-left: 1.5rem; padding-right: 1.5rem; }
.px-5 { padding-left: 3rem; padding-right: 3rem; }

.py-0 { padding-top: 0; padding-bottom: 0; }
.py-1 { padding-top: 0.25rem; padding-bottom: 0.25rem; }
.py-2 { padding-top: 0.5rem; padding-bottom: 0.5rem; }
.py-3 { padding-top: 1rem; padding-bottom: 1rem; }
.py-4 { padding-top: 1.5rem; padding-bottom: 1.5rem; }
.py-5 { padding-top: 3rem; padding-bottom: 3rem; }

.pt-0 { padding-top: 0; }
.pt-1 { padding-top: 0.25rem; }
.pt-2 { padding-top: 0.5rem; }
.pt-3 { padding-top: 1rem; }
.pt-4 { padding-top: 1.5rem; }
.pt-5 { padding-top: 3rem; }

.pb-0 { padding-bottom: 0; }
.pb-1 { padding-bottom: 0.25rem; }
.pb-2 { padding-bottom: 0.5rem; }
.pb-3 { padding-bottom: 1rem; }
.pb-4 { padding-bottom: 1.5rem; }
.pb-5 { padding-bottom: 3rem; }

.pl-0 { padding-left: 0; }
.pl-1 { padding-left: 0.25rem; }
.pl-2 { padding-left: 0.5rem; }
.pl-3 { padding-left: 1rem; }
.pl-4 { padding-left: 1.5rem; }
.pl-5 { padding-left: 3rem; }

.pr-0 { padding-right: 0; }
.pr-1 { padding-right: 0.25rem; }
.pr-2 { padding-right: 0.5rem; }
.pr-3 { padding-right: 1rem; }
.pr-4 { padding-right: 1.5rem; }
.pr-5 { padding-right: 3rem; }

/* Border Utilities */
.border { border: 1px solid var(--border-color); }
.border-0 { border: 0; }
.border-top { border-top: 1px solid var(--border-color); }
.border-right { border-right: 1px solid var(--border-color); }
.border-bottom { border-bottom: 1px solid var(--border-color); }
.border-left { border-left: 1px solid var(--border-color); }

.border-primary { border-color: var(--primary-color); }
.border-secondary { border-color: var(--gray-500); }
.border-success { border-color: var(--success-color); }
.border-warning { border-color: var(--warning-color); }
.border-danger { border-color: var(--danger-color); }
.border-info { border-color: var(--info-color); }

.rounded { border-radius: var(--radius-md); }
.rounded-sm { border-radius: var(--radius-sm); }
.rounded-lg { border-radius: var(--radius-lg); }
.rounded-xl { border-radius: var(--radius-xl); }
.rounded-circle { border-radius: 50%; }
.rounded-0 { border-radius: 0; }

/* Shadow Utilities */
.shadow-none { box-shadow: none; }
.shadow-sm { box-shadow: var(--shadow-sm); }
.shadow { box-shadow: var(--shadow-md); }
.shadow-lg { box-shadow: var(--shadow-lg); }
.shadow-xl { box-shadow: var(--shadow-xl); }

/* Background Utilities */
.bg-primary { background-color: var(--primary-color); }
.bg-secondary { background-color: var(--gray-500); }
.bg-success { background-color: var(--success-color); }
.bg-warning { background-color: var(--warning-color); }
.bg-danger { background-color: var(--danger-color); }
.bg-info { background-color: var(--info-color); }
.bg-light { background-color: var(--gray-100); }
.bg-dark { background-color: var(--gray-800); }
.bg-white { background-color: white; }
.bg-transparent { background-color: transparent; }

/* Responsive Utilities */
@media (max-width: 576px) {
    .d-xs-none { display: none; }
    .d-xs-inline { display: inline; }
    .d-xs-inline-block { display: inline-block; }
    .d-xs-block { display: block; }
    .d-xs-flex { display: flex; }
    .d-xs-inline-flex { display: inline-flex; }
    
    .flex-xs-column { flex-direction: column; }
    .flex-xs-row { flex-direction: row; }
    
    .text-xs-left { text-align: left; }
    .text-xs-center { text-align: center; }
    .text-xs-right { text-align: right; }
}

@media (min-width: 576px) and (max-width: 768px) {
    .d-sm-none { display: none; }
    .d-sm-inline { display: inline; }
    .d-sm-inline-block { display: inline-block; }
    .d-sm-block { display: block; }
    .d-sm-flex { display: flex; }
    .d-sm-inline-flex { display: inline-flex; }
    
    .flex-sm-column { flex-direction: column; }
    .flex-sm-row { flex-direction: row; }
    
    .text-sm-left { text-align: left; }
    .text-sm-center { text-align: center; }
    .text-sm-right { text-align: right; }
}

@media (min-width: 768px) and (max-width: 992px) {
    .d-md-none { display: none; }
    .d-md-inline { display: inline; }
    .d-md-inline-block { display: inline-block; }
    .d-md-block { display: block; }
    .d-md-flex { display: flex; }
    .d-md-inline-flex { display: inline-flex; }
    
    .flex-md-column { flex-direction: column; }
    .flex-md-row { flex-direction: row; }
    
    .text-md-left { text-align: left; }
    .text-md-center { text-align: center; }
    .text-md-right { text-align: right; }
}

@media (min-width: 992px) and (max-width: 1200px) {
    .d-lg-none { display: none; }
    .d-lg-inline { display: inline; }
    .d-lg-inline-block { display: inline-block; }
    .d-lg-block { display: block; }
    .d-lg-flex { display: flex; }
    .d-lg-inline-flex { display: inline-flex; }
    
    .flex-lg-column { flex-direction: column; }
    .flex-lg-row { flex-direction: row; }
    
    .text-lg-left { text-align: left; }
    .text-lg-center { text-align: center; }
    .text-lg-right { text-align: right; }
}

@media (min-width: 1200px) {
    .d-xl-none { display: none; }
    .d-xl-inline { display: inline; }
    .d-xl-inline-block { display: inline-block; }
    .d-xl-block { display: block; }
    .d-xl-flex { display: flex; }
    .d-xl-inline-flex { display: inline-flex; }
    
    .flex-xl-column { flex-direction: column; }
    .flex-xl-row { flex-direction: row; }
    
    .text-xl-left { text-align: left; }
    .text-xl-center { text-align: center; }
    .text-xl-right { text-align: right; }
}

/* Mobile Responsive Breakpoints */
@media (max-width: 992px) {
    :root {
        --sidebar-width: 280px;
    }
    
    /* Ensure proper stacking order on mobile */
    .app-sidebar,
    .sidebar,
    .menu-sidebar,
    #sidebar,
    #menu,
    .nav-sidebar,
    .side-menu {
        z-index: var(--z-modal);
    }
    
    .dashboard-content {
        padding: 16px;
    }
    
    .stats-grid {
        grid-template-columns: 1fr;
        gap: 16px;
    }
    
    .actions-grid {
        grid-template-columns: 1fr;
        gap: 12px;
    }
    
    .form-row {
        flex-direction: column;
        gap: 0;
    }
    
    .modal {
        padding: 0.5rem;
    }
    
    .modal-dialog {
        max-height: calc(100vh - 1rem);
    }
    
    .btn {
        padding: 10px 20px;
    }
    
    .btn-sm {
        padding: 8px 16px;
    }
    
    .btn-lg {
        padding: 14px 28px;
    }
    
    .table th,
    .table td {
        padding: 0.5rem 0.75rem;
    }
    
    .card-body {
        padding: 1rem;
    }
    
    .card-header,
    .card-footer {
        padding: 0.75rem 1rem;
    }
    
    .toast-container {
        top: 10px !important;
        right: 10px !important;
        left: 10px !important;
        max-width: calc(100vw - 20px);
    }
    
    .toast {
        max-width: 100%;
    }
}

@media (max-width: 576px) {
    .dashboard-content {
        padding: 12px;
    }
    
    .welcome-title {
        font-size: 20px;
    }
    
    .welcome-subtitle {
        font-size: 14px;
    }
    
    .stats-grid {
        gap: 12px;
        margin-bottom: 24px;
    }
    
    .stat-card {
        padding: 16px;
    }
    
    .stat-value {
        font-size: 24px;
    }
    
    .actions-grid {
        gap: 8px;
    }
    
    .action-card {
        padding: 16px;
        flex-direction: column;
        text-align: center;
        gap: 12px;
    }
    
    .section-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.5rem;
    }
    
    .breadcrumb {
        font-size: 12px;
    }
    
    .modal-header,
    .modal-body,
    .modal-footer {
        padding: 1rem;
    }
    
    .btn-group {
        flex-direction: column;
    }
    
    .btn-group .btn {
        border-radius: var(--radius-md);
        border-right: none;
        border-bottom: 1px solid rgba(255, 255, 255, 0.2);
    }
    
    .btn-group .btn:last-child {
        border-bottom: none;
    }
}

/* Print Styles */
@media print {
    .app-sidebar,
    .toast-container,
    .modal,
    .sidebar-overlay {
        display: none !important;
    }
    
    .main-content {
        margin-left: 0 !important;
    }
    
    .dashboard-content {
        padding: 0;
    }
    
    .card {
        box-shadow: none;
        border: 1px solid #ddd;
    }
    
    .btn {
        display: none;
    }
    
    .page-header {
        margin-bottom: 1rem;
    }
}

/* High Contrast Mode */
@media (prefers-contrast: high) {
    :root {
        --border-color: #000;
        --text-muted: #333;
        --gray-100: #f0f0f0;
        --gray-200: #e0e0e0;
    }
    
    .card {
        border: 2px solid var(--border-color);
    }
    
    .btn {
        border: 2px solid currentColor;
    }
    
    .form-control {
        border: 2px solid var(--border-color);
    }
}

/* Reduced Motion */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
    
    .loading::after {
        animation: none;
    }
    
    .spinner {
        animation: none;
        border-top-color: transparent;
    }
}

/* Focus Visible Support */
@supports selector(:focus-visible) {
    .btn:focus {
        outline: none;
    }
    
    .btn:focus-visible {
        outline: 2px solid var(--primary-color);
        outline-offset: 2px;
    }
    
    .form-control:focus {
        outline: none;
    }
    
    .form-control:focus-visible {
        outline: 2px solid var(--primary-color);
        outline-offset: 2px;
    }
}

/* Scroll Behavior */
html {
    scroll-behavior: smooth;
}

/* Custom Scrollbar */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: var(--gray-100);
}

::-webkit-scrollbar-thumb {
    background: var(--gray-300);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--gray-400);
}

/* Selection */
::selection {
    background: rgba(0, 144, 231, 0.2);
    color: var(--text-dark);
}

/* Global fixes for menu/content positioning issues */
.dashboard-content,
.content-wrapper,
.page-content,
.container,
.container-fluid,
main,
section,
article {
    position: relative;
    z-index: 1;
}

/* Ensure dropdowns appear above everything */
.dropdown-menu,
.dropdown,
.form-control-dropdown,
[role="listbox"],
[role="menu"],
.select-dropdown,
.autocomplete-dropdown {
    position: absolute;
    z-index: var(--z-dropdown) !important;
}

/* Dropdowns inside modals need higher z-index */
.modal .dropdown-menu,
.modal .dropdown,
.modal .form-control-dropdown,
.modal [role="listbox"],
.modal [role="menu"],
.modal .select-dropdown,
.modal .autocomplete-dropdown,
.modal .category-dropdown,
.modal .animal-dropdown,
.modal .multiselect-dropdown,
.modal .custom-multiselect.open {
    position: absolute;
    z-index: 99999 !important;
}

/* Ensure custom multiselect has proper stacking */
.custom-multiselect.open {
    position: relative;
    z-index: 99999 !important;
}

/* Fix for any content appearing behind menu */
.card,
.table-responsive,
.form-group,
.settings-section,
.tab-content {
    position: relative;
    z-index: 1;
}

/* Mobile menu toggle button (if missing) */
.menu-toggle,
.sidebar-toggle {
    position: fixed;
    top: 20px;
    left: 20px;
    z-index: calc(var(--z-modal) + 1);
    background: var(--primary-color);
    color: white;
    border: none;
    padding: 10px 15px;
    border-radius: var(--radius-md);
    cursor: pointer;
    display: none;
}

@media (max-width: 992px) {
    .menu-toggle,
    .sidebar-toggle {
        display: block;
    }
}

/* Ensure proper layering */
* {
    -webkit-backface-visibility: hidden;
    backface-visibility: hidden;
}

/* Fix for 1280px displays and similar resolutions */
@media (min-width: 993px) and (max-width: 1366px) {
    .main-content {
        z-index: 2 !important;
    }
    
    .app-sidebar,
    .sidebar,
    .menu-sidebar,
    #sidebar,
    #menu,
    .nav-sidebar,
    .side-menu {
        z-index: 1031 !important;
    }
    
    .dashboard-content,
    .content-wrapper,
    .page-content {
        transform: translateZ(0);
        will-change: transform;
    }
}

/* ===== FORM HELPER TEXT & VALIDATION ===== */
/* Helper text styling */
.form-text {
    display: block;
    margin-top: 0.25rem;
    font-size: 0.875rem;
    color: var(--text-muted);
    line-height: 1.4;
}

.form-text i {
    margin-right: 4px;
    opacity: 0.8;
}

/* Better form validation styling */
.form-control:invalid:not(:placeholder-shown) {
    border-color: var(--danger-color);
    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='%23dc3545'%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='%23dc3545' stroke='none'/%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: right calc(.375em + .1875rem) center;
    background-size: calc(.75em + .375rem) calc(.75em + .375rem);
    padding-right: calc(1.5em + .75rem);
}

.form-control:valid:not(:placeholder-shown) {
    border-color: var(--success-color);
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 8 8'%3e%3cpath fill='%23059669' 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(.375em + .1875rem) center;
    background-size: calc(.75em + .375rem) calc(.75em + .375rem);
    padding-right: calc(1.5em + .75rem);
}

/* Loading spinner for forms */
.btn.loading {
    position: relative;
    color: transparent !important;
    pointer-events: none;
}

.btn.loading::after {
    content: "";
    position: absolute;
    width: 16px;
    height: 16px;
    top: 50%;
    left: 50%;
    margin-left: -8px;
    margin-top: -8px;
    border: 2px solid transparent;
    border-top-color: currentColor;
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}

/* Field error messages */
.field-error {
    color: var(--danger-color);
    font-size: 13px;
    margin-top: 4px;
    display: block;
    animation: slideDown 0.2s ease;
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-4px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Autofill styling override */
input:-webkit-autofill,
input:-webkit-autofill:hover,
input:-webkit-autofill:focus,
select:-webkit-autofill,
select:-webkit-autofill:hover,
select:-webkit-autofill:focus,
textarea:-webkit-autofill,
textarea:-webkit-autofill:hover,
textarea:-webkit-autofill:focus {
    -webkit-text-fill-color: var(--text-dark);
    -webkit-box-shadow: 0 0 0 1000px white inset;
    transition: background-color 5000s ease-in-out 0s;
    border-color: var(--primary-color);
}

/* Required field indicator */
.form-group label.required::after {
    content: " *";
    color: var(--danger-color);
    font-weight: 600;
}

/* Checkbox and radio improvements */
input[type="checkbox"],
input[type="radio"] {
    width: 18px;
    height: 18px;
    cursor: pointer;
    accent-color: var(--primary-color);
}

/* Input group styling */
.input-group {
    display: flex;
    align-items: stretch;
    width: 100%;
}

.input-group .form-control {
    flex: 1;
    min-width: 0;
}

.input-group .form-control:not(:last-child) {
    border-top-right-radius: 0;
    border-bottom-right-radius: 0;
}

.input-group .form-control:not(:first-child) {
    border-top-left-radius: 0;
    border-bottom-left-radius: 0;
}

.input-group-text {
    display: flex;
    align-items: center;
    padding: 12px 16px;
    font-size: 14px;
    font-weight: 500;
    line-height: 1.4;
    color: var(--text-muted);
    text-align: center;
    white-space: nowrap;
    background-color: var(--gray-100);
    border: 2px solid var(--border-color);
}

.input-group-text:first-child {
    border-top-left-radius: var(--radius-md);
    border-bottom-left-radius: var(--radius-md);
    border-right: none;
}

.input-group-text:last-child {
    border-top-right-radius: var(--radius-md);
    border-bottom-right-radius: var(--radius-md);
    border-left: none;
}

/* iOS Safari auto-zooms any focused input whose font-size is below 16px.
   Force 16px on form controls at mobile widths to suppress that zoom.
   !important is required to beat the inline font-size rules used on
   many existing inputs across the codebase. */
@media (max-width: 768px) {
    input[type="text"],
    input[type="search"],
    input[type="email"],
    input[type="password"],
    input[type="tel"],
    input[type="url"],
    input[type="number"],
    input[type="date"],
    input[type="datetime-local"],
    input[type="time"],
    input[type="month"],
    input[type="week"],
    select,
    textarea {
        font-size: 16px !important;
    }
}

/* iOS Safari renders <input type="date"> with a built-in min-width tied to
   its native picker chrome (calendar icon + placeholder text). That intrinsic
   width survives `width: 100%` and `box-sizing: border-box` because Safari
   treats it as the user-agent default min-width — only resetting
   -webkit-appearance and explicit min-width:0 unlocks shrinking.
   We also force display:block so the input behaves predictably inside flex
   and grid containers (where its intrinsic min-content was previously
   determining the column width). */
input[type="date"],
input[type="datetime-local"],
input[type="time"],
input[type="month"],
input[type="week"] {
    -webkit-appearance: none !important;
    -moz-appearance: none !important;
    appearance: none !important;
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;
    box-sizing: border-box !important;
    display: block !important;
    /* Without appearance:none, iOS Safari sized empty date inputs from their
       internal placeholder chrome. Stripped of that, an empty input collapses
       to ~0 line-height. Force the same min-height other form-controls render
       at (font-size 16px * line-height 1.4 = ~22px content + the input's own
       padding) so the empty state matches text inputs visually. */
    line-height: 1.4 !important;
    min-height: calc(1.4em + 24px) !important;
}
/* Restore the calendar picker indicator that -webkit-appearance: none hides
   on iOS Safari. Without this, users would see no calendar icon on mobile. */
input[type="date"]::-webkit-calendar-picker-indicator,
input[type="datetime-local"]::-webkit-calendar-picker-indicator,
input[type="time"]::-webkit-calendar-picker-indicator,
input[type="month"]::-webkit-calendar-picker-indicator,
input[type="week"]::-webkit-calendar-picker-indicator {
    opacity: 0.6;
    cursor: pointer;
}
/* ============================================================
   Canonical breadcrumb — used by renderBreadcrumb() helper
   in includes/common_functions.php. All pages should call the
   helper rather than rendering breadcrumb HTML inline.
   ============================================================ */
.breadcrumb {
    display: flex !important;
    flex-wrap: wrap !important;
    align-items: center !important;
    gap: 10px !important;
    margin: 0 0 24px 0 !important;
    padding: 14px 18px !important;
    background: linear-gradient(135deg, #ffffff 0%, #f1f5f9 100%) !important;
    border: 1px solid #e2e8f0 !important;
    border-radius: 12px !important;
    box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04), 0 2px 6px rgba(15, 23, 42, 0.03) !important;
    font-size: 14px !important;
    line-height: 1.5 !important;
    list-style: none !important;
    color: #475569 !important;
}
.breadcrumb a {
    color: #2563eb !important;
    text-decoration: none !important;
    font-weight: 600 !important;
    transition: color 0.15s ease, background 0.15s ease !important;
    display: inline-flex !important;
    align-items: center !important;
    gap: 4px !important;
    padding: 2px 4px !important;
    border-radius: 4px !important;
}
.breadcrumb a:hover {
    color: #1d4ed8 !important;
    background: rgba(37, 99, 235, 0.08) !important;
    text-decoration: none !important;
}
/* Back-arrow icon prepended to the first link (the parent module).
   A small affordance so users instantly see "tap here to go back"
   without Font Awesome dependency. */
.breadcrumb > a:first-child::before {
    content: "←";
    margin-right: 4px;
    font-weight: 700;
    color: #2563eb;
    font-size: 16px;
    line-height: 1;
}
.breadcrumb .breadcrumb-sep {
    color: #94a3b8 !important;
    user-select: none !important;
    font-weight: 700 !important;
    font-size: 14px !important;
    margin: 0 2px !important;
}
.breadcrumb .breadcrumb-current {
    color: #0f172a !important;
    font-weight: 700 !important;
    padding: 2px 4px !important;
}
/* For pages where the breadcrumb is the ONLY child (a single label,
   e.g. on a top-level menu item like Medication Inventory) — collapse
   the back-arrow since there's nothing to go back to. */
.breadcrumb .breadcrumb-current:only-child {
    color: #0f172a !important;
    font-size: 16px !important;
}
@media (max-width: 640px) {
    .breadcrumb {
        font-size: 13px !important;
        padding: 12px 14px !important;
        gap: 8px !important;
        margin-bottom: 18px !important;
        border-radius: 10px !important;
    }
    .breadcrumb .breadcrumb-sep { font-size: 13px !important; }
    .breadcrumb > a:first-child::before { font-size: 14px !important; }
}

/* =============================================================
   Canonical modal pattern — see CLAUDE.md "Modals".
   Two class-name conventions are supported (the rota pages use
   .modal-backdrop / .modal-card / etc; older pages use
   .modal-overlay / .modal-box / etc). Both resolve to the same
   look here so every modal across the site gets the same visual
   without per-page CSS.

   Public token-gated pages (hr/rota/respond.php,
   hr/rota/request_time_off.php, vacancies/vacancies_accept.php)
   intentionally don't load this file — they ship their own
   minimal inline copy of these rules for fast load on slow
   mobile / no-cookie contexts.
   ============================================================= */

.modal-backdrop, .modal-overlay {
    position: fixed; inset: 0;
    background: rgba(15,23,42,0.55);
    display: none; align-items: center; justify-content: center;
    z-index: 1000; padding: 20px;
    backdrop-filter: blur(2px);
    -webkit-backdrop-filter: blur(2px);
}
.modal-backdrop.show, .modal-overlay.show { display: flex; }

.modal-card, .modal-box {
    background: #fff;
    border-radius: 14px;
    width: 100%; max-width: 480px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.3);
    display: flex; flex-direction: column;
    max-height: 90vh;
    margin: auto;
    animation: modalIn 0.2s ease-out;
}
@keyframes modalIn {
    from { opacity: 0; transform: translateY(16px) scale(0.97); }
    to   { opacity: 1; transform: none; }
}

.modal-head, .modal-hdr {
    padding: 18px 22px;
    background: linear-gradient(135deg, #6366f1, #4f46e5);
    color: #fff;
    border-radius: 14px 14px 0 0;
    flex: 0 0 auto;
    display: flex; align-items: center; gap: 10px;
}
.modal-head h3, .modal-hdr h3 {
    margin: 0; font-size: 16px; font-weight: 700; color: #fff; flex: 1;
}
/* Old .modal-close X button — keep working if a page still has one,
   but per CLAUDE.md the canonical convention is no X (Cancel in the
   footer is the only dismiss). Don't add new ones. */
.modal-close {
    background: rgba(255,255,255,0.2); border: 0; color: #fff;
    width: 30px; height: 30px; border-radius: 7px; cursor: pointer;
    font-size: 14px;
    display: flex; align-items: center; justify-content: center;
}
.modal-close:hover { background: rgba(255,255,255,0.3); }

.modal-body {
    padding: 20px 22px;
    overflow-y: auto;
    flex: 1 1 auto; min-height: 0;
}

.modal-foot, .modal-ftr {
    padding: 14px 22px;
    border-top: 1px solid #f1f5f9;
    display: flex; gap: 8px; justify-content: flex-end;
    flex: 0 0 auto;
    background: #fff;
    border-radius: 0 0 14px 14px;
}
.modal-foot .btn-secondary, .modal-foot .btn-primary,
.modal-ftr .btn-secondary, .modal-ftr .btn-primary,
.modal-foot .btn-ghost, .modal-ftr .btn-ghost {
    min-height: 44px;
}

/* Mobile sheet — auto-sized, centred, rounded card on dim backdrop.
   See CLAUDE.md "Modals → Sheet-style on mobile" for the rationale. */
@media (max-width: 768px) {
    .modal-backdrop, .modal-overlay {
        padding: max(24px, env(safe-area-inset-top))
                 max(14px, env(safe-area-inset-right))
                 max(24px, env(safe-area-inset-bottom))
                 max(14px, env(safe-area-inset-left));
        align-items: center; justify-content: center;
        overflow: hidden;
    }
    .modal-card, .modal-box {
        max-width: 100% !important; width: 100% !important;
        border-radius: 18px !important;
        height: auto !important;
        max-height: 100% !important;
        margin: 0 !important; min-height: 0;
        box-shadow: 0 24px 60px rgba(15,23,42,0.35);
    }
    .modal-card > .modal-head, .modal-box > .modal-hdr {
        padding: 18px 22px;
        border-radius: 18px 18px 0 0;
    }
    /* Force flex chain through any wrapping <form> so the body can
       actually scroll. Without this, <form>'s default display:block
       breaks the chain. */
    .modal-card > form, .modal-box > form {
        display: flex !important; flex-direction: column !important;
        flex: 1 1 auto !important; min-height: 0; margin: 0;
    }
    .modal-card > form > .modal-body, .modal-card > .modal-body,
    .modal-box  > form > .modal-body, .modal-box  > .modal-body {
        flex: 1 1 auto !important; min-height: 0 !important;
        overflow-y: auto !important; max-height: none !important;
        padding: 20px 20px;
        display: flex; flex-direction: column;
        justify-content: safe center;
    }
    .modal-body > * { flex-shrink: 0; }
    .modal-card > form > .modal-foot, .modal-card > .modal-foot,
    .modal-box  > form > .modal-ftr,  .modal-box  > .modal-ftr {
        background: #fff; border-top: 1px solid #e5e7eb;
        padding: 14px 18px;
        box-shadow: 0 -4px 16px rgba(0,0,0,0.04);
        border-radius: 0 0 18px 18px;
    }
    .modal-foot .btn-secondary, .modal-foot .btn-primary, .modal-foot .btn-ghost,
    .modal-ftr  .btn-secondary, .modal-ftr  .btn-primary, .modal-ftr  .btn-ghost {
        flex: 1; justify-content: center;
    }
}

/* =============================================================
   Multi-entry form pattern — see CLAUDE.md "Multi-entry forms".
   Used for "add another date range / shift / etc" forms inside
   modals. Reference: hr/rota/my_rota.php (modal),
   hr/rota/respond.php + hr/rota/request_time_off.php (page).
   ============================================================= */

.tof-entry {
    background: #f8fafc;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    padding: 14px;
    margin-bottom: 10px;
    position: relative;
}
.tof-entry .entry-num {
    position: absolute; top: -9px; left: 14px;
    background: #fff; color: #6366f1;
    font-size: 11px; font-weight: 700;
    padding: 2px 9px; border-radius: 999px;
    border: 1px solid #e2e8f0;
    text-transform: uppercase; letter-spacing: 0.5px;
}
.tof-entry .entry-remove {
    position: absolute; top: -12px; right: 12px;
    background: #fff; color: #ef4444;
    border: 1px solid #fecaca;
    width: 28px; height: 28px; border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    cursor: pointer; font-size: 11px;
    touch-action: manipulation;
    box-shadow: 0 2px 4px rgba(239,68,68,0.15);
}
.tof-entry .entry-remove:hover { background: #fef2f2; }

.add-another {
    display: inline-flex; align-items: center; gap: 8px;
    padding: 10px 16px; border-radius: 10px;
    background: #fff; border: 1px dashed #6366f1; color: #4338ca;
    font-size: 13px; font-weight: 600;
    cursor: pointer; min-height: 44px; margin-top: 4px;
    touch-action: manipulation;
    -webkit-tap-highlight-color: rgba(99,102,241,0.15);
}
.add-another:hover { background: #eef2ff; }

/* Side-by-side date pair (used in entries + standalone forms) */
.date-row {
    display: flex; gap: 10px; margin-bottom: 6px;
}
.date-row > div { flex: 1; min-width: 0; }

/* =============================================================
   Bootstrap-class modal aliases
   Pages using .modal / .modal-dialog / .modal-header / .modal-body
   / .modal-footer (the older Bootstrap-ish convention) inherit the
   same canonical look from the rules above. Add the .modal name
   to the backdrop selector and aliases for dialog/header/footer.
   ============================================================= */
.modal {
    position: fixed; inset: 0;
    background: rgba(15,23,42,0.55);
    display: none; align-items: center; justify-content: center;
    z-index: 1000; padding: 20px;
    backdrop-filter: blur(2px); -webkit-backdrop-filter: blur(2px);
}
.modal.show, .modal[style*="display: block"], .modal[style*="display:block"] { display: flex; }
.modal-dialog {
    background: #fff;
    border-radius: 14px;
    width: 100%; max-width: 480px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.3);
    display: flex; flex-direction: column;
    max-height: 90vh;
    margin: auto;
    animation: modalIn 0.2s ease-out;
}
.modal-header {
    padding: 18px 22px;
    background: linear-gradient(135deg, #6366f1, #4f46e5);
    color: #fff;
    border-radius: 14px 14px 0 0;
    flex: 0 0 auto;
    display: flex; align-items: center; gap: 10px;
    border-bottom: 0;
}
.modal-header .modal-title, .modal-header h2, .modal-header h3 {
    margin: 0; font-size: 16px; font-weight: 700; color: #fff; flex: 1;
}
.modal-footer {
    padding: 14px 22px;
    border-top: 1px solid #f1f5f9;
    display: flex; gap: 8px; justify-content: flex-end;
    flex: 0 0 auto;
    background: #fff;
    border-radius: 0 0 14px 14px;
}
.modal-footer .btn-secondary, .modal-footer .btn-primary,
.modal-footer .btn-success, .modal-footer .btn-danger,
.modal-footer .btn-ghost {
    min-height: 44px;
}

@media (max-width: 768px) {
    .modal {
        padding: max(24px, env(safe-area-inset-top))
                 max(14px, env(safe-area-inset-right))
                 max(24px, env(safe-area-inset-bottom))
                 max(14px, env(safe-area-inset-left));
        align-items: center; justify-content: center;
        overflow: hidden;
    }
    .modal-dialog {
        max-width: 100% !important; width: 100% !important;
        border-radius: 18px !important;
        height: auto !important;
        max-height: 100% !important;
        margin: 0 !important; min-height: 0;
        box-shadow: 0 24px 60px rgba(15,23,42,0.35);
    }
    .modal-dialog > .modal-header {
        padding: 18px 22px;
        border-radius: 18px 18px 0 0;
    }
    .modal-dialog > form {
        display: flex !important; flex-direction: column !important;
        flex: 1 1 auto !important; min-height: 0; margin: 0;
    }
    .modal-dialog > form > .modal-body, .modal-dialog > .modal-body {
        flex: 1 1 auto !important; min-height: 0 !important;
        overflow-y: auto !important; max-height: none !important;
        padding: 20px 20px;
        display: flex; flex-direction: column;
        justify-content: safe center;
    }
    .modal-dialog > form > .modal-footer, .modal-dialog > .modal-footer {
        background: #fff; border-top: 1px solid #e5e7eb;
        padding: 14px 18px;
        box-shadow: 0 -4px 16px rgba(0,0,0,0.04);
        border-radius: 0 0 18px 18px;
    }
    .modal-footer .btn-secondary, .modal-footer .btn-primary,
    .modal-footer .btn-success, .modal-footer .btn-danger,
    .modal-footer .btn-ghost {
        flex: 1; justify-content: center;
    }
}
