/* ============================================
   MISHMAROT - Shift Planning Styles
   ============================================ */

:root {
    --color-bg: #1a1a2e;
    --color-surface: #16213e;
    --color-surface-hover: #1f3460;
    --color-border: #334466;
    --color-text: #e8e8e8;
    --color-text-muted: #888;
    --color-working: #4ade80;
    --color-working-bg: #166534;
    --color-not-working: #f87171;
    --color-not-working-bg: #991b1b;
    --color-available: #60a5fa;
    --color-available-bg: #1e40af;
    --color-unavailable: #525252;
    --color-unavailable-bg: #262626;
    --color-alena: #f472b6;
    --color-ilya: #60a5fa;
    --color-aglaya: #a78bfa;
    --color-primary: #3b82f6;
    --font-main: "Segoe UI", system-ui, -apple-system, sans-serif;
    --radius: 8px;
    --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.3);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: var(--font-main);
    background: var(--color-bg);
    color: var(--color-text);
    /*min-height: 100vh;*/
    padding: 20px;
}

.container {
    max-width: 800px;
    margin: 0 auto;
}

/* ============================================
   Header with Hamburger Menu
   ============================================ */

.app-header {
    position: relative;
    margin-bottom: 24px;
}

h1 {
    text-align: center;
    margin: 0;
    font-weight: 300;
    font-size: 1.8rem;
    color: var(--color-text);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
}

.logo-icon {
    width: 48px;
    height: 48px;
    border-radius: 8px;
}

.hamburger {
    position: absolute;
    right: 0;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    cursor: pointer;
    padding: 8px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    z-index: 1001;
}

.hamburger span {
    display: block;
    width: 24px;
    height: 2px;
    background: var(--color-text);
    transition: all 0.3s;
    border-radius: 2px;
}

.hamburger:hover span {
    background: var(--color-primary);
}

.hamburger.active span:nth-child(1) {
    transform: rotate(45deg) translateY(9px);
}

.hamburger.active span:nth-child(2) {
    opacity: 0;
}

.hamburger.active span:nth-child(3) {
    transform: rotate(-45deg) translateY(-9px);
}

.dropdown-menu {
    position: absolute;
    right: 0;
    top: calc(100% + 8px);
    background: var(--color-surface);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    min-width: 200px;
    overflow: hidden;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-10px);
    transition: all 0.3s;
    z-index: 1000;
}

.dropdown-menu.active {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.menu-item {
    display: block;
    padding: 12px 16px;
    color: var(--color-text);
    text-decoration: none;
    transition: background 0.2s;
}

.menu-item:hover {
    background: var(--color-surface-hover);
}

/* ============================================
   Week Navigation
   ============================================ */

#week-nav {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 16px;
    margin-bottom: 20px;
    padding: 12px;
    background: var(--color-surface);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.nav-btn {
    padding: 8px 16px;
    border: none;
    border-radius: var(--radius);
    background: var(--color-surface-hover);
    color: var(--color-text);
    cursor: pointer;
    font-size: 14px;
    transition: all 0.2s;
}

.nav-btn:hover {
    background: var(--color-border);
}

.week-label {
    font-size: 1.1rem;
    font-weight: 500;
    min-width: 200px;
    text-align: center;
}

/* ============================================
   Controls
   ============================================ */

#brush-selector {
    display: flex;
    justify-content: center;
    align-items: center;
    margin-bottom: 20px;
    padding: 12px;
    background: var(--color-surface);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.reset-btn {
    padding: 10px 20px;
    border: 2px solid transparent;
    border-radius: var(--radius);
    background: var(--color-unavailable-bg);
    border-color: var(--color-unavailable);
    color: var(--color-text-muted);
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.2s;
}

.reset-btn:hover {
    background: var(--color-not-working-bg);
    border-color: var(--color-not-working);
    color: var(--color-not-working);
}

/* ============================================
   Schedule Table
   ============================================ */

#schedule-table {
    background: var(--color-surface);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    overflow: hidden;
    touch-action: pan-y; /* Allow vertical scroll, enable horizontal swipe */
    user-select: none; /* Prevent text selection during swipe */
}

.schedule-header {
    display: grid;
    grid-template-columns: 100px 1fr 1fr 80px;
    background: var(--color-surface-hover);
    border-bottom: 2px solid var(--color-border);
}

.header-cell {
    padding: 14px 12px;
    font-weight: 600;
    text-align: center;
    font-size: 0.95rem;
}

.alena-header {
    color: var(--color-alena);
}

.ilya-header {
    color: var(--color-ilya);
}

.aglaya-header {
    color: var(--color-aglaya);
}

.schedule-row {
    display: grid;
    grid-template-columns: 100px 1fr 1fr 80px;
    border-bottom: 1px solid var(--color-border);
    transition: background 0.2s;
}

.schedule-row:last-child {
    border-bottom: none;
}

.schedule-row:hover {
    background: rgba(255, 255, 255, 0.02);
}

.schedule-row.current-day {
    background: rgba(59, 130, 246, 0.1);
    border-left: 3px solid var(--color-primary);
}

.schedule-row.current-day:hover {
    background: rgba(59, 130, 246, 0.15);
}

