@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&display=swap');

/* =====================================================================
   DESIGN TOKENS
=====================================================================*/
:root {
    --primary: #2563eb;
    --primary-hover: #1d4ed8;
    --primary-glow: rgba(37,99,235,0.25);
    --accent: #f43f5e;
    --success: #10b981;
    --warning: #f59e0b;
    --error: #ef4444;
    --info: #06b6d4;

    --bg-light: #f6f7fb;
    --bg-dark: #060608;
    --card-light: rgba(255,255,255,0.92);
    --card-dark: rgba(14,14,18,0.85);
    --border-light: rgba(220,225,235,0.9);
    --border-dark: rgba(40,40,55,0.9);
    --text-light: #0f172a;
    --text-dark: #e8eaf0;

    --radius-lg: 20px;
    --radius-md: 12px;
    --radius-sm: 8px;
    --shadow-sm: 0 1px 3px 0 rgb(0 0 0 / 0.07);
    --shadow: 0 4px 16px -2px rgb(0 0 0 / 0.10), 0 2px 6px -2px rgb(0 0 0 / 0.06);
    --shadow-lg: 0 20px 40px -8px rgb(0 0 0 / 0.12), 0 8px 16px -4px rgb(0 0 0 / 0.08);
    --glass-blur: 24px;
    --transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

[data-theme="light"] {
    --bg: var(--bg-light);
    --card: var(--card-light);
    --border: var(--border-light);
    --text: var(--text-light);
    --text-muted: rgba(15,23,42,0.55);
    --input-bg: #ffffff;
}
[data-theme="dark"] {
    --bg: var(--bg-dark);
    --card: var(--card-dark);
    --border: var(--border-dark);
    --text: var(--text-dark);
    --text-muted: rgba(232,234,240,0.5);
    --input-bg: rgba(255,255,255,0.04);
}

/* =====================================================================
   RESET & BASE
=====================================================================*/
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }

body {
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    overflow-x: hidden;
    -webkit-tap-highlight-color: transparent;
    transition: background-color 0.4s ease, color 0.4s ease;
    padding-bottom: env(safe-area-inset-bottom);
}

/* Background gradient */
[data-theme="light"] body::before {
    content: '';
    position: fixed;
    inset: 0;
    background: radial-gradient(ellipse 80% 60% at 50% -10%, rgba(37,99,235,0.08) 0%, transparent 60%);
    pointer-events: none;
    z-index: 0;
}
[data-theme="dark"] body::before {
    content: '';
    position: fixed;
    inset: 0;
    background: radial-gradient(ellipse 80% 60% at 50% -10%, rgba(37,99,235,0.12) 0%, transparent 60%);
    pointer-events: none;
    z-index: 0;
}

/* =====================================================================
   LAYOUT
=====================================================================*/
.app-container {
    max-width: 820px;
    margin: 0 auto;
    padding: 20px;
    position: relative;
    z-index: 1;
}

header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 0;
    margin-bottom: 28px;
    position: sticky;
    top: 0;
    z-index: 100;
    background: transparent;
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
}

.logo-container img { height: 40px; }
.login-logo { display: block; margin: 0 auto; border: none !important; box-shadow: none !important; }

/* =====================================================================
   GLASS CARD
=====================================================================*/
.glass {
    background: var(--card);
    backdrop-filter: blur(var(--glass-blur));
    -webkit-backdrop-filter: blur(var(--glass-blur));
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    transition: var(--transition);
}
.glass:hover { box-shadow: var(--shadow-lg); }

/* =====================================================================
   BUTTONS
=====================================================================*/
.btn {
    padding: 10px 20px;
    border-radius: var(--radius-sm);
    border: none;
    font-weight: 600;
    font-size: 0.9rem;
    cursor: pointer;
    transition: var(--transition);
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-family: inherit;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-hover) 100%);
    color: white;
    box-shadow: 0 4px 12px var(--primary-glow);
}
.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 24px var(--primary-glow);
}
.btn-primary:active { transform: translateY(0); }

.btn-ghost {
    background: rgba(128,128,128,0.06);
    color: var(--text);
    border: 1px solid var(--border);
}
.btn-ghost:hover {
    background: var(--border);
    transform: translateY(-1px);
}

.back-btn { margin-bottom: 20px; }

/* =====================================================================
   FORMS
=====================================================================*/
.form-group { margin-bottom: 18px; }
.form-row-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.form-row-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 14px; }

