:root { 
    --c-grey: #cccccc; 
    --c-green: #a7c900; 
    --c-blue: #009ce0; 
    --c-orange: #eb6e00; 
    --c-yellow: #facc00; 
    --c-lightblue: #a8c4d2; 
    --c-magenta: #e3007b;
    --c-termin: #ffc107;
    --glow-termin: rgba(255, 193, 7, 0.4);
    --bg: #eef2f5; 
    --card: #ffffff; 
    --text: #3d4a52; 
    --border: #eef2f5;
}

body { 
    margin: 0; 
    font-family: 'Inter', sans-serif; 
    background: var(--bg); 
    color: var(--text); 
}

.hidden {
    display: none !important;
}

.app-container { 
    display: flex; 
    flex-direction: column; 
    min-height: 100vh; 
}

/* Header & Nav */
header { 
    background: transparent; 
    padding: 20px 30px; 
    display: flex; 
    align-items: center; 
    justify-content: space-between; 
}
.logo-wrapper { 
    display: flex; 
    align-items: center; 
    gap: 15px; 
    font-size: 1.3rem; 
    font-weight: bold; 
    color: var(--c-lightblue); 
    text-transform: uppercase; 
    letter-spacing: 1px;
}
.css-logo { 
    display: grid; 
    grid-template-columns: repeat(3, 8px); 
    gap: 3px; 
}
.css-logo span { display: block; width: 8px; height: 8px; border-radius: 50%; background: var(--c-grey); }
.css-logo span:nth-child(2) { background: var(--c-green); }
.css-logo span:nth-child(3) { background: var(--c-blue); }
.css-logo span:nth-child(4) { background: var(--c-orange); }
.css-logo span:nth-child(8) { background: var(--c-yellow); }
.css-logo span:nth-child(10) { background: var(--c-lightblue); }
.css-logo span:nth-child(11) { background: var(--c-magenta); }

nav { 
    background: var(--card); 
    padding: 5px; 
    border-radius: 10px; 
    box-shadow: 0 2px 10px rgba(0,0,0,0.03); 
    display: flex;
    gap: 5px;
}
nav a { 
    text-decoration: none; 
    padding: 8px 20px; 
    color: #888; 
    border-radius: 6px; 
    font-weight: bold; 
    display: inline-block; 
    transition: all 0.2s ease;
}
nav a:hover {
    background: rgba(168, 196, 210, 0.2);
    color: var(--text);
}
nav a.active { 
    background: var(--c-lightblue); 
    color: white; 
}

.user-menu {
    display: flex;
    align-items: center;
    gap: 15px;
}
.user { font-weight: 600; color: #888; }
.btn-logout {
    text-decoration: none;
    color: var(--c-magenta);
    font-size: 0.9rem;
    font-weight: 600;
}
.btn-logout:hover { text-decoration: underline; }

.logo-wrapper {
    cursor: pointer;
}

@media (max-width: 768px) {
    #info-modal {
        display: none !important;
    }
    .logo-wrapper {
        cursor: default;
        pointer-events: none;
    }
}

main { padding: 0 30px 30px 30px; flex: 1; }

.card { 
    background: var(--card); 
    border-radius: 12px; 
    padding: 25px; 
    box-shadow: 0 4px 15px rgba(168, 196, 210, 0.2); 
    margin-bottom: 20px;
    overflow-x: auto !important;
}