.schedule-row.current-day .day-name {
    font-weight: 700;
    color: var(--color-primary);
    font-size: 1rem;
}

.schedule-row.current-day .day-date {
    font-weight: 600;
    color: var(--color-primary);
    opacity: 0.9;
}

.date-cell {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    padding: 12px;
    border-right: 1px solid var(--color-border);
}

.day-name {
    font-weight: 600;
    font-size: 0.9rem;
}

.day-date {
    font-size: 0.8rem;
    color: var(--color-text-muted);
    margin-top: 2px;
}

.person-cell {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 8px;
    border-right: 1px solid var(--color-border);
}

.person-cell:last-child {
    border-right: none;
}

/* ============================================
   Shift Cells
   ============================================ */

.shifts-group {
    display: flex;
    gap: 6px;
}

.shift-cell {
    width: 40px;
    height: 40px;
    border: 2px solid transparent;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.shift-cell.available {
    background: var(--color-surface-hover);
    border-color: var(--color-border);
    color: var(--color-text-muted);
}

.shift-cell.available:hover {
    border-color: var(--color-available);
    color: var(--color-available);
}

.shift-cell.selected.working {
    background: var(--color-working-bg);
    border-color: var(--color-working);
    color: var(--color-working);
}

.shift-cell.blocked {
    background: var(--color-not-working-bg);
    border-color: var(--color-not-working);
    color: var(--color-not-working);
    cursor: not-allowed;
    opacity: 0.55;
    transition: none;
}

.shift-cell.not-exists {
    background: transparent;
    border-color: var(--color-border);
    color: var(--color-text-muted);
    cursor: not-allowed;
    opacity: 0.5;
    transition: none;
}

.alena-shifts .shift-cell.available:hover {
    border-color: var(--color-alena);
    color: var(--color-alena);
}

.ilya-shifts .shift-cell.available:hover {
    border-color: var(--color-ilya);
    color: var(--color-ilya);
}

/* ============================================
   Kindergarten Cell
   ============================================ */

.kindergarten-container {
    justify-content: center;
}

.kindergarten-cell {
    width: 44px;
    height: 44px;
    border: 2px solid transparent;
    border-radius: 50%;
    font-size: 16px;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.kindergarten-cell.active {
    background: var(--color-working-bg);
    border-color: var(--color-working);
    color: var(--color-working);
}

.kindergarten-cell.inactive {
    background: var(--color-not-working-bg);
    border-color: var(--color-not-working);
    color: var(--color-not-working);
}

.kindergarten-cell:hover {
    transform: scale(1.1);
}

/* ============================================
   Responsive
   ============================================ */

@media (max-width: 600px) {
    body {
        padding: 10px;
    }

    h1 {
        font-size: 1.4rem;
    }

    .logo-icon {
        width: 36px;
        height: 36px;
    }

    .schedule-header,
    .schedule-row {
        grid-template-columns: 70px 1fr 1fr 60px;
    }

    .shift-cell {
        width: 32px;
        height: 32px;
        font-size: 10px;
    }

    .kindergarten-cell {
        width: 36px;
        height: 36px;
        font-size: 14px;
    }

    .header-cell {
        padding: 10px 6px;
        font-size: 0.85rem;
    }

    #week-nav {
        flex-wrap: wrap;
    }

    .week-label {
        order: -1;
        width: 100%;
        margin-bottom: 8px;
    }
}

/* ============================================
   HISTORY PAGE
   ============================================ */

.page-nav {
    margin-bottom: 24px;
    text-align: center;
}

.nav-link {
    display: inline-block;
    padding: 12px 24px;
    background: var(--color-surface);
    color: var(--color-text);
    text-decoration: none;
    border-radius: var(--radius);
    transition: background 0.2s;
}

.nav-link:hover {
    background: var(--color-surface-hover);
}

#history-container {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.history-item {
    background: var(--color-surface);
    border-radius: var(--radius);
    padding: 16px;
    box-shadow: var(--shadow);
    transition: background 0.2s;
}

.history-item:hover {
    background: var(--color-surface-hover);
}

.history-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}

.history-user {
    font-weight: 600;
    color: var(--color-primary);
}

.history-time {
    font-size: 0.85rem;
    color: var(--color-text-muted);
}

.history-description {
    color: var(--color-text);
    line-height: 1.5;
}

.loading,
.empty-state,
.error {
    text-align: center;
    padding: 40px 20px;
    color: var(--color-text-muted);
}

.error {
    color: var(--color-not-working);
}

/* ============================================
   Login Page
   ============================================ */

.login-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 60px 20px;
    gap: 24px;
}

.login-text {
    color: var(--color-text-muted);
    font-size: 1.1rem;
    text-align: center;
}

.login-error {
    color: var(--color-not-working);
    font-size: 0.9rem;
    text-align: center;
}

/* Logout button in menu */
.logout-item {
    width: 100%;
    border: none;
    background: none;
    cursor: pointer;
    font-family: inherit;
    font-size: inherit;
    text-align: left;
    color: var(--color-not-working);
}

.logout-item:hover {
    background: var(--color-surface-hover);
}

@media (max-width: 600px) {
    .history-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 4px;
    }

    .history-time {
        font-size: 0.8rem;
    }
}
