/* === ALMEA SPA – Standalone CSS === */

:root {
    --c-primary: #32373c;
    --c-primary-light: #454c52;
    --c-primary-bg: #eef1f3;
    --c-brand: #96B41C;
    --c-brand-dark: #7a9516;
    --c-brand-bg: #f4f8e8;
    --c-orange: #E8830C;
    --c-orange-light: #f09520;
    --c-morning: #2d5a8a;
    --c-morning-light: #3670a8;
    --c-fuel: #E8830C;
    --c-fuel-light: #f09520;
    --c-end: #7a9516;
    --c-end-light: #96B41C;
    --c-segments: #00838f;
    --c-segments-light: #0097a7;
    --c-danger: #b71c1c;
    --c-danger-light: #e53935;
    --c-warning: #E8830C;
    --c-text: #1a1a1a;
    --c-text-light: #555;
    --c-text-muted: #8a8a8a;
    --c-border: #d5d8dc;
    --c-bg: #f4f5f7;
    --c-white: #fff;
    --radius: 8px;
    --radius-sm: 5px;
    --shadow: 0 1px 6px rgba(0,0,0,0.07);
    --shadow-lg: 0 4px 16px rgba(0,0,0,0.1);
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    color: var(--c-text);
    background: var(--c-bg);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    -webkit-tap-highlight-color: transparent;
}

/* === SCREENS === */
.screen { min-height: 100vh; }
#screen-login, #screen-units {
    display: flex; align-items: center; justify-content: center;
    background: linear-gradient(160deg, #f0f2f5 0%, var(--c-brand-bg) 100%);
    padding: 20px;
}

/* === NAVBAR === */
.navbar {
    background: var(--c-primary);
    color: var(--c-white);
    padding: 10px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: 0 2px 12px rgba(0,0,0,0.15);
}
.navbar-brand {
    font-weight: 700;
    font-size: 1rem;
    display: flex;
    align-items: center;
    gap: 4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    min-width: 0;
}
/* Burger button */
.burger {
    display: none;
    background: none;
    border: none;
    cursor: pointer;
    padding: 6px;
    flex-shrink: 0;
}
.burger span {
    display: block;
    width: 22px;
    height: 2px;
    background: var(--c-white);
    margin: 5px 0;
    border-radius: 2px;
    transition: all 0.2s;
}
.burger.open span:nth-child(1) { transform: rotate(45deg) translate(5px, 5px); }
.burger.open span:nth-child(2) { opacity: 0; }
.burger.open span:nth-child(3) { transform: rotate(-45deg) translate(5px, -5px); }

/* Navbar menu - desktop: inline, mobile: dropdown */
.navbar-menu {
    display: flex;
    gap: 6px;
    flex-shrink: 0;
}
.navbar-menu a {
    padding: 6px 12px;
    color: var(--c-white);
    text-decoration: none;
    font-size: 0.82rem;
    font-weight: 500;
    border: 1.5px solid rgba(255,255,255,0.3);
    border-radius: var(--radius-sm);
    white-space: nowrap;
    transition: all 0.15s;
}
.navbar-menu a:hover {
    background: rgba(255,255,255,0.12);
    border-color: rgba(255,255,255,0.6);
}

/* Legacy support */
.navbar-actions {
    display: flex;
    gap: 6px;
    flex-shrink: 0;
}

/* === BUTTONS === */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 10px 20px;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s;
    text-decoration: none;
    line-height: 1.3;
    white-space: nowrap;
}
.btn:active { transform: scale(0.97); }

.btn-primary {
    background: var(--c-brand);
    color: var(--c-white);
}
.btn-primary:hover { background: var(--c-brand-dark); }

.btn-outline {
    background: transparent;
    color: var(--c-white);
    border: 1.5px solid rgba(255,255,255,0.5);
}
.btn-outline:hover { background: rgba(255,255,255,0.12); border-color: rgba(255,255,255,0.8); }

.btn-outline-dark {
    background: transparent;
    color: var(--c-text-light);
    border: 1.5px solid var(--c-border);
}
.btn-outline-dark:hover { border-color: var(--c-primary); color: var(--c-primary); }

.btn-sm {
    padding: 6px 12px;
    font-size: 0.8rem;
}
.btn-block { width: 100%; }

.btn-warning {
    background: var(--c-warning);
    color: var(--c-white);
}

/* === CARDS === */
.card {
    background: var(--c-white);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    overflow: hidden;
    margin-bottom: 16px;
}
.card-header {
    padding: 14px 16px;
    font-weight: 700;
    font-size: 0.95rem;
    display: flex;
    align-items: center;
}
.card-body { padding: 16px; }
.card-footer { padding: 12px 16px; text-align: right; }

