:root {
    --primary-color: #0288d1;
    /* Blue/Azure */
    --primary-light: #03a9f4;
    --primary-dark: #01579b;
    --secondary-color: #e1f5fe;
    /* Light Blue BG */
    --text-color: #37474f;
    /* Blue Grey 800 */
    --bg-color: #f5f5f5;
    --white: #ffffff;
    --border-color: #cfd8dc;
    --danger: #d32f2f;
    --success: #388e3c;
    --warning: #fbc02d;
    --grid-line: #eceff1;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background-color: var(--bg-color);
    color: var(--text-color);
    line-height: 1.6;
}

/* --- Layout --- */
.app-container {
    display: flex;
    flex-direction: row;
    height: 100vh;
    overflow: hidden;
}

.sidebar {
    width: 280px;
    background-color: var(--primary-dark);
    color: var(--white);
    display: flex;
    flex-direction: column;
    height: 100%;
    flex-shrink: 0;
    box-shadow: 2px 0 10px rgba(0, 0, 0, 0.1);
    z-index: 100;
}

.brand {
    padding: 2rem 1.5rem;
    font-size: 1.3rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 0.8rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.nav-links {
    display: flex;
    flex-direction: column;
    padding: 1.5rem 0;
    flex: 1;
}

.nav-item {
    color: rgba(255, 255, 255, 0.7);
    text-decoration: none;
    font-weight: 500;
    font-size: 1rem;
    cursor: pointer;
    transition: all 0.2s;
    padding: 12px 1.5rem;
    display: flex;
    align-items: center;
    gap: 12px;
    border-left: 4px solid transparent;
}

.nav-item i {
    width: 20px;
    text-align: center;
}

.nav-item:hover {
    background-color: rgba(255, 255, 255, 0.1);
    color: var(--white);
}

.nav-item.active {
    color: var(--white);
    background-color: rgba(255, 255, 255, 0.15);
    border-left-color: var(--primary-light);
}

.user-sidebar-menu {
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.admin-info {
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 600;
}

.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    background-color: var(--bg-color);
}

/* --- Controls & Buttons --- */
.controls-bar {
    background: var(--white);
    padding: 1rem 1.5rem;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.date-nav {
    display: flex;
    align-items: center;
    gap: 15px;
}

.date-controls {
    display: flex;
    background: #f1f3f4;
    padding: 4px;
    border-radius: 8px;
    gap: 4px;
}

.date-controls .btn {
    box-shadow: none;
    padding: 6px 15px;
    font-size: 0.85rem;
    height: 34px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.btn-icon-small {
    width: 34px;
    padding: 0 !important;
}

#current-date-range {
    font-weight: 700;
    font-size: 1.1rem;
    color: var(--primary-dark);
    margin: 0 10px;
}

.view-toggles {
    display: flex;
    gap: 5px;
    margin-left: 15px;
    padding-left: 15px;
    border-left: 1px solid var(--border-color);
}

.btn {
    padding: 0.6rem 1.2rem;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 600;
    transition: all 0.2s;
    letter-spacing: 0.3px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);
    opacity: 0.95;
}

.btn-primary {
    background-color: var(--primary-color);
    color: var(--white);
}

.btn-secondary {
    background-color: var(--white);
    color: #546e7a;
    border: 1px solid var(--border-color);
    box-shadow: none;
}

.btn-secondary:hover {
    background-color: #eceff1;
}

.btn-danger {
    background-color: var(--danger);
    color: var(--white) !important;
}

.text-white {
    color: var(--white) !important;
}

.btn-block {
    width: 100%;
    margin-top: 10px;
}

.btn-icon {
    width: 46px;
    height: 46px;
    padding: 0 !important;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    flex-shrink: 0;
}

/* --- Search Bar --- */
.search-bar-container {
    padding-bottom: 1.5rem;
}

.search-box {
    position: relative;
    max-width: 500px;
    display: flex;
    align-items: center;
}

.search-box i.fa-search {
    position: absolute;
    left: 15px;
    color: #999;
}

.search-box input {
    width: 100%;
    padding: 12px 40px 12px 45px;
    border: 1px solid var(--border-color);
    border-radius: 12px;
    font-size: 0.95rem;
    outline: none;
    transition: all 0.2s;
    background: #fff;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.02);
}

.search-box input:focus {
    border-color: var(--primary-color);
    box-shadow: 0 4px 12px rgba(0, 102, 204, 0.15);
}

.search-clear {
    position: absolute;
    right: 12px;
    background: none;
    border: none;
    color: #ccc;
    cursor: pointer;
    padding: 5px;
    font-size: 1rem;
    visibility: hidden;
    transition: color 0.2s;
}

.search-clear:hover {
    color: var(--danger);
}

.filter-input {
    padding: 10px 15px;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    flex: 1;
    font-size: 0.95rem;
    transition: all 0.2s;
    background-color: #f9f9f9;
}

.filter-input:focus {
    background-color: #fff;
    border-color: var(--primary-color);
    outline: none;
    box-shadow: 0 0 0 3px rgba(2, 136, 209, 0.1);
}

.list-filters .btn {
    padding: 10px 20px;
    height: 42px;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* --- List View Table --- */
.data-table {
    width: 100%;
    border-collapse: collapse;
    background: var(--white);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
    border-radius: 8px;
    overflow: hidden;
    margin-top: 10px;
}

.data-table th,
.data-table td {
    padding: 1rem;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
}

.data-table th {
    background-color: var(--secondary-color);
    font-weight: 700;
    color: var(--primary-dark);
}

.data-table tr:hover {
    background-color: #fafafa;
}

/* --- Modals --- */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    overflow: auto;
    background-color: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(2px);
    animation: fadeIn 0.3s;
}

.modal-content {
    background-color: #fefefe;
    margin: 5% auto;
    padding: 30px;
    border: 1px solid #888;
    width: 90%;
    max-width: 500px;
    /* Slimmer max width */
    border-radius: 12px;
    box-shadow: 0 15px 35px rgba(0, 0, 0, 0.25);
    position: relative;
    animation: slideUp 0.3s cubic-bezier(0.18, 0.89, 0.32, 1.28);
}

.close {
    color: #aaa;
    float: right;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
    line-height: 1;
    position: relative;
    top: -10px;
    right: -10px;
    width: 30px;
    height: 30px;
    text-align: center;
    border-radius: 50%;
    transition: all 0.2s;
}

.close:hover,
.close:focus {
    color: var(--danger);
    background: #ffebee;
}

/* Modal Headers */
.modal-content h2,
.modal-title {
    margin-top: 0;
    color: var(--primary-dark);
    font-weight: 700;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 15px;
    margin-bottom: 25px;
    font-size: 1.25rem;
}

/* Modal Inputs */
.modal-content input[type="text"],
.modal-content input[type="email"],
.modal-content input[type="tel"],
.modal-content input[type="date"],
.modal-content input[type="time"],
.modal-content input[type="password"],
.modal-content input[type="number"],
.modal-content select,
.modal-content textarea {
    width: 100%;
    padding: 12px 14px;
    margin: 8px 0 15px 0;
    display: inline-block;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    box-sizing: border-box;
    font-size: 0.95rem;
    transition: all 0.2s;
    background-color: #ffffff;
    color: var(--text-color);
}

.modal-content select {
    appearance: none;
    background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6 9 12 15 18 9'%3e%3c/polyline%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: right 14px center;
    background-size: 16px;
    padding-right: 40px;
    cursor: pointer;
}

.modal-content input:focus,
.modal-content select:focus,
.modal-content textarea:focus {
    border-color: var(--primary-color);
    outline: none;
    box-shadow: 0 0 0 3px rgba(2, 136, 209, 0.15);
}

.modal-content select:hover {
    border-color: var(--primary-light);
}

.modal-content label {
    font-weight: 600;
    font-size: 0.9rem;
    color: #546e7a;
    display: block;
    margin-bottom: -5px;
}

/* Modal Footer Actions */
.modal-actions {
    margin-top: 20px;
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}

/* Animations */
@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

@keyframes slideUp {
    from {
        transform: translateY(20px);
        opacity: 0;
    }

    to {
        transform: translateY(0);
        opacity: 1;
    }
}

/* --- Calendar Logic --- */
.view-container {
    flex: 1;
    overflow: hidden;
    position: relative;
    padding: 1.5rem;
}

.hidden {
    display: none !important;
}

.calendar-wrapper {
    background: var(--white);
    border: 1px solid var(--border-color);
    height: 100%;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
}

.calendar-header {
    display: grid;
    grid-template-columns: 70px repeat(5, 1fr);
    border-bottom: 2px solid var(--border-color);
    background: #fcfcfc;
}

.header-cell {
    padding: 1rem 0.5rem;
    text-align: center;
    border-right: 1px solid var(--border-color);
    font-weight: 700;
    color: #455a64;
}

.calendar-body {
    flex: 1;
    overflow-y: auto;
    position: relative;
    background: #fff;
}

.calendar-grid {
    display: grid;
    grid-template-columns: 70px repeat(5, 1fr);
    position: relative;
}

.time-column {
    border-right: 1px solid var(--border-color);
    background: #fafafa;
}

.time-slot {
    height: 120px;
    border-bottom: 1px solid var(--grid-line);
    font-size: 0.8rem;
    color: #90a4ae;
    text-align: center;
    padding-top: 5px;
}

.day-column {
    border-right: 1px solid var(--grid-line);
    position: relative;
    min-height: 600px;
}

.day-slot-bg {
    height: 120px;
    border-bottom: 1px solid var(--grid-line);
}

.event-card {
    position: absolute;
    left: 4px;
    right: 4px;
    border-radius: 6px;
    padding: 8px 10px;
    font-size: 0.85rem;
    color: var(--white);
    overflow: hidden;
    cursor: pointer;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.2);
    z-index: 10;
    border-left: 5px solid rgba(0, 0, 0, 0.2);
    border-bottom: 2px solid rgba(0, 0, 0, 0.1);
    transition: transform 0.1s;
}

