:root {
    --primary-blue: #29b6f6;
    --bg-body: #f5f7fa;
    --border-color: #e0e0e0;
    --text-main: #333;
    --text-muted: #999;
    --slot-height: 60px;
    --col-width: 400px;
    --hover-slot-bg: rgba(41, 182, 246, 0.2);
    --current-time-color: #ff5252;
}

body {
    font-family: 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
    background-color: var(--bg-body);
    color: var(--text-main);
    height: 100vh;
    display: flex;
    overflow: hidden;
    font-size: 13px;
}

/* === Main Layout === */

.main-content {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    position: relative;
    background: #fff;
    overflow: hidden;
}

/* === Resource Header === */

.resource-header {
    height: 60px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    background: #fff;
    flex-shrink: 0;
    padding-left: 60px;
    overflow: hidden;
    position: relative;
}

.resource-col-header {
    width: var(--col-width);
    flex-shrink: 0;
    padding: 0 10px;
    border-right: 1px solid var(--border-color);
    position: relative;
    cursor: grab;
    user-select: none;
}

.resource-col-header:active {
    cursor: grabbing;
    background-color: #f0f8ff;
}

.sortable-ghost .doctor-remove-btn {
    display: none;
}

.resource-card {
    background: #fff;
    padding: 5px 0;
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
}

.res-info { display: flex; flex-direction: column; flex-grow: 1; overflow: hidden; }
.res-name { font-weight: 600; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.res-role { font-size: 11px; color: var(--text-muted); }

.btn-remove-resource {
    position: absolute;
    top: 2px;
    right: 5px;
    color: #ff5252;
    cursor: pointer;
    opacity: 0;
    transition: opacity 0.2s;
    font-size: 14px;
}
.resource-col-header:hover .btn-remove-resource { opacity: 1; }

.btn-schedule-resource {
    position: absolute;
    top: 2px;
    right: 25px;
    color: #ffa000;
    cursor: pointer;
    opacity: 0;
    transition: opacity 0.2s;
    font-size: 14px;
}
.resource-col-header:hover .btn-schedule-resource { opacity: 1; }

.btn-add-resource {
    margin-left: 15px;
    background: #e1f5fe;
    color: var(--primary-blue);
    border: none;
    padding: 8px 15px;
    border-radius: 20px;
    font-size: 13px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 5px;
    white-space: nowrap;
    flex-shrink: 0;
}

/* === Scheduler Grid === */

.scheduler-wrapper {
    flex-grow: 1;
    overflow: auto;
    position: relative;
    display: flex;
    scrollbar-width: none;
}
.scheduler-wrapper::-webkit-scrollbar {
    display: none;
}

.time-gutter {
    width: 60px;
    flex-shrink: 0;
    border-right: 1px solid var(--border-color);
    background: #fff;
    position: sticky;
    left: 0;
    z-index: 20;
    padding-top: 10px;
}

.time-label {
    height: var(--slot-height);
    font-size: 11px;
    color: var(--text-muted);
    text-align: right;
    padding-right: 10px;
    position: relative;
}
.time-label span { position: relative; top: -7px; background: #fff; padding-left: 5px; }

.grid-columns-container {
    display: flex;
    position: relative;
    background-size: 100% var(--slot-height);
    background-image: linear-gradient(to bottom, var(--border-color) 1px, transparent 1px);
    margin-top: 10px;
}

.resource-column {
    width: var(--col-width);
    flex-shrink: 0;
    border-right: 1px solid var(--border-color);
    position: relative;
    height: 100%;
}

#gridColumns {
    display: flex;
}

/* === Ghost Slot (hover preview) === */

.ghost-slot {
    position: absolute;
    left: 2px;
    right: 2px;
    background: var(--hover-slot-bg);
    border: 1px dashed var(--primary-blue);
    border-radius: 3px;
    pointer-events: none;
    display: none;
    z-index: 100;
    color: var(--primary-blue);
    font-size: 11px;
    font-weight: bold;
    padding: 2px 5px;
    align-items: center;
    justify-content: center;
}

/* === Booked Events === */

.booked-event {
    position: absolute;
    left: 4px;
    right: 4px;
    border-radius: 3px;
    padding: 3px 6px;
    font-size: 11px;
    color: #fff;
    box-shadow: 0 1px 2px rgba(0,0,0,0.2);
    z-index: 10;
    pointer-events: auto;
    display: flex;
    align-items: center;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
}

.booked-event .evt-content {
    display: block;
    width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
}

.booked-event .evt-title { font-weight: bold; font-size: 11px; }
.booked-event .evt-time { font-size: 10px; opacity: 0.9; }

.booked-event .evt-contact {
    font-size: 10px;
    opacity: 0.9;
    margin-top: 2px;
}

.booked-event .delete-booking-btn {
    position: absolute;
    top: 2px;
    right: 4px;
    width: 18px;
    height: 18px;
    background: rgba(255, 255, 255, 0.9);
    color: #ff5252;
    border-radius: 50%;
    display: none;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 12px;
    z-index: 100;
    transition: all 0.2s;
}

.booked-event .delete-booking-btn:hover {
    background: #ff5252;
    color: white;
    transform: scale(1.1);
}

.booked-event:hover .delete-booking-btn {
    display: flex;
}

.booked-event .comment-dot {
    position: absolute;
    top: 4px;
    right: 24px;
    width: 8px;
    height: 8px;
    background: #000;
    border-radius: 50%;
    z-index: 50;
    pointer-events: none;
}

/* === Non-working Zones === */

.non-working-slot {
    position: absolute;
    left: 0;
    right: 0;
    background: repeating-linear-gradient(
      45deg,
      #f0f0f0,
      #f0f0f0 10px,
      #e0e0e0 10px,
      #e0e0e0 20px
    );
    opacity: 0.7;
    z-index: 5;
    pointer-events: auto;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #999;
    font-size: 10px;
    border-top: 1px solid #ccc;
    border-bottom: 1px solid #ccc;
}

/* === Scroll Arrows === */

.scroll-arrow {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 50px;
    height: 100px;
    background-color: rgba(0, 0, 0, 0.05);
    color: #555;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 999;
    border-radius: 8px;
    transition: all 0.3s;
    font-size: 30px;
    user-select: none;
}

.scroll-arrow:hover {
    background-color: rgba(41, 182, 246, 0.8);
    color: white;
    box-shadow: 0 4px 15px rgba(0,0,0,0.2);
}

.scroll-arrow-left {
    left: 10px;
    display: none;
}

.scroll-arrow-right {
    right: 10px;
    display: none;
}

/* === Sidebar Right === */

.sidebar-right {
    width: 300px;
    border-left: 1px solid var(--border-color);
    background: #fff;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    padding: 60px 20px 20px 20px;
}

.cal-header { display: flex; justify-content: space-between; margin-bottom: 15px; font-weight: 600; }
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 5px; text-align: center; }
.cal-day-name { color: var(--text-muted); font-size: 11px; margin-bottom: 5px; }
.cal-day {
    height: 30px; display: flex; align-items: center; justify-content: center;
    border-radius: 50%; cursor: pointer; font-size: 12px;
}
.cal-day:hover { background: #f0f0f0; }
.cal-day.active { background: var(--primary-blue); color: #fff; }

/* === Services === */

.service-option {
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    padding: 10px;
    margin-bottom: 8px;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.service-option:hover { background-color: #f5f7fa; border-color: var(--primary-blue); }
.service-option.selected {
    background-color: #e1f5fe;
    border-color: var(--primary-blue);
    color: var(--primary-blue);
}
.service-time { font-weight: bold; font-size: 12px; background: #fff; padding: 2px 6px; border-radius: 4px; }

/* === Select2 Overrides === */

.select2-container { z-index: 9999 !important; }
.select2-container--default .select2-selection--single { height: 38px; padding: 6px 12px; }
.select2-container--default .select2-selection--single .select2-selection__rendered { line-height: 24px; }

/* === Tabs === */

.tab-btn.active {
    background: #fff !important;
    border-bottom: 3px solid #29b6f6 !important;
    color: #29b6f6;
    font-weight: 600;
}

.tab-btn:hover {
    background: #e8f4f8;
}

/* === Settings Panel z-index === */

#settingsPanel ~ .modal {
    z-index: 10001 !important;
}
.modal-backdrop {
    z-index: 10000 !important;
}

/* === Status Legend === */

.status-legend {
    margin-top: 20px;
    border-top: 1px solid #e0e0e0;
    padding-top: 15px;
}

.status-legend-title {
    font-size: 12px;
    color: #666;
    font-weight: 600;
    margin-bottom: 10px;
    display: flex;
    align-items: center;
    gap: 5px;
}

.status-legend-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 4px 0;
    font-size: 12px;
    color: #555;
}

.status-legend-color {
    width: 16px;
    height: 16px;
    border-radius: 4px;
    flex-shrink: 0;
    box-shadow: 0 1px 2px rgba(0,0,0,0.15);
}

.status-legend-name {
    flex-grow: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* === Deal Search === */

#searchResults .list-group-item:hover {
    background-color: #e3f2fd;
    border-color: #29b6f6;
}

#searchResults .list-group-item:active {
    background-color: #bbdefb;
}

#dealSearchSection .input-group input:focus {
    border-color: #29b6f6;
    box-shadow: 0 0 0 0.2rem rgba(41, 182, 246, 0.25);
}

/* === Full Calendar (modal) === */

.calendar-controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
}

