html {
    font-size: 14px;
    position: relative;
    min-height: 100%;
}

@media (min-width: 768px) {
    html { font-size: 16px; }
}

body {
    margin: 0;
    overflow-x: hidden;
    background-color: #f8f9fa;
}

/* Sidebar */
.sidebar {
    width: 250px;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    transition: margin-left 0.3s;
}

.sidebar-link {
    border-radius: 8px;
    padding: 10px 15px;
    margin: 2px 0;
    transition: background-color 0.2s;
}

.sidebar-link:hover,
.sidebar-link.active {
    background-color: rgba(255, 255, 255, 0.15);
}

/* Mobile sidebar */
@media (max-width: 991.98px) {
    .sidebar {
        position: fixed;
        z-index: 1050;
        margin-left: -250px;
    }
    .sidebar.show {
        margin-left: 0;
    }
    .sidebar-overlay {
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        background: rgba(0, 0, 0, 0.5);
        z-index: 1040;
        display: none;
    }
    .sidebar-overlay.show {
        display: block;
    }
}

@media (min-width: 992px) {
    .sidebar { display: flex !important; }
}

/* Cards */
.card {
    border-radius: 12px;
    border: none;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    margin-bottom: 1rem;
}

.card-header {
    border-radius: 12px 12px 0 0 !important;
    padding: 1rem 1.25rem;
    border-bottom: 1px solid rgba(0, 0, 0, 0.05);
}

/* Quick date and stat cards */
.quick-date-card, .stat-card {
    transition: all 0.2s;
    border-radius: 10px;
}

.quick-date-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.15);
}

.quick-date-card .card-body {
    padding: 0.75rem 0.5rem;
}

.stat-card {
    cursor: default;
}

.quick-date-card i, .stat-card i {
    font-size: 1.25rem;
}

.stat-card h5 {
    font-size: 1.5rem;
    font-weight: 700;
}

/* Quick badge on cards */
.quick-badge {
    position: absolute;
    top: 4px;
    right: 4px;
    background-color: #dc3545;
    color: white;
    border-radius: 10px;
    padding: 2px 6px;
    font-size: 0.65rem;
    font-weight: 700;
    min-width: 18px;
    text-align: center;
}

.appointment-card {
    transition: transform 0.15s, box-shadow 0.15s;
    border-radius: 10px;
}

.appointment-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.12);
}

/* Attachment items */
.attachment-item {
    position: relative;
}

.attachment-item .btn {
    min-width: 100px;
    min-height: 100px;
    transition: all 0.2s;
}

.attachment-item .btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

@media (max-width: 768px) {
    .card-body {
        padding: 0.875rem;
    }

    .card-header {
        padding: 0.875rem 1rem;
    }

    .card-header h6 {
        font-size: 0.95rem;
    }

    .quick-date-card .card-body, .stat-card .card-body {
        padding: 0.5rem 0.35rem;
    }

    .quick-date-card i, .stat-card i {
        font-size: 1rem;
    }

    .stat-card h5 {
        font-size: 1.25rem;
    }

    .quick-date-card small, .stat-card small {
        font-size: 0.7rem;
    }

    .appointment-card {
        margin-bottom: 0.65rem;
    }

    .appointment-card .card-body {
        padding: 0.75rem !important;
    }
}

/* Timeline */
.timeline {
    position: relative;
    padding: 10px 0;
}

.timeline-item {
    display: flex;
    padding: 10px 15px;
    position: relative;
}

.timeline-item:not(:last-child)::before {
    content: '';
    position: absolute;
    left: 25px;
    top: 30px;
    bottom: -10px;
    width: 2px;
    background: #dee2e6;
}

.timeline-marker {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    margin-top: 5px;
    margin-right: 15px;
    flex-shrink: 0;
}

.timeline-content {
    flex-grow: 1;
    min-width: 0;
}

/* FullCalendar tweaks */
.fc {
    font-size: 0.95rem;
}

.fc .fc-toolbar {
    flex-wrap: wrap;
    gap: 0.5rem;
}

.fc .fc-toolbar-title {
    font-size: 1.25rem;
    font-weight: 600;
}

.fc .fc-button-primary {
    background-color: #0d6efd;
    border-color: #0d6efd;
    padding: 0.4rem 0.8rem;
    font-size: 0.9rem;
}

.fc .fc-button-primary:hover {
    background-color: #0b5ed7;
    border-color: #0a58ca;
}

.fc .fc-daygrid-day {
    cursor: pointer;
    transition: background-color 0.2s;
}

.fc .fc-daygrid-day:hover {
    background-color: rgba(13, 110, 253, 0.08);
}

.fc .fc-daygrid-day-number {
    padding: 0.5rem;
    font-weight: 500;
}

/* Day cell styling */
.fc .fc-day-today-custom {
    background-color: rgba(255, 193, 7, 0.15) !important;
}