.toolbar { display: flex; gap: 15px; margin-bottom: 20px; align-items: center; }
input, select, button {
    box-sizing: border-box;
    font-family: inherit;
}
input[type="text"], input[type="password"], input[type="date"], input[type="time"], input[type="month"], input[type="number"], select { 
    padding: 10px 15px; 
    border: 1px solid var(--c-lightblue); 
    border-radius: 6px; 
    outline: none; 
    font-family: inherit; 
    color: var(--text); 
    background: white;
}
input:focus, select:focus { background: #f0f5f8; border-color: var(--c-blue); }

.btn-primary { 
    background: var(--c-lightblue); 
    color: white; 
    border: none; 
    padding: 10px 25px; 
    border-radius: 6px; 
    cursor: pointer; 
    font-weight: bold; 
    font-family: inherit; 
    transition: background 0.2s;
}
.btn-primary:hover { background: #96b5c4; }

.btn-secondary {
    background: var(--border);
    color: var(--text);
    border: none;
    padding: 10px 15px;
    border-radius: 6px;
    cursor: pointer;
    font-weight: bold;
    text-decoration: none;
}
.btn-secondary:hover { background: #dce3e8; }

/* Matrix Table */
.shift-matrix-container {
    overflow-x: auto;
}
.shift-matrix { 
    width: 100%; 
    border-collapse: collapse; 
    font-size: 0.9rem;
}
.shift-matrix th, .shift-matrix td { 
    border: 1px solid var(--border); 
    padding: 8px 10px; 
    text-align: center; 
    min-width: var(--cell-width, 30px);
    width: var(--cell-width, 30px);
    max-width: var(--cell-width, 30px);
    position: relative;
    box-sizing: border-box;
}
/* Reduce height for time rows */
.shift-matrix td.time-row {
    height: 18px; /* Narrower rows */
    padding: 2px 10px;
}
.shift-matrix th { 
    border-bottom: 2px solid var(--c-lightblue); 
    background: #fafbfc;
    font-weight: 600;
}
.time-col {
    background-color: #f0f5f8;
    font-weight: bold;
    position: sticky;
    left: 0;
    z-index: 2;
    text-align: left;
    padding-left: 10px;
    border-right: 2px solid var(--c-lightblue) !important;
    transition: color 0.2s ease, font-weight 0.2s ease;
}

.time-col-right {
    background-color: #f0f5f8;
    font-weight: bold;
    position: sticky;
    right: 0;
    z-index: 2;
    text-align: left;
    padding-left: 10px;
    border-left: 2px solid var(--c-lightblue) !important;
    transition: color 0.2s ease, font-weight 0.2s ease;
}

.shift-matrix tbody tr:hover > td.time-col,
.shift-matrix tbody tr:hover > td.time-col-right {
    color: #000000 !important;
    font-weight: 900 !important;
}

.day-start {
    border-left: 2px solid var(--c-lightblue) !important;
    max-width: none !important;
}
.shift-matrix th.time-col, .shift-matrix td.time-col, .shift-matrix th.time-col-right, .shift-matrix td.time-col-right {
    text-align: left;
    width: 80px !important;
    min-width: 80px !important;
    max-width: none !important;
    background: #fafbfc;
    font-weight: 600;
    color: #666;
}
/* Thicker line above 06:00 */
.shift-matrix td.thick-top {
    border-top: 3px solid var(--c-lightblue);
}

.shift-matrix tbody td.cell {
    cursor: cell;
    user-select: none;
    transition: transform 0.1s;
}
.shift-matrix tbody td.cell:hover {
    box-shadow: inset 0 0 0 2px var(--c-blue);
}
.shift-matrix tbody td.cell.selected {
    color: white;
    font-weight: bold;
}

/* Header inputs for Effektive, Nacht, Pikett etc */
.top-row { background: #fdfdfd; }
.top-row td { font-weight: bold; color: #555; }
.input-cell.full-size {
    width: 100%;
    height: 100%;
    text-align: center;
    padding: 8px 4px;
    border: none;
    background: transparent;
    font-weight: 600;
    box-sizing: border-box;
    color: var(--text);
    outline: none;
}
.input-cell.full-size:hover, .input-cell.full-size:focus {
    background: white;
    box-shadow: inset 0 0 0 2px var(--c-lightblue);
}

/* Modal */
.modal {
    display: none;
    position: fixed;
    z-index: 10000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0,0,0,0.4);
}
.modal-content {
    background-color: var(--card);
    margin: 15% auto;
    padding: 25px;
    border-radius: 12px;
    width: 100%;
    max-width: 400px;
    box-shadow: 0 4px 25px rgba(0,0,0,0.2);
}
.close {
    color: #aaa;
    float: right;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
}
.close:hover { color: #333; }

/* Toast Notifications */
#toast-container {
    position: fixed;
    top: 20px;
    right: 30px;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 10px;
}
.toast {
    background: var(--c-green);
    color: white;
    padding: 10px 20px;
    border-radius: 4px;
    margin-top: 10px;
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
    animation: fadein 0.3s;
}

@keyframes fadein {
    from { opacity: 0; transform: translateY(-10px); }
    to { opacity: 1; transform: translateY(0); }
}

@media print {
    @page { 
        size: landscape; 
        margin: 0mm;
        margin-right: 3mm; 
    }
    body { 
        font-size: 10px; 
        -webkit-print-color-adjust: exact !important;
        print-color-adjust: exact !important;
    }
    header, .toolbar, .btn-primary, .btn-secondary, #toast-container, .modal {
        display: none !important;
    }
    .app-container {
        padding: 0;
        margin: 0;
        max-width: 100%;
    }
    .card {
        box-shadow: none;
        border: none;
        padding: 0;
        margin: 0;
        overflow:visible !important;
    }
    .shift-matrix-container {
        overflow: visible !important;
    }
    .shift-matrix th, .shift-matrix td {
        border-color: #000;
        color: #000;
        padding: 1px 2px !important;
        font-size: 9px !important;
        white-space: nowrap;
    }
    .shift-matrix input {
        font-size: 9px !important;
    }
    .shift-matrix {
        width: 100%;
        max-width: 100%;
    }
    .time-col-right {
        display: none !important; /* Hide right time col in print to save space */
    }
}

.kontroll-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(350px, 1fr));
    gap: 20px;
}

@media (max-width: 768px) {
    .kontroll-grid {
        grid-template-columns: 1fr;
    }
}
.toast.show {
    transform: translateX(0);
    opacity: 1;
}
.toast.error {
    background: var(--c-magenta);
}

/* Mobile Responsive */
@media (max-width: 768px) {
    header { flex-direction: column; gap: 15px; }
    nav { flex-wrap: wrap; justify-content: center; }
    main { padding: 0 15px 15px 15px; }
}

.paint-mode-active {
    box-shadow: 0 0 15px var(--glow-termin) !important;
    border: 2px solid var(--c-termin) !important;
    transition: box-shadow 0.3s ease, border 0.3s ease;
}
