/* --- VARIABLES --- */
:root {
    --transition: 0.2s ease;
    --radius: 8px;
    
    /* LIGHT (Default) */
    --bg-body: #f4f6f8;
    --bg-card: rgba(255, 255, 255, 0.95);
    --bg-input: #f1f3f4;
    --text-main: #202124;
    --text-muted: #5f6368;
    --border: #dadce0;
    --primary: #1a73e8; 
    --primary-hover: #1557b0;
    --text-on-primary: #ffffff;
    --weekend: #34a853; 
    --danger: #d93025;
    --blocked-red: #ffebee;
    --blocked-gray: #f1f3f4;
    --confirmed-blue: #e3f2fd;
    --shadow: 0 1px 3px rgba(0,0,0,0.12), 0 1px 2px rgba(0,0,0,0.24);
    --modal-overlay: rgba(0, 0, 0, 0.5);
    color-scheme: light;
}

[data-theme="dark"] {
    --bg-body: #202124;
    --bg-card: rgba(41, 42, 45, 0.9);
    --bg-input: #35363a;
    --text-main: #e8eaed;
    --text-muted: #9aa0a6;
    --border: #3c4043;
    --primary: #8ab4f8;
    --primary-hover: #aecbfa;
    --text-on-primary: #202124;
    --weekend: #1e8e3e;
    --danger: #f28b82;
    --blocked-red: #5c2b2b;
    --blocked-gray: #3c4043;
    --confirmed-blue: #1c3aa9;
    --shadow: 0 4px 8px rgba(0,0,0,0.3);
    --modal-overlay: rgba(0, 0, 0, 0.7);
    color-scheme: dark;
}

[data-theme="black"] {
    --bg-body: #000000;
    --bg-card: rgba(18, 18, 18, 0.9);
    --bg-input: #1f1f1f;
    --text-main: #ffffff;
    --text-muted: #888888;
    --border: #333333;
    --primary: #8ab4f8; 
    --primary-hover: #e0e0e0;
    --text-on-primary: #000000;
    --weekend: #0d5126;
    --danger: #ef5350;
    --blocked-red: #3d0000;
    --blocked-gray: #111111;
    --confirmed-blue: #0d1b45;
    --shadow: none;
    --modal-overlay: rgba(255, 255, 255, 0.1);
    color-scheme: dark;
}

[data-theme="newyear"] {
    --bg-body: #0f361e; 
    --bg-card: #fffaf0; 
    --bg-input: #ffffff;
    --text-main: #2d3436;
    --text-muted: #636e72;
    --border: #b2bec3;
    --primary: #c0392b; 
    --primary-hover: #e74c3c;
    --text-on-primary: #ffffff;
    --weekend: #27ae60;
    --danger: #d63031;
    --blocked-red: #fad390;
    --blocked-gray: #dfe6e9;
    --confirmed-blue: #dff9fb;
    --shadow: 0 4px 15px rgba(0,0,0,0.3);
    color-scheme: light;
}

[data-theme="fairytale"] {
    --bg-body: #fff0f5; 
    --bg-card: #ffffff;
    --bg-input: #fce4ec;
    --text-main: #4a4a4a;
    --text-muted: #888;
    --border: #f8bbd0;
    --primary: #ff80ab; 
    --primary-hover: #ff4081;
    --text-on-primary: #ffffff;
    --weekend: #b2dfdb;
    --danger: #ff5252;
    --blocked-red: #ffcdd2;
    --blocked-gray: #fce4ec;
    --confirmed-blue: #e3f2fd;
    --shadow: 0 5px 15px rgba(255, 105, 180, 0.2);
    color-scheme: light;
}

[data-theme="magic"] {
    --bg-body: #190028; 
    --bg-card: #240046;
    --bg-input: #3c096c;
    --text-main: #e0aaff;
    --text-muted: #9d4edd;
    --border: #5a189a;
    --primary: #c77dff; 
    --primary-hover: #e0aaff;
    --text-on-primary: #10002b;
    --weekend: #00b4d8;
    --danger: #ff006e;
    --blocked-red: #3a0ca3;
    --blocked-gray: #10002b;
    --confirmed-blue: #240090;
    --shadow: 0 0 20px rgba(199, 125, 255, 0.2);
    color-scheme: dark;
}

/* GLOBAL */
body { font-family: 'Segoe UI', 'Roboto', Helvetica, Arial, sans-serif; background-color: var(--bg-body); color: var(--text-main); margin: 0; font-size: 14px; min-height: 100vh; }
.container { max-width: 100%; margin: 0 auto; padding: 20px; box-sizing: border-box; }

