/**
 * styles.css - Stylesheet für den Camviewer
 */

:root {
    --bg: #0f0f0f;
    --panel: #1a1a1a;
    --panel-2: #141414;
    --text: #efefef;
    --muted: #9a9a9a;
    --accent: #007bff;
    --border: #2d2d2d;
    --danger: #d9534f;
    --shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
}

* { 
    box-sizing: border-box; 
}

body {
    margin: 0;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: var(--bg);
    color: var(--text);
}

#login-overlay {
    position: fixed;
    inset: 0;
    background: var(--bg);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
}

#login-box {
    background: var(--panel);
    padding: 40px;
    border-radius: 12px;
    text-align: center;
    width: 320px;
    box-shadow: var(--shadow);
    border: 1px solid var(--border);
}

#login-box h3 { 
    margin-top: 0; 
    color: var(--accent); 
}

#login-box input {
    padding: 12px;
    margin: 10px 0;
    border-radius: 6px;
    border: 1px solid #444;
    background: #222;
    color: white;
    width: 100%;
}

#login-box button {
    padding: 12px;
    background: var(--accent);
    border: none;
    color: white;
    border-radius: 6px;
    cursor: pointer;
    width: 100%;
    font-weight: bold;
    font-size: 1em;
}

#app-container {
    min-height: 100vh;
    flex-direction: column;
}

#topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 14px 18px;
    background: var(--panel);
    border-bottom: 1px solid var(--border);
}

.topbar-left, .topbar-center, .topbar-right {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

.filter-group {
    display: flex;
    align-items: center;
    gap: 6px;
    background: #111;
    padding: 4px 8px;
    border-radius: 6px;
    border: 1px solid var(--border);
}

.filter-label {
    font-size: 0.75em;
    color: var(--muted);
    font-weight: 600;
    text-transform: uppercase;
    margin-right: 2px;
}

.btn-filter {
    padding: 5px 10px;
    font-size: 0.8em;
    opacity: 0.4;
    transition: all 0.2s ease;
    background: #2a2a2a;
    color: var(--text);
    border: 1px solid #3b3b3b;
    border-radius: 4px;
    cursor: pointer;
}

.btn-filter:hover {
    opacity: 0.8;
    border-color: var(--accent);
}

.btn-filter.active {
    opacity: 1;
    background: var(--accent);
    color: #fff;
    border-color: var(--accent);
    font-weight: 600;
}

.is-hidden {
    display: none !important;
}

.refresh-select {
    background: #2a2a2a;
    color: var(--text);
    border: 1px solid #3b3b3b;
    border-radius: 6px;
    padding: 8px 10px;
    cursor: pointer;
    font-size: 0.9em;
}

#archive-date-label { 
    font-weight: 600; 
}

.btn {
    background: #2a2a2a;
    color: var(--text);
    border: 1px solid #3b3b3b;
    border-radius: 6px;
    padding: 10px 12px;
    cursor: pointer;
    transition: background 0.2s, border-color 0.2s;
}

.btn:hover { 
    background: #343434; 
    border-color: var(--accent); 
}

.btn-primary { 
    background: var(--accent); 
    border-color: var(--accent); 
    color: #fff; 
}

.btn-primary:hover { 
    background: #0069d9; 
}

.link-btn { 
    color: #bbb; 
    text-decoration: none; 
    font-size: 0.9em; 
}

.link-btn:hover { 
    color: #fff; 
}

.modal-overlay {
    position: fixed;
    inset: 0;
    background: #000;
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 2000;
    padding: 0;
}

.modal-overlay.active { 
    display: flex; 
}

.modal-box {
    width: 100vw;
    height: 100vh;
    max-width: 100vw;
    max-height: 100vh;
    background: #000;
    border: none;
    border-radius: 0;
    box-shadow: none;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 10px 16px;
    background: rgba(20, 20, 20, 0.85);
    border-bottom: 1px solid var(--border);
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    z-index: 10;
}

.modal-title { 
    font-weight: 700; 
    overflow: hidden; 
    text-overflow: ellipsis; 
    white-space: nowrap; 
}