/* Section headers */
#header-morning { background: linear-gradient(135deg, var(--c-morning) 0%, var(--c-morning-light) 100%); color: var(--c-white); }
#header-segments { background: linear-gradient(135deg, var(--c-segments) 0%, var(--c-segments-light) 100%); color: var(--c-white); }
#header-fuel { background: linear-gradient(135deg, var(--c-fuel) 0%, var(--c-fuel-light) 100%); color: var(--c-white); }
#header-end { background: linear-gradient(135deg, var(--c-end) 0%, var(--c-end-light) 100%); color: var(--c-white); }

.collapsible { cursor: pointer; user-select: none; }
.collapsible:hover { filter: brightness(0.92); }

/* Completed sections */
.completed { opacity: 0.65; }
.completed:hover { opacity: 0.85; }
.completed .card-header::after {
    content: '\2713 Uloženo';
    font-size: 0.78rem;
    font-weight: 600;
    background: rgba(255,255,255,0.25);
    padding: 3px 12px;
    border-radius: 20px;
    margin-left: auto;
}

/* Collapse icon */
.collapse-icon {
    margin-left: 8px;
    font-size: 0.7rem;
    transition: transform 0.2s;
}
.collapse-icon.open { transform: rotate(180deg); }

/* === FORMS === */
.form-group {
    margin-bottom: 14px;
}
.form-group label {
    display: block;
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--c-text-light);
    text-transform: uppercase;
    letter-spacing: 0.03em;
    margin-bottom: 5px;
}
.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}
.form-row-full {
    display: grid;
    grid-template-columns: 1fr;
    gap: 12px;
}

input[type="text"],
input[type="number"],
input[type="time"],
input[type="date"],
input[type="month"],
input[type="password"],
select,
textarea {
    width: 100%;
    padding: 10px 12px;
    border: 1.5px solid var(--c-border);
    border-radius: var(--radius-sm);
    font-size: 0.95rem;
    font-family: inherit;
    color: var(--c-text);
    background: var(--c-white);
    transition: border-color 0.15s;
    outline: none;
}
input:focus, select:focus, textarea:focus {
    border-color: var(--c-brand);
    box-shadow: 0 0 0 3px rgba(150, 180, 28, 0.15);
}
textarea { resize: vertical; min-height: 80px; }
select { cursor: pointer; }

/* Error state */
input.error, select.error, textarea.error {
    border-color: var(--c-danger) !important;
    box-shadow: 0 0 0 3px rgba(198, 40, 40, 0.1) !important;
}

