:root {
    --primary-color: #3f51b5;
    --background-color: #f4f4f9;
    --sidebar-color: #2c3e50;
    --text-color: #333;
    --white: #fff;
    --hover-color: #ecf0f1;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    margin: 0;
    padding: 0;
    background-color: var(--background-color);
    color: var(--text-color);
    display: flex;
    height: 100vh;
}

.container {
    display: flex;
    width: 100%;
}

/* Sidebar drawer logic */
.sidebar {
    width: 280px;
    background-color: var(--sidebar-color);
    color: var(--white);
    padding: 70px 20px 20px 20px;
    /* Increased top padding to clear the ☰ button */
    display: flex;
    flex-direction: column;
    height: 100vh;
    box-sizing: border-box;
    transition: transform 0.3s ease;
    z-index: 1000;
}

.sidebar.hidden {
    transform: translateX(-100%);
    position: absolute;
}

.sidebar h2 {
    margin-top: 0;
    margin-bottom: 20px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    padding-bottom: 15px;
    font-size: 1.5rem;
}

.sidebar ul {
    list-style: none;
    padding: 0;
    overflow-y: auto;
    flex-grow: 1;
}

.sidebar li {
    padding: 15px 12px;
    cursor: pointer;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    transition: background 0.2s;
}

.sidebar li:hover {
    background-color: rgba(255, 255, 255, 0.1);
}

.sidebar li.active {
    background-color: var(--primary-color);
    font-weight: bold;
}

/* Menu Toggle Button */
.menu-toggle {
    position: fixed;
    top: 15px;
    left: 15px;
    z-index: 1001;
    background: var(--primary-color);
    color: white;
    border: none;
    width: 45px;
    height: 45px;
    border-radius: 8px;
    font-size: 24px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

/* Desktop behavior: Sidebar visible by default, but toggleable */
@media (min-width: 769px) {
    .sidebar.hidden {
        width: 0;
        padding: 0;
        overflow: hidden;
    }
}

/* Mobile behavior: Sidebar is a floating drawer */
@media (max-width: 768px) {
    .sidebar {
        position: fixed;
        left: 0;
        top: 0;
        transform: translateX(-100%);
    }

    .sidebar.active {
        transform: translateX(0);
    }

    .sidebar.hidden {
        transform: translateX(-100%);
    }

    .overlay {
        display: none;
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        background: rgba(0, 0, 0, 0.5);
        z-index: 999;
    }

    .overlay.active {
        display: block;
    }
}

/* Content adjustment */
.content {
    flex: 1;
    padding: 60px 40px 40px 40px;
    /* More top padding for the menu button */
    overflow-y: auto;
    transition: margin-left 0.3s ease;
    position: relative;
}

h1 {
    color: var(--sidebar-color);
    margin-bottom: 30px;
}

/* Reservation Table Responsive */
.reservation-table {
    background: var(--white);
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
    overflow: hidden;
    width: 100%;
    max-width: 1000px;
}

/* Rest of table styles stay same - keeping them readable */
.header-row {
    display: flex;
    background-color: var(--primary-color);
    color: var(--white);
    padding: 15px;
    font-weight: bold;
}

.slot-row {
    display: flex;
    padding: 15px;
    border-bottom: 1px solid #eee;
    align-items: center;
}

.slot-row:last-child {
    border-bottom: none;
}

.slot-row:hover {
    background-color: #f9f9f9;
}

.time-col {
    width: 100px;
    font-weight: bold;
    color: var(--sidebar-color);
}

.name-col {
    flex: 1;
    display: flex;
    overflow: hidden;
    /* Prevent text from pushing columns */
}

.name-input {
    width: 100%;
    padding: 8px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 14px;
}

.action-col {
    width: 120px;
    /* Slightly wider and fixed */
    flex-shrink: 0;
    /* Never shrink */
    text-align: right;
}

.save-btn {
    background-color: var(--primary-color);
    color: white;
    border: none;
    padding: 8px 15px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    transition: background 0.2s;
}

.save-btn:hover {
    background-color: #303f9f;
}

/* Mobile specific table tweaks */
@media (max-width: 600px) {
    .content {
        padding: 60px 12px 20px 12px;
    }

    .slot-row {
        padding: 12px 8px;
        gap: 8px;
        /* Keep it horizontal as per user wish "pozice tlačítka byla pevná" */
        flex-direction: row;
        flex-wrap: nowrap;
    }

    .time-col {
        width: 65px;
        /* Compact time */
        font-size: 0.9rem;
    }

    .name-col {
        flex: 1;
        min-width: 0;
        /* Important for ellipsis in flexbox */
    }

    .name-input {
        padding: 6px;
        font-size: 0.95rem;
    }

    .action-col {
        width: 100px;
        /* Specific width for mobile buttons */
        text-align: right;
        margin-top: 0;
    }

    .save-btn {
        width: auto;
        padding: 10px 12px;
        font-size: 0.85rem;
        min-height: 44px;
        /* Better touch target */
    }

    .header-row {
        display: none;
    }

    h1 {
        font-size: 1.5rem;
        margin-bottom: 20px;
    }
}

/* Keeping Print Styles */
@media print {
    body {
        background-color: white;
        height: auto;
        display: block;
    }

    .menu-toggle,
    .sidebar,
    .sidebar.active,
    .overlay {
        display: none !important;
    }

    .content {
        padding: 0;
        margin: 0;
        width: 100%;
    }

    .container {
        display: block;
    }

    .reservation-table {
        box-shadow: none;
        width: 100%;
        max-width: none;
    }

    .header-row {
        background-color: #ddd !important;
        color: black !important;
        border-bottom: 2px solid black;
    }

    .slot-row {
        border-bottom: 1px solid #000;
    }

    .name-input {
        border: none;
        background: transparent;
        padding: 0;
    }

    .action-col,
    .save-btn {
        display: none !important;
    }

    h1 {
        text-align: center;
        font-size: 24pt;
        margin-bottom: 20px;
    }
}

/* Loading Overlay */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(255, 255, 255, 0.9);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 2000;
    font-weight: bold;
    color: var(--sidebar-color);
}