.modal-close { 
    min-width: 44px; 
    font-size: 1.1em; 
    line-height: 1; 
}

.modal-body {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    height: 100%;
    padding: 0;
    position: relative;
}

.modal-nav-group {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    z-index: 10;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.modal-nav-group-left {
    left: 16px;
}

.modal-nav-group-right {
    right: 16px;
}

.modal-nav {
    height: 48px;
    width: 54px;
    padding: 0;
    background: #2a2a2a;
    border: 1px solid #444444;
    color: #ffffff;
    font-size: 1.1em;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    border-radius: 6px;
    transition: background 0.2s, border-color 0.2s;
    user-select: none;
}

.modal-nav:hover {
    background: #3d3d3d;
    border-color: var(--accent);
}

.modal-image-wrap {
    flex: 1;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #000;
    border-radius: 0;
    overflow: hidden;
    min-height: 100vh;
    max-height: 100vh;
    position: relative;
    user-select: none;
}

.modal-image {
    max-width: 100vw;
    max-height: 100vh;
    object-fit: contain;
    background: #000;
    transform-origin: center center;
    transition: transform 0.05s ease-out;
    cursor: grab;
}

.modal-image:active {
    cursor: grabbing;
}

.modal-footer {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 16px;
    background: rgba(20, 20, 20, 0.85);
    color: var(--muted);
    font-size: 0.85em;
    z-index: 10;
}

#main-view {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
    padding: 12px;
    background: #000;
    transition: grid-template-columns 0.2s ease;
}

#calendar-controls {
    padding: 10px 12px 8px;
    background: #111;
    border-bottom: 1px solid var(--border);
}

.calendar-shell { 
    width: 100%; 
}

.archive-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
    margin-bottom: 10px;
}

.cam-column { 
    min-width: 0; 
}

.cam-container {
    position: relative;
    height: 42vh;
    min-height: 280px;
    display: flex;
    justify-content: center;
    align-items: center;
    background: #111;
    border-radius: 10px;
    overflow: hidden;
    border: 1px solid #222;
}

.cam-container img { 
    width: 100%; 
    height: 100%; 
    object-fit: contain; 
    background: #000; 
    cursor: pointer; 
}

.status-badge {
    position: absolute;
    top: 12px; left: 12px; right: 12px;
    background: rgba(0, 0, 0, 0.72);
    padding: 8px 12px;
    border-radius: 6px;
    font-size: 0.9em;
    z-index: 5;
    border-left: 4px solid var(--accent);
}

#archive-panel {
    flex: 1;
    min-height: 0;
    background: var(--panel);
    border-top: 1px solid var(--border);
    display: flex;
    flex-direction: column;
}

.calendar-nav { 
    display: flex; 
    justify-content: space-between; 
    align-items: center; 
    margin-bottom: 8px; 
    gap: 8px; 
}

#month-label { 
    font-weight: bold; 
    text-align: center; 
    flex: 1; 
    font-size: 0.95em; 
}

.calendar-grid { 
    display: flex; 
    flex-wrap: wrap; 
    gap: 6px; 
}

.cal-day {
    min-height: 32px;
    min-width: 80px;
    padding: 6px 10px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    background: var(--panel-2);
    font-size: 0.8em;
    border: 1px solid #2a2a2a;
    border-radius: 999px;
    cursor: pointer;
    transition: 0.2s;
    white-space: nowrap;
}

.cal-day:hover { 
    background: #333; 
    color: var(--accent); 
    border-color: #3b3b3b; 
}

.cal-day.has-data { 
    background: #1d2730; 
    color: #dbeafe; 
    border-color: #35536b; 
}

.cal-day-label { 
    display: inline-flex; 
    align-items: center; 
    justify-content: center; 
}

.cal-day-markers { 
    display: inline-flex; 
    align-items: center; 
    gap: 3px; 
    flex: 0 0 auto; 
}

.cal-day-marker { 
    width: 6px; 
    height: 6px; 
    border-radius: 50%; 
    border: 1px solid #7cc4ff; 
    background: transparent; 
}