label {
    display: block;
    margin-bottom: 7px;
    font-size: 0.82rem;
    font-weight: 600;
    letter-spacing: 0.02em;
    color: var(--text-muted);
    text-transform: uppercase;
}

input, select, textarea {
    width: 100%;
    padding: 12px 16px;
    border-radius: var(--radius-md);
    border: 1.5px solid var(--border);
    background: var(--input-bg);
    color: var(--text);
    font-family: inherit;
    font-size: 0.95rem;
    outline: none;
    transition: var(--transition);
    -webkit-appearance: none;
    appearance: none;
}
select {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 40px;
}
input:focus, select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-glow);
    background: var(--input-bg);
}

.divider-or {
    text-align: center;
    margin: 20px 0;
    color: var(--text-muted);
    font-size: 0.8rem;
    font-weight: 500;
    letter-spacing: 0.05em;
}

/* =====================================================================
   DASHBOARD GRID
=====================================================================*/
.dashboard-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

.dash-card {
    padding: 24px 20px;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    gap: 8px;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}
.dash-card:hover { transform: translateY(-4px); }
.dash-card:active { transform: translateY(-1px); }

.dash-icon {
    margin-bottom: 4px;
    width: 48px;
    height: 48px;
    border-radius: 12px;
    background: rgba(128,128,128,0.06);
    display: flex;
    align-items: center;
    justify-content: center;
}

.dash-card h3 { font-size: 1.05rem; font-weight: 700; }
.dash-card p { font-size: 0.82rem; color: var(--text-muted); line-height: 1.4; }

/* =====================================================================
   WIZARD COMPONENTS
=====================================================================*/
.wizard-header { margin-bottom: 28px; }

.wizard-steps {
    display: flex;
    align-items: flex-start;
    justify-content: center;
    margin-bottom: 16px;
}

.step-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    min-width: 70px;
}

.step-circle {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.9rem;
    border: 2px solid var(--border);
    background: var(--card);
    color: var(--text-muted);
    transition: var(--transition);
}

.step-item.active .step-circle {
    background: linear-gradient(135deg, var(--primary), var(--primary-hover));
    border-color: var(--primary);
    color: white;
    box-shadow: 0 4px 16px var(--primary-glow);
}

.step-item.completed .step-circle {
    background: var(--success);
    border-color: var(--success);
    color: white;
}

.step-label {
    font-size: 0.72rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    transition: var(--transition);
}
.step-item.active .step-label, .step-item.completed .step-label { color: var(--text); }

.step-connector {
    flex: 1;
    height: 2px;
    background: var(--border);
    margin: 0 8px;
    margin-top: 20px;
    transition: var(--transition);
    border-radius: 2px;
}
.step-connector.active { background: var(--primary); }
.step-connector.completed { background: var(--success); }

.wizard-card { padding: 28px; margin-bottom: 16px; }

.section-title {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 1.1rem;
    font-weight: 700;
    margin-bottom: 20px;
    color: var(--text);
}
.section-title svg { opacity: 0.6; }

.customer-chip {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 6px 14px;
    border-radius: 30px;
    background: rgba(37,99,235,0.08);
    border: 1px solid rgba(37,99,235,0.2);
    color: var(--primary);
    font-size: 0.82rem;
    font-weight: 600;
    margin-top: 12px;
}

.selected-customer-badge {
    padding: 14px 18px;
    border-radius: var(--radius-md);
    background: rgba(16,185,129,0.08);
    border: 1px solid rgba(16,185,129,0.25);
    color: var(--success);
    font-size: 0.9rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 10px;
}

/* =====================================================================
   ITEMS LIST
=====================================================================*/
.order-item-card {
    background: rgba(128,128,128,0.03);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 16px;
    margin-bottom: 12px;
    transition: var(--transition);
}
.order-item-card .item-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 12px;
}
.item-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.03em;
    text-transform: uppercase;
}
.badge-IDA { background: rgba(37,99,235,0.1); color: var(--primary); }
.badge-Maska { background: rgba(168,85,247,0.1); color: #8b5cf6; }
.badge-Tlačna { background: rgba(6,182,212,0.1); color: var(--info); }

/* =====================================================================
   SERVICE CHECKBOXES
=====================================================================*/
.services-label {
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    color: var(--text-muted);
    margin-bottom: 10px;
    margin-top: 16px;
}

.services-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 8px;
}