.fc .fc-day-weekend .fc-daygrid-day-number {
    color: #dc3545;
    font-weight: 600;
}

.fc .fc-day-past {
    background-color: rgba(0, 0, 0, 0.02);
}

/* Event styling */
.fc .fc-event {
    border-radius: 4px;
    padding: 2px 5px;
    font-size: 0.8rem;
    margin-bottom: 2px;
    cursor: pointer;
}

.fc .fc-daygrid-event {
    white-space: normal;
}

/* Event colors based on time */
.fc .fc-event-past {
    background-color: #6c757d !important;
    border-color: #6c757d !important;
}

.fc .fc-event-today {
    background-color: #ffc107 !important;
    border-color: #ffc107 !important;
    color: #000 !important;
}

.fc .fc-event-future {
    background-color: #28a745 !important;
    border-color: #28a745 !important;
}

.fc .fc-daygrid-more-link {
    font-weight: 600;
    font-size: 0.85rem;
}

@media (max-width: 768px) {
    .fc .fc-toolbar {
        font-size: 0.85rem;
    }

    .fc .fc-toolbar-title {
        font-size: 1rem;
    }

    .fc .fc-button {
        padding: 0.3rem 0.6rem;
        font-size: 0.8rem;
    }

    .fc .fc-daygrid-day-number {
        font-size: 0.85rem;
        padding: 0.35rem;
    }

    .fc .fc-col-header-cell {
        font-size: 0.8rem;
    }

    /* Mobile: Hide individual events completely */
    .fc .fc-daygrid-day-events {
        display: none !important;
    }

    .fc .fc-daygrid-event-harness {
        display: none !important;
    }

    .fc .fc-daygrid-day-bottom {
        display: none !important;
    }

    /* Custom event count badge */
    .custom-event-badge {
        position: absolute;
        bottom: 2px;
        left: 50%;
        transform: translateX(-50%);
        display: inline-flex;
        align-items: center;
        justify-content: center;
        border-radius: 10px;
        padding: 2px 8px;
        font-size: 0.7rem;
        font-weight: 700;
        min-width: 22px;
        height: 16px;
        color: white;
        cursor: pointer;
        z-index: 10;
    }

    .custom-event-badge.more-past {
        background-color: #6c757d;
    }

    .custom-event-badge.more-today {
        background-color: #ffc107;
        color: #000;
    }

    .custom-event-badge.more-future {
        background-color: #28a745;
    }

    .fc .fc-daygrid-day-frame {
        position: relative;
        min-height: 50px;
    }
}

@media (max-width: 576px) {
    .fc .fc-toolbar {
        flex-direction: column;
        align-items: stretch !important;
    }

    .fc .fc-toolbar-chunk {
        display: flex;
        justify-content: center;
        margin-bottom: 0.5rem;
    }

    .fc .fc-toolbar-title {
        font-size: 0.95rem;
        text-align: center;
    }

    .fc .fc-daygrid-day-number {
        font-size: 0.8rem;
        padding: 0.25rem;
    }

    .fc .fc-daygrid-more-link {
        font-size: 0.7rem;
        padding: 2px 8px;
        min-width: 24px;
        height: 18px;
    }
}

/* Toastr overrides */
.toast-top-right { top: 70px; }

/* Focus states */
.btn:focus, .btn:active:focus, .btn-link.nav-link:focus, .form-control:focus, .form-check-input:focus {
    box-shadow: 0 0 0 0.1rem white, 0 0 0 0.25rem #258cfb;
}

/* Global Loader */
.global-loader {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(5px);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 9999;
}

.global-loader.show {
    display: flex;
}

.loader-content {
    text-align: center;
}

.loader-content .spinner-border {
    width: 3rem;
    height: 3rem;
    border-width: 0.3rem;
}

/* Mobile optimizations */
@media (max-width: 991.98px) {
    .container-fluid {
        padding-left: 1rem;
        padding-right: 1rem;
    }

    h1, .h1 { font-size: 1.75rem; }
    h2, .h2 { font-size: 1.5rem; }
    h3, .h3 { font-size: 1.25rem; }
    h4, .h4 { font-size: 1.1rem; }
    h5, .h5 { font-size: 1rem; }
    h6, .h6 { font-size: 0.95rem; }
}

@media (max-width: 576px) {
    body {
        font-size: 0.9rem;
    }

    .btn-sm {
        font-size: 0.8rem;
        padding: 0.35rem 0.75rem;
    }

    .badge {
        font-size: 0.7rem;
        padding: 0.3rem 0.5rem;
    }

    .small, small {
        font-size: 0.8rem;
    }
}

/* Responsive spacing */
@media (max-width: 768px) {
    .mb-4 { margin-bottom: 1rem !important; }
    .mb-3 { margin-bottom: 0.75rem !important; }
    .g-3 { --bs-gutter-x: 0.75rem; --bs-gutter-y: 0.75rem; }
}