.cal-day-marker.has-data { 
    background: #7cc4ff; 
}

.cal-day.today { 
    color: var(--accent); 
    font-weight: bold; 
}

.cal-day.selected { 
    background: var(--accent); 
    color: #fff; 
    font-weight: bold; 
    border-color: var(--accent); 
}

.cal-day.selected .cal-day-marker { 
    border-color: #fff; 
}

.cal-day.selected .cal-day-marker.has-data { 
    background: #fff; 
}

#archive-content { 
    flex: 1; 
    overflow-y: auto; 
    padding: 16px 18px 22px; 
}

.empty-state {
    color: var(--muted);
    text-align: center;
    padding: 30px 12px;
    border: 1px dashed #3c3c3c;
    border-radius: 10px;
    background: #151515;
}

.error-state {
    color: var(--danger);
    text-align: left;
    padding: 16px;
    border: 1px solid var(--danger);
    border-radius: 8px;
    background: #2a1515;
    font-family: monospace;
    font-size: 0.85em;
    white-space: pre-wrap;
    word-break: break-all;
}

.hour-block { 
    margin-bottom: 20px; 
    border: 1px solid var(--border); 
    border-radius: 10px; 
    overflow: hidden; 
    background: #151515; 
}

.hour-toggle { 
    display: block; 
}

.hour-toggle summary {
    list-style: none;
    cursor: pointer;
    padding: 10px 14px;
    background: #202020;
    border-bottom: 1px solid var(--border);
    font-weight: 700;
    letter-spacing: 0.02em;
    user-select: none;
    position: relative;
    padding-right: 42px;
}

.hour-toggle summary::-webkit-details-marker { 
    display: none; 
}

.hour-toggle summary::after {
    content: '▸';
    position: absolute;
    right: 14px; top: 50%;
    transform: translateY(-50%);
    transition: transform 0.2s ease;
    color: var(--muted);
}

.hour-toggle[open] summary::after { 
    transform: translateY(-50%) rotate(90deg); 
}

.hour-toggle[open] summary { 
    border-bottom: 1px solid var(--border); 
}

.hour-grid { 
    display: grid; 
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); 
    gap: 1px; 
    background: var(--border); 
}

.camera-section { 
    padding: 12px; 
    min-width: 0; 
    background: #151515; 
}

.camera-title { 
    font-size: 0.95em; 
    font-weight: 700; 
    margin-bottom: 10px; 
}

.thumb-grid { 
    display: grid; 
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); 
    gap: 10px; 
}

.thumb-item {
    position: relative;
    cursor: pointer;
    background: #000;
    border-radius: 6px;
    overflow: hidden;
    border: 2px solid transparent;
    transition: border-color 0.2s, transform 0.2s;
}

.thumb-item:hover { 
    border-color: var(--accent); 
    transform: translateY(-1px); 
}

.thumb-item img { 
    width: 100%; 
    display: block; 
    aspect-ratio: 16 / 9; 
    object-fit: cover; 
}

.thumb-time {
    position: absolute; left: 0; right: 0; bottom: 0;
    background: rgba(0, 0, 0, 0.72);
    font-size: 0.75em; text-align: center; padding: 4px 6px;
}

.thumb-name {
    position: absolute; left: 0; right: 0; top: 0;
    background: rgba(0, 0, 0, 0.78);
    font-size: 0.68em; line-height: 1.25; text-align: center;
    padding: 4px 6px; color: #ddd; opacity: 0;
    transition: opacity 0.2s ease; pointer-events: none;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

.thumb-item:hover .thumb-name { 
    opacity: 1; 
}

.camera-empty { 
    color: #666; 
    font-size: 0.9em; 
    padding: 10px 0; 
}

@media (max-width: 1200px) {
    #main-view { grid-template-columns: 1fr !important; }
    .cam-container { height: 30vh; }
}

@media (max-width: 640px) {
    #topbar { flex-direction: column; align-items: flex-start; }
    .thumb-grid { grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); }
    .calendar-grid { font-size: 0.9em; }
}