.service-checkbox-label {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: var(--transition);
    background: rgba(128,128,128,0.04);
    border: 1.5px solid var(--border);
    min-height: 44px;
    user-select: none;
}
.service-checkbox-label:hover {
    background: rgba(37,99,235,0.05);
    border-color: var(--primary);
}
.service-checkbox-label.checked {
    background: rgba(37,99,235,0.08);
    border-color: var(--primary);
}
.service-checkbox-label.exclusive-disabled {
    opacity: 0.35;
    cursor: not-allowed;
    pointer-events: none;
}

.service-checkbox-label .checkmark {
    width: 20px;
    height: 20px;
    min-width: 20px;
    border: 2px solid var(--border);
    border-radius: 5px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
    background: var(--input-bg);
    flex-shrink: 0;
}
.service-checkbox-label.checked .checkmark {
    background: var(--primary);
    border-color: var(--primary);
}
.service-checkbox-label.checked .checkmark::after {
    content: '✓';
    color: white;
    font-size: 12px;
    font-weight: 800;
}
.service-checkbox-label input[type="checkbox"] { display: none; }

.service-text { font-size: 0.83rem; line-height: 1.3; font-weight: 500; }

.service-count {
    background: rgba(128,128,128,0.1);
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 0.72rem;
    font-weight: 700;
    color: var(--text-muted);
    transition: var(--transition);
}
.service-count.all-checked { background: var(--success); color: white; }

/* =====================================================================
   SIGNATURE PAD
=====================================================================*/
.sig-wrap { margin-top: 4px; }

.signature-container {
    background: white;
    border-radius: var(--radius-sm);
    overflow: hidden;
    border: 1.5px solid var(--border);
}

canvas.signature-pad {
    width: 100%;
    height: 140px;
    cursor: crosshair;
    display: block;
}

.sig-preview {
    width: 100%;
    height: 120px;
    object-fit: contain;
    display: block;
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    background: white;
}

.sig-redo-btn { font-size: 0.75rem; margin-top: 6px; }

/* =====================================================================
   SEARCH DROPDOWN
=====================================================================*/
.search-dropdown { position: relative; }

.search-results {
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    right: 0;
    z-index: 200;
    max-height: 220px;
    overflow-y: auto;
    padding: 4px;
}

.search-item {
    padding: 12px 14px;
    cursor: pointer;
    border-radius: var(--radius-sm);
    transition: var(--transition);
    font-size: 0.9rem;
}
.search-item:hover { background: var(--primary); color: white; }

/* =====================================================================
   LIST CARDS (nalogi, prevzem)
=====================================================================*/
.nalog-card {
    padding: 18px 20px;
    margin-bottom: 12px;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    transition: transform 0.2s ease;
}
.nalog-card:hover { transform: translateX(4px); }

.nalog-card-left h4 { font-size: 1rem; font-weight: 700; margin-bottom: 4px; }
.nalog-card-left p { font-size: 0.82rem; color: var(--text-muted); }

.nalog-badge {
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    flex-shrink: 0;
}
.badge-open { background: rgba(245,158,11,0.1); color: var(--warning); }
.badge-finished { background: rgba(16,185,129,0.1); color: var(--success); }
.badge-prevzet { background: rgba(6,182,212,0.1); color: var(--info); }

/* =====================================================================
   AUTO-SAVE INDICATOR
=====================================================================*/
.autosave-indicator {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 5px 12px;
    border-radius: 20px;
    font-size: 0.78rem;
    font-weight: 600;
    background: rgba(16,185,129,0.08);
    color: var(--success);
    border: 1px solid rgba(16,185,129,0.2);
    animation: fadeIn 0.3s ease;
}
.autosave-indicator.saving {
    background: rgba(245,158,11,0.08);
    color: var(--warning);
    border-color: rgba(245,158,11,0.2);
}

/* =====================================================================
   ITEM DETAIL (odprti nalogi)
=====================================================================*/
.detail-item-card {
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 18px;
    margin-bottom: 14px;
    transition: var(--transition);
}
.detail-item-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
    flex-wrap: wrap;
    gap: 8px;
}

/* =====================================================================
   ADMIN TABS
=====================================================================*/
.admin-tabs-bar {
    display: flex;
    overflow-x: auto;
    margin-bottom: 16px;
    padding: 4px;
    -webkit-overflow-scrolling: touch;
}

.admin-tab {
    flex: 1;
    min-width: 80px;
    padding: 12px 16px;
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-weight: 600;
    font-size: 0.82rem;
    cursor: pointer;
    transition: var(--transition);
    border-radius: var(--radius-sm);
    white-space: nowrap;
    font-family: inherit;
}
.admin-tab:hover { background: rgba(128,128,128,0.06); color: var(--text); }
.admin-tab.active {
    background: rgba(37,99,235,0.08);
    color: var(--primary);
}

