/* ================================================
   UI/UX Enhancements - Dr Khan Therapy
   Professional Polish & Refinement
   Version: 2.0
   ================================================ */

/* ================================================
   ENHANCED CSS VARIABLES
   ================================================ */
:root {
    /* Gradient Variants */
    --gradient-primary: linear-gradient(135deg, #2d5a8f 0%, #3498db 100%);
    --gradient-success: linear-gradient(135deg, #27ae60 0%, #2ecc71 100%);
    --gradient-danger: linear-gradient(135deg, #e74c3c 0%, #c0392b 100%);
    --gradient-warning: linear-gradient(135deg, #f39c12 0%, #f1c40f 100%);
    --gradient-info: linear-gradient(135deg, #3498db 0%, #5dade2 100%);

    /* Shadow Variants */
    --shadow-primary: 0 4px 12px rgba(45, 90, 143, 0.2);
    --shadow-success: 0 4px 12px rgba(39, 174, 96, 0.2);
    --shadow-danger: 0 4px 12px rgba(231, 76, 60, 0.2);
    --shadow-hover: 0 8px 16px rgba(0, 0, 0, 0.15);

    /* Typography Weights */
    --font-weight-light: 300;
    --font-weight-normal: 400;
    --font-weight-medium: 500;
    --font-weight-semibold: 600;
    --font-weight-bold: 700;
}

/* ================================================
   GLOBAL LOADING SPINNER
   ================================================ */
#globalLoader {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(255, 255, 255, 0.95);
    z-index: 99999;
    backdrop-filter: blur(8px);
}

#globalLoader .spinner-container {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    text-align: center;
}

.spinner {
    width: 60px;
    height: 60px;
    border: 4px solid #f3f3f3;
    border-top: 4px solid #3498db;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 1rem;
}

@keyframes spin {
    0% {
        transform: rotate(0deg);
    }

    100% {
        transform: rotate(360deg);
    }
}

/* ================================================
   ENHANCED BUTTONS
   ================================================ */
.btn {
    position: relative;
    overflow: hidden;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.btn::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.3);
    transform: translate(-50%, -50%);
    transition: width 0.6s, height 0.6s;
}

.btn:hover::before {
    width: 300px;
    height: 300px;
}

.btn:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-hover);
}

.btn:active {
    transform: translateY(0);
}

.btn-loading {
    pointer-events: none;
    opacity: 0.7;
}

.btn-loading::after {
    content: '';
    position: absolute;
    width: 16px;
    height: 16px;
    top: 50%;
    left: 50%;
    margin-left: -8px;
    margin-top: -8px;
    border: 2px solid #ffffff;
    border-radius: 50%;
    border-top-color: transparent;
    animation: spin 0.6s linear infinite;
}

/* ================================================
   ENHANCED STATUS BADGES
   ================================================ */
.status-badge,
.badge {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.4rem 0.8rem;
    border-radius: 20px;
    font-weight: 600;
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    transition: all 0.3s ease;
}

.status-arrived,
.badge-success {
    background: var(--gradient-success);
    color: white;
    box-shadow: var(--shadow-success);
}

.status-scheduled,
.badge-info {
    background: var(--gradient-info);
    color: white;
    box-shadow: var(--shadow-primary);
}

.status-cancelled,
.badge-danger {
    background: var(--gradient-danger);
    color: white;
    box-shadow: var(--shadow-danger);
}

.status-pending,
.badge-warning {
    background: var(--gradient-warning);
    color: white;
    box-shadow: 0 2px 8px rgba(243, 156, 18, 0.3);
}

.badge:hover {
    transform: scale(1.05);
}

/* Unpaid Fee Badge with Pulse */
.unpaid-fee-badge {
    background: var(--gradient-danger);
    color: white;
    padding: 0.4rem 0.8rem;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1px;
    box-shadow: var(--shadow-danger);
    animation: pulse 2s infinite;
}

@keyframes pulse {

    0%,
    100% {
        opacity: 1;
        transform: scale(1);
    }

    50% {
        opacity: 0.8;
        transform: scale(1.05);
    }
}