.event-card:hover {
    z-index: 20;
    transform: scale(1.02);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
}

/* --- Patient Details Tabs --- */
.btn-tab {
    background: none;
    border: none;
    padding: 10px 15px;
    cursor: pointer;
    font-weight: 600;
    color: #888;
    transition: all 0.2s;
}

.btn-tab.active {
    color: var(--primary-color);
    border-bottom: 2px solid var(--primary-color);
}

.btn-tab:hover {
    color: var(--primary-dark);
}

.details-tab.hidden {
    display: none;
}

#medical-records-timeline {
    margin-top: 20px;
    max-height: 400px;
    overflow-y: auto;
    padding-right: 10px;
}

.badge {
    font-size: 0.75rem;
    padding: 2px 8px;
    border-radius: 12px;
}


.event-card-short {
    padding: 2px 4px;
    font-size: 0.7rem;
    line-height: 1;
}

.event-card-short .event-time {
    margin-bottom: 0;
    font-size: 0.65rem;
}

.event-card-short strong {
    white-space: nowrap;
    text-overflow: ellipsis;
    display: block;
    overflow: hidden;
}

.event-time {
    font-weight: 800;
    display: block;
    margin-bottom: 3px;
    font-size: 0.75rem;
    opacity: 0.9;
}

.color-1 {
    background-color: #26a69a;
}