.calendar-grid-header {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    background: #f8f9fa;
    border-bottom: 1px solid #e0e0e0;
    padding: 10px 0;
    font-weight: 600;
    text-align: center;
    color: #555;
    flex-shrink: 0;
    margin-right: 5px;
}
.calendar-grid-header div { padding: 5px; }

.calendar-grid-body {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    grid-auto-rows: minmax(100px, auto);
    overflow-y: auto;
    padding-right: 5px;
}

.cal-cell {
    border-right: 1px solid #eee;
    border-bottom: 1px solid #eee;
    background: #fff;
    padding: 30px 4px 4px 4px;
    position: relative;
    min-height: 100px;
    display: flex;
    flex-direction: column;
    gap: 2px;
}
.cal-cell:nth-child(7n) { border-right: none; }

.cal-cell.empty {
    background: #fcfcfc;
    color: #ccc;
}
.cal-cell.today {
    background: #fff9c4;
}

.cal-cell-date {
    position: absolute;
    top: 5px;
    right: 8px;
    font-weight: bold;
    font-size: 14px;
    color: #777;
    z-index: 1;
}

.cal-event-item {
    font-size: 10px;
    padding: 3px 5px;
    border-radius: 3px;
    color: #fff;
    cursor: pointer;
    margin-bottom: 2px;
    white-space: normal;
    line-height: 1.2;
    overflow: hidden;
    word-wrap: break-word;
    box-shadow: 0 1px 2px rgba(0,0,0,0.1);
    transition: opacity 0.2s;
}
.cal-event-item:hover { opacity: 0.9; }