/* BACKGROUND IMAGES */
body.bg-login { background-image: url('login.jpeg'); background-size: cover; background-position: center; background-attachment: fixed; }
body.bg-register { background-image: url('register.jpeg'); background-size: cover; background-position: center; background-attachment: fixed; }
body.bg-logout { background-image: url('logout.jpeg'); background-size: cover; background-position: center; background-attachment: fixed; }

/* AUTH PAGE */
.auth-page { display: flex; justify-content: center; align-items: center; min-height: 100vh; padding: 20px; box-sizing: border-box; }
.auth-card { background: var(--bg-card); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); width: 100%; max-width: 420px; padding: 40px; border-radius: 16px; box-shadow: 0 10px 40px rgba(0,0,0,0.3); border: 1px solid var(--border); text-align: center; margin: auto; }
.auth-card h1 { margin: 0 0 10px; font-size: 26px; font-weight: 800; letter-spacing: -0.5px; }
.auth-toggle-btn { background: transparent; border: 1px solid var(--primary); color: var(--primary); padding: 12px; width: 100%; margin-top: 20px; border-radius: 6px; cursor: pointer; font-weight: 700; transition: 0.2s; text-transform: uppercase; font-size: 12px; letter-spacing: 0.5px; }
.auth-toggle-btn:hover { background: rgba(26, 115, 232, 0.1); transform: translateY(-1px); }

/* LOGOUT SCREEN */
.logout-card { background: var(--bg-card); backdrop-filter: blur(15px); padding: 60px; border-radius: 24px; box-shadow: 0 20px 60px rgba(0,0,0,0.4); text-align: center; max-width: 600px; width: 100%; border: 1px solid var(--border); animation: fadeIn 0.5s ease-out; margin: auto; }
.logout-title { font-size: 32px; font-weight: 800; color: var(--primary); margin-bottom: 25px; line-height: 1.3; text-shadow: 0 2px 4px rgba(0,0,0,0.1); }
@keyframes fadeIn { from { opacity: 0; transform: translateY(20px); } to { opacity: 1; transform: translateY(0); } }