.admin-panel { animation: fadeIn 0.3s ease; }

.admin-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 14px 12px;
    border-bottom: 1px solid var(--border);
    transition: var(--transition);
}
.admin-item:last-child { border-bottom: none; }
.admin-item:hover { background: rgba(128,128,128,0.04); border-radius: var(--radius-sm); }

/* =====================================================================
   CENIK TABLE
=====================================================================*/
.cenik-table { width: 100%; border-collapse: collapse; }
.cenik-table th {
    text-align: left;
    padding: 10px 12px;
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    border-bottom: 2px solid var(--border);
}
.cenik-table td { padding: 10px 12px; border-bottom: 1px solid var(--border); font-size: 0.9rem; }
.cenik-table tr:last-child td { border-bottom: none; }
.cenik-group-header td {
    font-weight: 700;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    padding-top: 18px;
    color: var(--primary);
    background: rgba(37,99,235,0.03);
}

.price-input {
    width: 100px !important;
    text-align: right;
    padding: 8px 12px !important;
    font-weight: 600;
}

/* =====================================================================
   TOAST
=====================================================================*/
#toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 2000;
    display: flex;
    flex-direction: column;
    gap: 10px;
    pointer-events: none;
}

.toast {
    pointer-events: auto;
    min-width: 280px;
    padding: 14px 18px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 0.9rem;
    font-weight: 500;
    animation: toastIn 0.35s cubic-bezier(0.18, 0.89, 0.32, 1.3);
    box-shadow: var(--shadow-lg);
    background: var(--card);
    backdrop-filter: blur(20px);
    border: 1px solid var(--border);
}
.toast.removing { animation: toastOut 0.3s forwards; }
.toast-success { border-left: 4px solid var(--success); }
.toast-error { border-left: 4px solid var(--error); }
.toast-info { border-left: 4px solid var(--primary); }

@keyframes toastIn { from { opacity: 0; transform: translateX(110%); } to { opacity: 1; transform: translateX(0); } }
@keyframes toastOut { to { opacity: 0; transform: translateX(110%); } }

/* =====================================================================
   LOADER
=====================================================================*/
.animate-spin { animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* =====================================================================
   VIEWS / ANIMATIONS
=====================================================================*/
.view { display: none; animation: fadeIn 0.35s ease-out; }
.view.active { display: block; }

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(12px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* =====================================================================
   EMPTY STATE
=====================================================================*/
.empty-state {
    text-align: center;
    padding: 32px 16px;
    color: var(--text-muted);
    font-size: 0.9rem;
}

/* =====================================================================
   SHIMMER
=====================================================================*/
.shimmer {
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.08), transparent);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
    border-radius: var(--radius-md);
}
@keyframes shimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }

/* =====================================================================
   SCROLLBAR
=====================================================================*/
::-webkit-scrollbar { width: 5px; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 10px; }

/* =====================================================================
   RESPONSIVE
=====================================================================*/
@media (max-width: 640px) {
    .app-container { padding: 12px; }
    .form-row-2, .form-row-3 { grid-template-columns: 1fr; }
    .dashboard-grid { grid-template-columns: 1fr; }
    .dashboard-grid .dash-card { grid-column: span 1 !important; }
    #admin-card { grid-column: span 1 !important; }
    #pwa-install-container { grid-column: span 1 !important; }
    .wizard-card { padding: 18px; }
    .services-grid { grid-template-columns: 1fr 1fr; }
    .step-label { display: none; }
    .step-connector { margin-top: 16px; }
    canvas.signature-pad { height: 110px; }
    #toast-container { left: 12px; right: 12px; top: 12px; }
    .toast { min-width: auto; }
    input, select { font-size: 16px; }
}

@media (max-width: 400px) {
    .services-grid { grid-template-columns: 1fr; }
    .price-input { width: 80px !important; }
}

/* =====================================================================
   SAFE AREA
=====================================================================*/
@supports (padding: max(0px)) {
    body {
        padding-left: max(0px, env(safe-area-inset-left));
        padding-right: max(0px, env(safe-area-inset-right));
        padding-bottom: max(0px, env(safe-area-inset-bottom));
    }
}

@media print {
    header, .btn, #loader, #admin-modal, #toast-container { display: none !important; }
}