.loader {
    border: 5px solid #f3f3f3;
    border-top: 5px solid var(--primary-color);
    border-radius: 50%;
    width: 40px;
    height: 40px;
    animation: spin 1s linear infinite;
    margin-bottom: 20px;
}

/* Highlight own reservation */
.slot-row.my-slot {
    background-color: #e8f5e9 !important;
    border-left: 4px solid #2ecc71;
}

.occupied-name {
    font-weight: 600;
    color: #2c3e50;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    display: block;
    width: 100%;
    line-height: 1.4;
}

.slot-row.occupied {
    background-color: #fcfcfc;
}

/* Sidebar Toggle Animation */
.sidebar {
    transition: all 0.3s ease-in-out;
}

@keyframes spin {
    0% {
        transform: rotate(0deg);
    }

    100% {
        transform: rotate(360deg);
    }
}

/* Refresh Button */
.refresh-btn {
    background: rgba(255, 255, 255, 0.1);
    border: none;
    color: white;
    font-size: 20px;
    cursor: pointer;
    padding: 5px 10px;
    border-radius: 4px;
    transition: background 0.3s;
}

.refresh-btn:hover {
    background: rgba(255, 255, 255, 0.2);
}

/* --- Admin Mobile Styles --- */
@media (max-width: 768px) {
    .admin-sidebar {
        position: fixed !important;
        left: 0 !important;
        top: 0 !important;
        width: 280px !important;
        height: 100vh !important;
        transform: translateX(-100%) !important;
        z-index: 1000 !important;
        transition: transform 0.3s ease-in-out !important;
        background: #2c3e50 !important;
        display: flex !important;
        flex-direction: column !important;
    }

    .admin-sidebar.active {
        transform: translateX(0) !important;
    }

    .admin-main {
        padding: 70px 15px 20px 15px !important;
        width: 100% !important;
        margin-left: 0 !important;
    }

    .admin-page #overlay {
        display: none;
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        background: rgba(0, 0, 0, 0.5);
        z-index: 999;
    }

    .admin-page #overlay.active {
        display: block;
    }

    .stats-bar {
        flex-direction: column;
        gap: 10px;
    }
}

/* Admin specific alignment */
.admin-main {
    flex: 1;
    padding: 30px !important;
    overflow-y: auto;
    background: #f4f4f9;
    position: relative;
}

@media (max-width: 768px) {
    .content {
        padding: 60px 15px 15px 15px;
    }

    .admin-main {
        padding: 70px 15px 15px 15px !important;
    }
}