/* HEADER */
header { background: var(--bg-card); padding: 15px 25px; border-radius: var(--radius); display: flex; justify-content: space-between; align-items: center; border: 1px solid var(--border); margin-bottom: 20px; box-shadow: var(--shadow); backdrop-filter: blur(10px); gap: 25px; }
.app-logo { width: 56px; height: 56px; border-radius: 12px; object-fit: contain; background: var(--bg-input); padding: 4px; border: 1px solid var(--border); box-shadow: 0 2px 5px rgba(0,0,0,0.1); }
.header-info h1 { margin: 0; font-size: 20px; font-weight: 800; letter-spacing: 0.5px; line-height: 1.2; }
.header-info small { font-size: 13px; color: var(--text-muted); font-weight: 600; display: block; margin-top: 4px; }
.btn-header-logout { display: flex; align-items: center; justify-content: center; padding: 8px 20px; background: transparent; border: 2px solid var(--danger); color: var(--danger); font-weight: 700; text-transform: uppercase; font-size: 13px; border-radius: 30px; transition: all 0.2s ease; text-decoration: none; height: 42px; box-sizing: border-box; }
.btn-header-logout:hover { background: var(--danger); color: #fff; box-shadow: 0 4px 10px rgba(220, 53, 69, 0.3); transform: translateY(-1px); }

/* FORMS */
.form-group { margin-bottom: 15px; text-align: left; position: relative; }
.form-group label { display: block; margin-bottom: 5px; font-weight: 600; font-size: 13px; color: var(--text-muted); }
input, select { width: 100%; padding: 12px; padding-right: 35px; background: var(--bg-input); border: 1px solid var(--border); border-radius: 6px; color: var(--text-main); font-size: 14px; box-sizing: border-box; height: 45px; }
input:focus, select:focus { outline: none; border-color: var(--primary); background: var(--bg-card); box-shadow: 0 0 0 3px rgba(138, 180, 248, 0.25); }
.btn { width: 100%; padding: 12px; background: var(--primary); color: var(--text-on-primary); border: none; border-radius: 6px; cursor: pointer; font-weight: 700; font-size: 14px; transition: 0.2s; text-transform: uppercase; letter-spacing: 0.5px; }
.btn:hover { opacity: 0.9; transform: translateY(-1px); box-shadow: 0 4px 10px rgba(0,0,0,0.15); }
.btn-outline { background: transparent; border: 1px solid var(--border); color: var(--text-muted); margin-top: 10px; }
.pass-toggle { position: absolute; right: 12px; top: 38px; cursor: pointer; color: var(--text-muted); z-index: 5; }

/* TABS */
.nav-tabs { display: flex; gap: 8px; margin-bottom: 15px; border-bottom: 2px solid var(--border); overflow-x: auto; }
.nav-tab { padding: 12px 24px; cursor: pointer; font-weight: 700; color: var(--text-muted); border-bottom: 3px solid transparent; transition: all 0.2s; text-transform: uppercase; font-size: 13px; letter-spacing: 0.5px; white-space: nowrap; }
.nav-tab:hover { color: var(--primary); background: rgba(0,0,0,0.02); }
.nav-tab.active { color: var(--primary); border-bottom-color: var(--primary); }
.tab-content { display: none; }
.tab-content.active { display: block; }

/* TABLE */
.table-responsive { overflow-x: auto; background: var(--bg-card); border-radius: var(--radius); border: 1px solid var(--border); }
table { width: 100%; border-collapse: collapse; min-width: 1200px; font-size: 13px; }
th { background: var(--bg-input); color: var(--text-muted); padding: 10px 4px; border: 1px solid var(--border); text-align: center; position: sticky; top: 0; z-index: 10; font-weight: 700; }
td { border: 1px solid var(--border); padding: 0; height: 40px; min-width: 35px; text-align: center; position: relative; vertical-align: middle; }
td input { width: 100%; height: 100%; border: none; background: transparent; text-align: center; font-weight: 700; font-size: 14px; padding: 0; margin: 0; border-radius: 0; text-transform: uppercase; cursor: pointer; display: block; color: var(--text-main); }
td input:focus { background: rgba(var(--primary), 0.1); border: 2px solid var(--primary); cursor: text; outline: none; }

/* COLUMNS */
.fio-col { position: sticky; left: 0; z-index: 20; background: var(--bg-card); text-align: left !important; padding: 5px 12px; width: 180px; min-width: 180px; border-right: 2px solid var(--border); }
th.fio-header { text-align: center !important; }

/* TINY COLUMNS */
.tiny-col { width: 40px; min-width: 40px; max-width: 40px; font-size: 11px; white-space: normal; line-height: 1; padding: 0 !important; }
.tiny-col div { display: flex; align-items: center; justify-content: center; height: 100%; width: 100%; }
.tiny-col input[type="checkbox"] { margin: 0; width: 18px; height: 18px; cursor: pointer; }

/* STATES */
.weekend { background: var(--weekend) !important; color: #fff; }
.weekend input { color: #fff; pointer-events: none; } 
.blocked-red { background: var(--blocked-red) !important; pointer-events: none; opacity: 1; }
.blocked-gray { background: var(--blocked-gray) !important; pointer-events: none; opacity: 0.5; }
.cell-confirmed { background-color: var(--confirmed-blue); }

/* LEGEND & CONTROLS */
.legend-container { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 15px; padding: 15px; background: var(--bg-card); border-radius: var(--radius); border: 1px solid var(--border); }
.draggable-item { padding: 6px 12px; background: var(--bg-input); border: 1px solid var(--border); border-radius: 4px; font-size: 12px; font-weight: 600; cursor: grab; display: flex; align-items: center; gap: 6px; white-space: nowrap; }
.draggable-item:hover { border-color: var(--primary); background: var(--bg-card); transform: translateY(-2px); box-shadow: 0 2px 5px rgba(0,0,0,0.1); }
.draggable-item.item-weekend { background: var(--weekend); color: white; border-color: var(--weekend); }
.filters-bar { display: flex; gap: 10px; align-items: flex-end; flex-wrap: wrap; margin-bottom: 15px; background: var(--bg-card); padding: 15px; border-radius: var(--radius); border: 1px solid var(--border); }
.filter-item { flex: 1; min-width: 150px; }
.filter-item label { display: block; font-size: 12px; color: var(--text-muted); margin-bottom: 4px; font-weight: 600; }

/* USERS & STAFFING LAYOUT FIX */
.users-container { 
    display: flex; 
    flex-direction: row; 
    gap: 20px; 
    align-items: flex-start; 
}
.user-form-card { 
    flex: 0 0 320px; /* Fixed sidebar */
    background: var(--bg-card); 
    padding: 20px; 
    border-radius: var(--radius); 
    border: 1px solid var(--border); 
}
.user-list-card { 
    flex: 1; /* Fluid right side */
    min-width: 0; /* Prevents overflow */
}

/* MEDIA QUERY FOR MOBILE */
@media (max-width: 1000px) {
    .users-container { flex-direction: column; }
    .user-form-card { flex: none; width: 100%; }
    .user-list-card { flex: none; width: 100%; }
}

/* TABLES SPECIFIC */
.compact-table th, .compact-table td { padding: 12px; text-align: left; height: auto; vertical-align: middle; }
.compact-table td.center-text { text-align: center; }
#staffing-table th, #staffing-table td { text-align: center; vertical-align: middle; } 
#staffing-table td:first-child { text-align: left; }
.action-btn-group { display: flex; gap: 8px; justify-content: center; }
.btn-edit { background: var(--primary); color: var(--text-on-primary); padding: 8px 16px; border-radius: 4px; font-size: 12px; font-weight: bold; border: none; cursor: pointer; box-shadow: 0 1px 3px rgba(0,0,0,0.2); }
.btn-delete { background: var(--danger); color: #fff; padding: 8px 16px; border-radius: 4px; font-size: 12px; font-weight: bold; border: none; cursor: pointer; box-shadow: 0 1px 3px rgba(0,0,0,0.2); }
.btn-edit:hover, .btn-delete:hover { opacity: 0.9; transform: translateY(-1px); }

/* THEME SWITCH */
.theme-switch { display: flex; gap: 5px; background: var(--bg-input); padding: 5px; border-radius: 30px; border: 1px solid var(--border); width: fit-content; margin: 0 auto; }
.theme-btn { width: 32px; height: 32px; padding: 0; border-radius: 50%; display: flex; align-items: center; justify-content: center; background: transparent; border: 2px solid transparent; cursor: pointer; font-size: 16px; transition: 0.2s; flex-shrink: 0; }
.theme-btn:hover { background: rgba(0,0,0,0.1); }
.theme-btn.active { background: var(--bg-card) !important; border: 2px solid var(--primary) !important; color: var(--primary) !important; transform: scale(1.15); box-shadow: 0 2px 5px rgba(0,0,0,0.2); }

/* MODAL */
.custom-modal-overlay { position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: var(--modal-overlay); backdrop-filter: blur(5px); display: none; justify-content: center; align-items: center; z-index: 9999; }
.custom-modal-overlay.open { display: flex; }
.custom-modal-box { background: var(--bg-card); padding: 30px; border-radius: 16px; width: 90%; max-width: 400px; box-shadow: 0 20px 50px rgba(0,0,0,0.3); border: 1px solid var(--border); transform: scale(0.9); transition: transform 0.3s; text-align: center; }
.custom-modal-overlay.open .custom-modal-box { transform: scale(1); }
.modal-icon { font-size: 40px; margin-bottom: 15px; }
.modal-title { font-size: 20px; font-weight: 800; margin-bottom: 10px; color: var(--text-main); }
.modal-text { font-size: 14px; color: var(--text-muted); margin-bottom: 25px; line-height: 1.5; }
.modal-actions { display: flex; gap: 10px; justify-content: center; }
.modal-btn { flex: 1; padding: 12px; border-radius: 8px; font-weight: 700; cursor: pointer; border: none; transition: 0.2s; }
.modal-btn-confirm { background: var(--danger); color: #fff; }
.modal-btn-cancel { background: var(--bg-input); color: var(--text-main); border: 1px solid var(--border); }

.hist-item { display: inline-block; padding: 6px 10px; margin: 2px; background: var(--bg-input); border: 1px solid var(--border); border-radius: 6px; font-size: 11px; white-space: normal; text-align: left; line-height: 1.4; max-width: 100%; }
.hist-item .del-hist { color: var(--danger); font-weight: bold; cursor: pointer; margin-left: 6px; padding: 0 4px; }

/* PRINT */
@media print {
    header, .nav-tabs, .filters-bar, .legend-container, .user-form-card, .search-box, .theme-switch, .btn, input[type="checkbox"], .auth-switch-link, .auth-toggle-btn { display: none !important; }
    .container { padding: 0; margin: 0; max-width: 100%; }
    .tab-content { display: none; }
    .tab-content.active { display: block; }
    .table-responsive { border: none; overflow: visible; }
    table { width: 100%; font-size: 9px; min-width: auto; }
    th, td { border: 1px solid #000; padding: 1px; height: 18px; }
    td input { font-size: 9px; color: #000; }
    .fio-col { width: 120px; min-width: 120px; white-space: normal; }
    .weekend { background-color: #ccc !important; color: #000 !important; -webkit-print-color-adjust: exact; }
    .print-header { display: block !important; font-size: 16px; font-weight: bold; margin-bottom: 10px; text-align: center; margin-top: 10px; }
    .blocked-red { background-color: #eee !important; -webkit-print-color-adjust: exact; }
}
.print-header { display: none; }