.color-2 {
    background-color: #ffa726;
}

.color-3 {
    background-color: #ef5350;
}

/* Login Page */
.login-page {
    display: flex;
    justify-content: center;
    align-items: center;
    height: 100vh;
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-dark) 100%);
}

.login-card {
    background: var(--white);
    padding: 40px;
    border-radius: 16px;
    width: 100%;
    max-width: 420px;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.2);
    text-align: center;
}

.login-card h2 {
    margin-bottom: 2rem;
    color: var(--primary-dark);
}

.form-group {
    margin-bottom: 1.2rem;
    text-align: left;
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 600;
    font-size: 0.9rem;
    color: #546e7a;
}

.form-group input {
    width: 100%;
    padding: 12px;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    transition: 0.2s;
}

.form-group input:focus {
    border-color: var(--primary-color);
    outline: none;
    box-shadow: 0 0 0 3px rgba(2, 136, 209, 0.1);
}

/* --- Media Queries (Responsiveness) --- */
@media (max-width: 992px) {
    .calendar-body {
        overflow-x: auto;
    }

    .calendar-header,
    .calendar-grid {
        min-width: 800px;
        /* Force scroll on tablets */
    }
}

/* --- Slots Grid (Shared) --- */
.slots-container label {
    display: block;
    margin-bottom: 15px;
    font-weight: 700;
    color: var(--primary-dark);
}

.slots-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.slot-btn {
    padding: 10px 16px;
    border: 1.5px solid var(--secondary-color);
    background: var(--white);
    color: var(--primary-dark);
    border-radius: 10px;
    cursor: pointer;
    font-weight: 600;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    font-size: 0.95rem;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.02);
}

.slot-btn:hover {
    background: var(--primary-color);
    color: var(--white);
    border-color: var(--primary-color);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(2, 136, 209, 0.2);
}

.slot-btn.active {
    background: var(--primary-dark);
    color: var(--white);
    border-color: var(--primary-dark);
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.1);
}

.slot-btn.booked {
    background: #f5f5f5 !important;
    color: #bdbdbd !important;
    border-color: #eee !important;
    cursor: not-allowed !important;
    box-shadow: none !important;
    transform: none !important;
}

@media (max-width: 768px) {
    .top-nav {
        padding: 0 1rem;
    }

    .nav-links {
        gap: 1rem;
    }

    .brand span {
        display: none;
        /* Hide 'Kalendarz Wizyt' text, keep icon */
    }

    .controls-bar {
        flex-direction: column;
        gap: 10px;
        align-items: stretch;
    }

    .list-filters {
        flex-direction: column;
        align-items: stretch;
    }

    .view-container {
        padding: 1rem;
    }

    .data-table {
        display: block;
        overflow-x: auto;
    }

    .modal-content {
        width: 95%;
        margin: 10% auto;
        padding: 20px;
    }
}

@media (max-width: 480px) {
    .top-nav {
        height: auto;
        padding: 10px;
        flex-direction: column;
        gap: 10px;
    }

    .nav-links {
        width: 100%;
        justify-content: center;
        flex-wrap: wrap;
        gap: 0.5rem;
    }

    .nav-item {
        font-size: 0.85rem;
    }

    .brand {
        font-size: 1.2rem;
    }

    .calendar-header,
    .calendar-grid {
        min-width: 600px;
    }

    .time-slot,
    .day-slot-bg {
        height: 100px;
        /* Slightly smaller on mobile */
    }

    .modal-content h2,
    .modal-title {
        font-size: 1.1rem;
    }
}