/* Auto-fill */
.auto-filled { background-color: #fff8e1 !important; border-color: var(--c-warning) !important; }
.auto-fill-note { font-size: 0.82rem; color: var(--c-warning); font-style: italic; margin-top: 6px; }

/* === ALERTS === */
.alert {
    padding: 12px 16px;
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
    font-weight: 500;
}
.alert-danger { background: #ffebee; color: var(--c-danger); border: 1px solid #ffcdd2; }
.alert-success { background: #e8f5e9; color: #2e7d32; border: 1px solid #c8e6c9; }
.alert-warning { background: #fff3e0; color: #e65100; border: 1px solid #ffe0b2; }

/* === ONLINE STATUS === */
.online-status {
    display: inline-block; width: 9px; height: 9px;
    border-radius: 50%; margin-right: 6px; flex-shrink: 0;
}
.online-status.online { background: #69f0ae; box-shadow: 0 0 6px rgba(105, 240, 174, 0.5); }
.online-status.offline { background: var(--c-danger-light); animation: pulse 2s infinite; }
@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.4; }
}

/* === DATE NAVIGATION === */
.date-nav {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 10px;
}
.date-label {
    font-weight: 700;
    font-size: 1.1rem;
    cursor: pointer;
    user-select: none;
    padding: 0 6px;
    min-width: 90px;
    text-align: center;
}
.date-label:hover { color: var(--c-brand); }

/* === UNIT GRID === */
.unit-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 14px;
    max-width: 500px;
    margin: 0 auto 24px;
}
.unit-btn {
    cursor: pointer; padding: 20px 16px; text-align: center;
    border: 2px solid var(--c-border); border-radius: var(--radius);
    transition: all 0.2s; background: var(--c-white);
}
.unit-btn:hover {
    border-color: var(--c-brand);
    box-shadow: var(--shadow-lg);
    transform: translateY(-2px);
}
.unit-name { display: block; font-weight: 700; font-size: 1rem; margin-bottom: 6px; color: var(--c-primary); }
.unit-btn:hover .unit-name { color: var(--c-brand); }
.unit-stredisko {
    font-size: 0.8rem; color: var(--c-text-muted);
    background: var(--c-bg); padding: 3px 10px; border-radius: 20px;
    display: inline-block;
}

/* === FUEL === */
.fuel-item { padding: 12px 0; border-bottom: 1px solid #eee; }
.fuel-item:last-child { border-bottom: none; }
.fuel-item-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.fuel-label { font-weight: 600; font-size: 0.88rem; color: var(--c-text-light); }
.fuel-total { font-weight: 700; color: var(--c-orange); font-size: 0.9rem; }
.fuel-entry-row { display: flex; gap: 8px; align-items: center; margin-bottom: 6px; }
.fuel-entry-row input[type="number"] { flex: 1; }
.fuel-entry-row input[type="time"] { width: 120px; flex-shrink: 0; }

.btn-add-fuel {
    background: none; border: 2px dashed var(--c-border); color: var(--c-brand);
    font-size: 0.83rem; font-weight: 600; cursor: pointer;
    padding: 8px; margin-top: 6px; border-radius: var(--radius-sm);
    width: 100%; transition: all 0.15s;
}
.btn-add-fuel:hover { border-color: var(--c-primary); background: var(--c-primary-bg); }
.btn-remove-fuel {
    background: var(--c-danger-light); color: var(--c-white); border: none;
    border-radius: 50%; width: 28px; height: 28px; font-size: 1rem;
    cursor: pointer; display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.btn-remove-fuel:hover { background: var(--c-danger); }

/* === SEGMENTS === */
.segments-hint { font-size: 0.82rem; color: var(--c-text-muted); margin-bottom: 12px; }
.segment-row {
    padding: 12px;
    border: 1.5px solid var(--c-border);
    border-radius: var(--radius);
    margin-bottom: 10px;
    background: #fafafa;
}
.segment-row-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
}
.segment-row-title {
    font-weight: 700;
    font-size: 0.88rem;
    color: var(--c-segments);
}
.btn-remove-segment {
    background: var(--c-danger-light); color: var(--c-white); border: none;
    border-radius: 50%; width: 28px; height: 28px; font-size: 1rem;
    cursor: pointer; display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.btn-remove-segment:hover { background: var(--c-danger); }

/* === MTH PHOTOS === */
.mth-field-row { display: flex; gap: 8px; align-items: flex-start; }
.mth-field-row input { flex: 1; }
.mth-field-wrap { flex: 1; }
.btn-mth-photo {
    background: none; border: 1.5px solid var(--c-border);
    border-radius: var(--radius-sm); cursor: pointer;
    width: 42px; height: 42px; display: flex;
    align-items: center; justify-content: center; flex-shrink: 0;
    color: var(--c-text-muted); font-size: 1.2rem;
    transition: all 0.15s;
}
.btn-mth-photo:hover { border-color: var(--c-brand); color: var(--c-brand); }
.mth-photo-preview { margin-top: 4px; display: flex; gap: 4px; flex-wrap: wrap; }
.mth-photo-thumb {
    width: 48px; height: 48px; object-fit: cover;
    border-radius: 4px; border: 1px solid #ddd; cursor: pointer;
}
.mth-photo-item { position: relative; display: inline-block; }
.mth-photo-delete {
    position: absolute; top: -6px; right: -6px;
    background: var(--c-danger); color: #fff; border: none;
    border-radius: 50%; width: 20px; height: 20px;
    font-size: 0.7rem; cursor: pointer;
    display: flex; align-items: center; justify-content: center;
}
.photo-pending { opacity: 0.6; border-color: var(--c-warning); }

/* === VERSION LABEL === */
.app-version-label {
    position: fixed;
    bottom: 6px;
    right: 10px;
    font-size: 0.72rem;
    color: var(--c-text-light);
    opacity: 0.5;
    pointer-events: none;
    z-index: 1;
}

/* === WAREHOUSE === */
.warehouse-options { display: flex; flex-wrap: wrap; gap: 10px; }
.warehouse-option { display: flex; align-items: center; gap: 6px; flex: 1; min-width: 100px; }
.warehouse-option input[type="radio"] { display: none; }
.warehouse-option label {
    display: block; padding: 10px 12px; text-align: center;
    border: 2px solid var(--c-border); border-radius: var(--radius-sm); cursor: pointer;
    font-weight: 600; font-size: 0.85rem; transition: all 0.15s;
    background: var(--c-white); width: 100%;
}
.warehouse-option label:hover { border-color: var(--c-brand); background: var(--c-brand-bg); }
.warehouse-option input:checked + label {
    border-color: var(--c-brand); background: var(--c-brand-bg); color: var(--c-brand);
    box-shadow: 0 0 0 2px rgba(44, 95, 45, 0.12);
}

/* === SYNC BAR === */
.sync-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
}

/* === TOAST === */
#toast {
    position: fixed;
    bottom: 24px;
    left: 50%; transform: translateX(-50%);
    z-index: 9000;
    min-width: 280px; max-width: 90vw;
    text-align: center;
    animation: toastIn 0.3s ease;
    box-shadow: var(--shadow-lg);
    border-radius: var(--radius-sm);
}
#toast.hidden { display: none; }
@keyframes toastIn {
    from { transform: translateX(-50%) translateY(16px); opacity: 0; }
    to { transform: translateX(-50%) translateY(0); opacity: 1; }
}

/* === MAIN CONTENT === */
.main-content {
    max-width: 600px;
    margin: 0 auto;
    padding: 16px 14px 40px;
}

/* === LOGIN === */
.login-box {
    width: 100%;
    max-width: 380px;
}
.login-title {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--c-primary);
    text-align: center;
    margin-bottom: 4px;
    letter-spacing: 0.02em;
}
.login-subtitle {
    text-align: center;
    color: var(--c-text-muted);
    margin-bottom: 24px;
    font-size: 0.9rem;
}

/* === ADMIN === */
.admin-tabs {
    display: flex;
    gap: 4px;
    margin-bottom: 16px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}
.admin-tab {
    padding: 8px 16px;
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
    font-weight: 600;
    text-decoration: none;
    color: var(--c-text-light);
    background: var(--c-white);
    border: 1.5px solid var(--c-border);
    white-space: nowrap;
    transition: all 0.15s;
}
.admin-tab:hover { border-color: var(--c-primary); color: var(--c-primary); }
.admin-tab.active {
    background: var(--c-primary);
    color: var(--c-white);
    border-color: var(--c-primary);
}
.admin-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin-bottom: 16px;
}
.admin-card {
    background: var(--c-white);
    border-radius: var(--radius);
    padding: 14px;
    box-shadow: var(--shadow);
}
.admin-card-title {
    font-weight: 700;
    font-size: 0.9rem;
    margin-bottom: 6px;
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}
.admin-table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.admin-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.88rem;
}
.admin-table th {
    text-align: left;
    padding: 8px 10px;
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--c-text-light);
    text-transform: uppercase;
    letter-spacing: 0.03em;
    border-bottom: 2px solid var(--c-border);
    white-space: nowrap;
}
.admin-table td {
    padding: 8px 10px;
    border-bottom: 1px solid #f0f0f0;
    vertical-align: middle;
}
.admin-table tbody tr:hover { background: #fafafa; }

/* Badges */
.badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 600;
    white-space: nowrap;
}
.badge-green { background: #e8f5e9; color: #2e7d32; }
.badge-blue { background: #e3f2fd; color: #1565c0; }
.badge-orange { background: #fff3e0; color: #e65100; }
.badge-gray { background: #f3f4f6; color: #9ca3af; }
.badge-red { background: #ffebee; color: #b71c1c; }

/* Unit chips */
.unit-chip {
    display: inline-block;
    padding: 3px 8px;
    border-radius: 4px;
    font-size: 0.78rem;
    font-weight: 600;
    cursor: pointer;
    border: 1.5px solid var(--c-border);
    background: var(--c-white);
    color: var(--c-text-light);
    margin: 1px;
    transition: all 0.15s;
}
.unit-chip:hover { border-color: var(--c-primary); }
.unit-chip.active {
    background: var(--c-primary-bg);
    color: var(--c-primary);
    border-color: var(--c-primary);
}

.btn-danger {
    background: var(--c-danger);
    color: var(--c-white);
    border: none;
}
.btn-danger:hover { background: var(--c-danger-light); }

h3 { font-size: 1.05rem; color: var(--c-text); }

details > summary { list-style: none; }
details > summary::-webkit-details-marker { display: none; }

/* === RESPONSIVE === */
@media (max-width: 600px) {
    .main-content { padding: 10px 8px 32px; }
    .unit-grid { grid-template-columns: 1fr; }
    .form-row { grid-template-columns: 1fr; }
    .navbar { padding: 8px 10px; }
    .navbar-brand { font-size: 0.9rem; }
    .btn-sm { padding: 5px 8px; font-size: 0.75rem; }
    .warehouse-options { gap: 6px; }

    /* Burger menu on mobile */
    .burger { display: block; }
    .navbar-menu {
        display: none;
        position: absolute;
        top: 100%;
        right: 0;
        left: 0;
        background: var(--c-primary);
        flex-direction: column;
        padding: 8px 12px 12px;
        gap: 2px;
        box-shadow: 0 4px 16px rgba(0,0,0,0.2);
        z-index: 99;
    }
    .navbar-menu.open { display: flex; }
    .navbar-menu a {
        border: none;
        padding: 10px 12px;
        border-radius: var(--radius-sm);
        font-size: 0.9rem;
    }
    .navbar-menu a:hover { background: rgba(255,255,255,0.1); }
    .navbar { position: relative; }

    .admin-grid { grid-template-columns: 1fr; }
    .admin-table { font-size: 0.82rem; }
    .admin-table th, .admin-table td { padding: 6px 8px; }
}