/* ================================================
   ENHANCED TABLES
   ================================================ */
tbody tr {
    transition: all 0.2s ease;
    border-left: 4px solid transparent;
}

tbody tr:hover {
    background-color: #f8f9fa;
    border-left-color: #3498db;
    transform: scale(1.005);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

/* Unpaid Fee Row Highlighting */
.unpaid-fee-row {
    background: linear-gradient(90deg, #fff5f5 0%, #ffffff 100%) !important;
    border-left: 4px solid #e74c3c !important;
}

.unpaid-fee-row:hover {
    background: linear-gradient(90deg, #ffebeb 0%, #fff5f5 100%) !important;
}

/* ================================================
   ENHANCED CARDS
   ================================================ */
.card {
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.card:hover {
    transform: translateY(-4px);
    box-shadow: 0 12px 24px rgba(0, 0, 0, 0.1);
}

/* Stat Cards with Animation */
.stat-card {
    position: relative;
    overflow: hidden;
    transition: all 0.3s ease;
}

.stat-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent);
    transition: left 0.5s;
}

.stat-card:hover::before {
    left: 100%;
}

.stat-card:hover {
    transform: translateY(-8px) scale(1.02);
    box-shadow: 0 12px 24px rgba(0, 0, 0, 0.15);
}

.stat-card-value {
    animation: countUp 1s ease-out;
}

@keyframes countUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ================================================
   ENHANCED MODALS
   ================================================ */
.modal-overlay,
[id$="Modal"][style*="display: block"] {
    backdrop-filter: blur(8px);
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

.modal-content,
[id$="Modal"]>div:first-child {
    animation: slideUp 0.3s ease;
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Enhanced Modal Close Button (The X button) */
.modal-close-btn,
.modal-x-close {
    background: #f8f9fa;
    border: none;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    color: #6c757d;
    transition: all 0.2s ease;
}

.modal-close-btn:hover {
    background: #e74c3c;
    color: white;
    transform: rotate(90deg);
}

/* ================================================
   ENHANCED FORMS
   ================================================ */
.form-control {
    transition: all 0.3s ease;
}

.form-control:focus {
    border-color: #3498db;
    box-shadow: 0 0 0 4px rgba(52, 152, 219, 0.1);
    transform: scale(1.01);
}

.form-control.error {
    border-color: #e74c3c;
    background: #fff5f5;
    animation: shake 0.3s;
}

.form-control.success {
    border-color: #27ae60;
    background: #f0fff4;
}

@keyframes shake {

    0%,
    100% {
        transform: translateX(0);
    }

    25% {
        transform: translateX(-10px);
    }

    75% {
        transform: translateX(10px);
    }
}

.error-message {
    color: #e74c3c;
    font-size: 0.85rem;
    margin-top: 0.5rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    animation: slideDown 0.3s ease;
}

.error-message::before {
    content: '⚠';
    font-size: 1rem;
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ================================================
   ENHANCED AUTOCOMPLETE
   ================================================ */
.patient-autocomplete-dropdown,
.autocomplete-suggestions {
    animation: slideDown 0.2s ease;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15);
}

.autocomplete-item {
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 1rem;
}

.autocomplete-item::before {
    content: '👤';
    font-size: 1.5rem;
    opacity: 0.5;
}

.autocomplete-item:hover,
.autocomplete-item.selected {
    background: linear-gradient(90deg, #f8f9fa 0%, #e8f4f8 100%);
    border-left: 4px solid #3498db;
    padding-left: calc(1rem - 4px);
}

/* ================================================
   ENHANCED ALERTS
   ================================================ */
.alert {
    border-radius: 12px;
    animation: slideDown 0.3s ease;
}

.alert-success {
    background: linear-gradient(135deg, #d4edda 0%, #c3e6cb 100%);
    border-left: 4px solid #27ae60;
}

.alert-danger {
    background: linear-gradient(135deg, #f8d7da 0%, #f5c6cb 100%);
    border-left: 4px solid #e74c3c;
}

.alert-warning {
    background: linear-gradient(135deg, #fff3cd 0%, #ffeaa7 100%);
    border-left: 4px solid #f39c12;
}

.alert-info {
    background: linear-gradient(135deg, #d1ecf1 0%, #bee5eb 100%);
    border-left: 4px solid #3498db;
}

/* ================================================
   ENHANCED EMPTY STATES
   ================================================ */
.empty-state {
    text-align: center;
    padding: 4rem 2rem;
    background: linear-gradient(135deg, #f8f9fa 0%, #ffffff 100%);
    border-radius: 16px;
    animation: fadeIn 0.5s ease;
}

.empty-state i {
    font-size: 5rem;
    margin-bottom: 1.5rem;
    opacity: 0.3;
    animation: float 3s ease-in-out infinite;
}

@keyframes float {

    0%,
    100% {
        transform: translateY(0px);
    }

    50% {
        transform: translateY(-10px);
    }
}

/* ================================================
   ACCESSIBILITY ENHANCEMENTS
   ================================================ */
*:focus {
    outline: 3px solid #3498db;
    outline-offset: 2px;
}

.btn:focus,
.form-control:focus {
    outline: 3px solid #3498db;
    outline-offset: 2px;
}

/* Skip to main content */
.skip-to-main {
    position: absolute;
    top: -40px;
    left: 0;
    background: #2d5a8f;
    color: white;
    padding: 8px;
    text-decoration: none;
    z-index: 100;
}

.skip-to-main:focus {
    top: 0;
}

/* ================================================
   ACTION BUTTON IMPROVEMENTS
   ================================================ */
.action-btn-container {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
    justify-content: flex-start;
}

.action-btn {
    white-space: nowrap;
    font-size: 0.85rem;
    padding: 0.4rem 0.8rem;
    border-radius: 6px;
    transition: all 0.2s ease;
}

.action-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

/* ================================================
   MOBILE ENHANCEMENTS
   ================================================ */
@media (max-width: 768px) {

    /* Better touch targets */
    .btn,
    .action-btn {
        min-height: 44px;
        padding: 0.6rem 1rem;
    }

    /* Full-width buttons on mobile */
    .action-btn-container {
        flex-direction: column;
    }

    .action-btn {
        width: 100%;
        justify-content: center;
    }

    /* Better modal sizing */
    .modal-content,
    [id$="Modal"]>div:first-child {
        max-width: 95%;
        margin: 1rem auto;
    }

    /* Larger form inputs */
    .form-control {
        font-size: 16px;
        /* Prevents zoom on iOS */
        padding: 0.75rem;
    }
}

/* ================================================
   SKELETON LOADING SCREENS
   ================================================ */
.skeleton {
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: loading 1.5s infinite;
    border-radius: 8px;
}

@keyframes loading {
    0% {
        background-position: 200% 0;
    }

    100% {
        background-position: -200% 0;
    }
}

.skeleton-text {
    height: 16px;
    margin-bottom: 8px;
}

.skeleton-card {
    height: 200px;
    margin-bottom: 16px;
}

/* ================================================
   PAGE TRANSITION
   ================================================ */
body {
    animation: pageLoad 0.5s ease;
}

@keyframes pageLoad {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

/* ================================================
   UTILITY CLASSES
   ================================================ */
.fade-in {
    animation: fadeIn 0.5s ease;
}

.slide-up {
    animation: slideUp 0.3s ease;
}

.slide-down {
    animation: slideDown 0.3s ease;
}

.bounce-in {
    animation: bounceIn 0.6s ease;
}

@keyframes bounceIn {
    0% {
        opacity: 0;
        transform: scale(0.9);
    }

    50% {
        opacity: 1;
        transform: scale(1.05);
    }

    100% {
        opacity: 1;
        transform: scale(1);
    }
}

/* ================================================
   PRINT OPTIMIZATIONS
   ================================================ */
@media print {

    .navbar,
    .action-btn,
    .btn,
    button,
    .mobile-sidebar,
    .sidebar-overlay {
        display: none !important;
    }

    .card {
        box-shadow: none;
        border: 1px solid #ddd;
    }

    body {
        background: white;
    }
}