/* ============================================================
   Lagerivo – App Core Stylesheet (Design System)
   Farbe: #4c8c2b (Lagerivo-Grün)
   ============================================================ */

/* ─── CSS Custom Properties ───────────────────────────────── */
:root {
    --color-primary: #4c8c2b;
    --color-primary-dark: #3a6e20;
    --color-primary-darker: #2d5718;
    --color-primary-light: #e8f5e0;
    --color-primary-50: #f4faf0;
    --color-primary-100: #e8f5e0;
    --color-primary-200: #c8e6b4;

    --color-bg: #f5f7f4;
    --color-surface: #ffffff;
    --color-surface-hover: #fafcf9;
    --color-border: #e2e8de;
    --color-border-light: #eef2ec;
    --color-text: #1a2e12;
    --color-text-secondary: #4a5e40;
    --color-text-muted: #7a8e70;

    --color-success: #27ae60;
    --color-success-bg: #eafaf1;
    --color-warning: #f39c12;
    --color-warning-bg: #fef9e7;
    --color-danger: #c0392b;
    --color-danger-bg: #fdecea;
    --color-info: #2980b9;
    --color-info-bg: #ebf5fb;

    --sidebar-width: 260px;
    --topbar-height: 64px;
    --content-padding: 28px;

    --radius: 12px;
    --radius-sm: 8px;
    --radius-xs: 6px;
    --radius-full: 9999px;
    --shadow-sm: 0 1px 2px rgba(0,0,0,0.04);
    --shadow: 0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
    --shadow-md: 0 4px 12px rgba(0,0,0,0.06), 0 1px 3px rgba(0,0,0,0.04);
    --shadow-lg: 0 8px 30px rgba(0,0,0,0.08), 0 2px 6px rgba(0,0,0,0.04);
    --transition: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    --transition-slow: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    --font-mono: "SF Mono", "Fira Code", Menlo, monospace;
}

/* ─── Reset ───────────────────────────────────────────────── */
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }
html { font-size: 16px; -webkit-font-smoothing: antialiased; scroll-behavior: smooth; }
a { color: var(--color-primary); text-decoration: none; }
a:hover { color: var(--color-primary-dark); }

/* ─── Scrollbar ───────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--color-border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--color-text-muted); }

/* =============================================================
   APP SHELL
   ============================================================= */
.app-body {
    font-family: var(--font);
    background: var(--color-bg);
    color: var(--color-text);
    min-height: 100vh;
    display: flex;
    overflow-x: hidden;
}

/* ─── Sidebar ─────────────────────────────────────────────── */
.sidebar {
    position: fixed; top: 0; left: 0;
    width: var(--sidebar-width); height: 100vh;
    background: var(--color-surface);
    border-right: 1px solid var(--color-border);
    display: flex; flex-direction: column;
    z-index: 100;
    transition: transform var(--transition-slow);
    overflow: hidden;
}

.sidebar-header {
    display: flex; align-items: center; justify-content: space-between;
    padding: 20px 20px 16px;
    border-bottom: 1px solid var(--color-border-light);
    flex-shrink: 0;
}

.sidebar-logo {
    display: flex; align-items: center; gap: 12px;
    color: var(--color-primary);
    text-decoration: none;
}
.sidebar-logo:hover { color: var(--color-primary); }

.sidebar-brand {
    font-size: 1.25rem; font-weight: 700;
    color: var(--color-text); letter-spacing: -0.02em;
}

.sidebar-close {
    display: none; background: none; border: none;
    color: var(--color-text-muted); cursor: pointer;
    padding: 4px; border-radius: var(--radius-xs);
}
.sidebar-close:hover { color: var(--color-text); }

.sidebar-nav { flex: 1; overflow-y: auto; padding: 12px 12px 8px; }
.sidebar-nav ul { list-style: none; }

.nav-section-label {
    font-size: 0.6875rem; font-weight: 700;
    text-transform: uppercase; letter-spacing: 0.06em;
    color: var(--color-text-muted);
    padding: 16px 12px 6px;
}
.nav-section-label:first-child { padding-top: 4px; }

.nav-link {
    display: flex; align-items: center; gap: 12px;
    padding: 10px 12px; font-size: 0.875rem; font-weight: 500;
    color: var(--color-text-secondary);
    border-radius: var(--radius-sm);
    transition: background var(--transition), color var(--transition);
    cursor: pointer; text-decoration: none;
}
.nav-link svg { flex-shrink: 0; opacity: 0.6; transition: opacity var(--transition); }
.nav-link:hover { background: var(--color-primary-50); color: var(--color-primary-dark); }
.nav-link:hover svg { opacity: 0.85; }
.nav-link.active { background: var(--color-primary-light); color: var(--color-primary-dark); font-weight: 600; }
.nav-link.active svg { opacity: 1; color: var(--color-primary); }

.sidebar-footer {
    padding: 12px;
    border-top: 1px solid var(--color-border-light);
    flex-shrink: 0;
}

.sidebar-user { display: flex; align-items: center; gap: 12px; padding: 10px 12px; margin-bottom: 4px; }

.user-avatar {
    width: 36px; height: 36px;
    background: var(--color-primary-light); color: var(--color-primary);
    border-radius: var(--radius-full);
    display: flex; align-items: center; justify-content: center;
    font-size: 0.875rem; font-weight: 700; flex-shrink: 0;
}

.user-info { display: flex; flex-direction: column; min-width: 0; }
.user-name { font-size: 0.8125rem; font-weight: 600; color: var(--color-text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-role { font-size: 0.6875rem; color: var(--color-text-muted); }

.nav-link-logout { color: var(--color-text-muted); }
.nav-link-logout:hover { background: var(--color-danger-bg); color: var(--color-danger); }

.sidebar-overlay {
    display: none; position: fixed; inset: 0;
    background: rgba(0,0,0,0.3); z-index: 99;
    backdrop-filter: blur(2px);
}

/* ─── Main Content ────────────────────────────────────────── */
.main-content {
    flex: 1; margin-left: var(--sidebar-width);
    min-height: 100vh; display: flex; flex-direction: column;
    transition: margin-left var(--transition-slow);
}

.topbar {
    height: var(--topbar-height);
    background: var(--color-surface);
    border-bottom: 1px solid var(--color-border);
    display: flex; align-items: center; justify-content: space-between;
    padding: 0 var(--content-padding);
    position: sticky; top: 0; z-index: 50; flex-shrink: 0;
}

.topbar-left { display: flex; align-items: center; gap: 16px; }

.topbar-menu-btn {
    display: none; background: none; border: none;
    color: var(--color-text-secondary); cursor: pointer;
    padding: 6px; border-radius: var(--radius-xs);
}
.topbar-menu-btn:hover { color: var(--color-text); }

.topbar-title { font-size: 1.25rem; font-weight: 700; color: var(--color-text); letter-spacing: -0.01em; }

.topbar-right { display: flex; align-items: center; gap: 16px; }

.topbar-search { position: relative; width: 280px; }
.topbar-search .search-icon {
    position: absolute; left: 12px; top: 50%; transform: translateY(-50%);
    color: var(--color-text-muted); pointer-events: none; opacity: 0.5;
}
.topbar-search input {
    width: 100%; padding: 9px 14px 9px 38px;
    font-size: 0.875rem; font-family: var(--font);
    color: var(--color-text); background: var(--color-bg);
    border: 1.5px solid var(--color-border); border-radius: var(--radius-sm);
    outline: none; transition: border-color var(--transition), box-shadow var(--transition), background var(--transition);
}
.topbar-search input::placeholder { color: var(--color-text-muted); }
.topbar-search input:focus { background: var(--color-surface); border-color: var(--color-primary); box-shadow: 0 0 0 3px rgba(76,140,43,0.10); }

.content-area { flex: 1; padding: var(--content-padding); }

/* =============================================================
   ALERTS
   ============================================================= */
.alert {
    display: flex; align-items: center; justify-content: space-between;
    gap: 12px; padding: 14px 20px;
    margin: 16px var(--content-padding) 0;
    border-radius: var(--radius-sm);
    font-size: 0.875rem; font-weight: 500; line-height: 1.4;
    animation: alertSlideIn 0.3s ease-out;
}
@keyframes alertSlideIn { from { opacity: 0; transform: translateY(-8px); } to { opacity: 1; transform: translateY(0); } }

.alert-success { background: var(--color-success-bg); color: #1e8449; border: 1px solid rgba(39,174,96,0.15); }
.alert-warning { background: var(--color-warning-bg); color: #9a7b13; border: 1px solid rgba(243,156,18,0.15); }
.alert-error   { background: var(--color-danger-bg);  color: var(--color-danger); border: 1px solid rgba(192,57,43,0.15); }
.alert-info    { background: var(--color-info-bg);    color: #1a6fa0; border: 1px solid rgba(41,128,185,0.15); }

.alert-close {
    background: none; border: none; color: inherit;
    opacity: 0.5; cursor: pointer; font-size: 1.25rem;
    padding: 0 4px; line-height: 1;
}
.alert-close:hover { opacity: 1; }

/* =============================================================
   CARDS
   ============================================================= */
.card { background: var(--color-surface); border: 1px solid var(--color-border); border-radius: var(--radius); box-shadow: var(--shadow-sm); }
.card-header { display: flex; align-items: center; justify-content: space-between; padding: 18px 24px; border-bottom: 1px solid var(--color-border-light); }
.card-header h2, .card-header h3 { font-size: 1rem; font-weight: 700; color: var(--color-text); }
.card-body { padding: 24px; }
.card-footer { padding: 16px 24px; border-top: 1px solid var(--color-border-light); display: flex; align-items: center; justify-content: space-between; }

/* =============================================================
   TABLES
   ============================================================= */
.table-wrapper { overflow-x: auto; }
.data-table { width: 100%; border-collapse: collapse; font-size: 0.875rem; }
.data-table thead { background: var(--color-bg); position: sticky; top: 0; z-index: 1; }
.data-table th {
    padding: 12px 16px; text-align: left;
    font-size: 0.75rem; font-weight: 700;
    text-transform: uppercase; letter-spacing: 0.04em;
    color: var(--color-text-muted);
    border-bottom: 2px solid var(--color-border);
    white-space: nowrap; user-select: none;
}
.data-table td { padding: 12px 16px; border-bottom: 1px solid var(--color-border-light); color: var(--color-text-secondary); vertical-align: middle; }
.data-table tbody tr { transition: background var(--transition); }
.data-table tbody tr:hover { background: var(--color-primary-50); }
.data-table tbody tr:last-child td { border-bottom: none; }
.table-empty { text-align: center; padding: 40px 20px; color: var(--color-text-muted); }

/* =============================================================
   BUTTONS
   ============================================================= */
.btn {
    display: inline-flex; align-items: center; justify-content: center;
    gap: 8px; padding: 10px 20px;
    font-size: 0.875rem; font-weight: 600; font-family: var(--font);
    border: none; border-radius: var(--radius-sm);
    cursor: pointer; text-decoration: none;
    line-height: 1.4; white-space: nowrap;
    transition: background var(--transition), transform var(--transition), box-shadow var(--transition);
}
.btn:active { transform: scale(0.97); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }

.btn-primary { background: var(--color-primary); color: #fff; box-shadow: 0 1px 4px rgba(76,140,43,0.2); }
.btn-primary:hover { background: var(--color-primary-dark); color: #fff; }
.btn-secondary { background: var(--color-bg); color: var(--color-text-secondary); border: 1px solid var(--color-border); }
.btn-secondary:hover { background: var(--color-border-light); }
.btn-danger { background: var(--color-danger); color: #fff; }
.btn-danger:hover { background: #a93226; color: #fff; }
.btn-ghost { background: transparent; color: var(--color-text-secondary); padding: 8px 12px; }
.btn-ghost:hover { background: var(--color-bg); }
.btn-sm { padding: 6px 14px; font-size: 0.8125rem; }
.btn-icon { padding: 8px; width: 36px; height: 36px; }
.btn-block { width: 100%; padding: 14px 24px; font-size: 1rem; }
.btn-group { display: flex; gap: 8px; }

/* =============================================================
   FORMS
   ============================================================= */
.form-group { margin-bottom: 20px; }
.form-group label { display: block; font-size: 0.8125rem; font-weight: 600; color: var(--color-text); margin-bottom: 6px; }
.form-control {
    width: 100%; padding: 10px 14px;
    font-size: 0.875rem; font-family: var(--font);
    color: var(--color-text); background: var(--color-surface);
    border: 1.5px solid var(--color-border); border-radius: var(--radius-sm);
    outline: none; transition: border-color var(--transition), box-shadow var(--transition);
}
.form-control::placeholder { color: var(--color-text-muted); opacity: 0.6; }
.form-control:focus { border-color: var(--color-primary); box-shadow: 0 0 0 3px rgba(76,140,43,0.10); }
.form-control:disabled { background: var(--color-bg); cursor: not-allowed; }

select.form-control {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='%237a8e70'%3E%3Cpath d='M6 8.825L0.375 3.2l0.85-0.85L6 7.125 10.775 2.35l0.85 0.85z'/%3E%3C/svg%3E");
    background-repeat: no-repeat; background-position: right 12px center; padding-right: 36px;
}
textarea.form-control { resize: vertical; min-height: 80px; }
.form-hint { font-size: 0.75rem; color: var(--color-text-muted); margin-top: 4px; }
.form-error { font-size: 0.75rem; color: var(--color-danger); margin-top: 4px; }
.form-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 16px; }

/* =============================================================
   BADGES
   ============================================================= */
.badge {
    display: inline-flex; align-items: center;
    padding: 3px 10px; font-size: 0.6875rem; font-weight: 700;
    text-transform: uppercase; letter-spacing: 0.03em;
    border-radius: var(--radius-full); white-space: nowrap;
}
.badge-green   { background: var(--color-success-bg); color: #1e8449; }
.badge-yellow  { background: var(--color-warning-bg); color: #9a7b13; }
.badge-red     { background: var(--color-danger-bg);  color: var(--color-danger); }
.badge-blue    { background: var(--color-info-bg);    color: #1a6fa0; }
.badge-gray    { background: var(--color-bg);         color: var(--color-text-muted); }
.badge-primary { background: var(--color-primary-light); color: var(--color-primary-dark); }

/* =============================================================
   MODALS
   ============================================================= */
.modal-overlay {
    display: none; position: fixed; inset: 0;
    background: rgba(0,0,0,0.35); z-index: 200;
    align-items: center; justify-content: center;
    backdrop-filter: blur(3px);
    animation: fadeIn 0.2s ease-out;
}
.modal-overlay.is-active { display: flex; }

.modal {
    background: var(--color-surface); border-radius: var(--radius);
    box-shadow: var(--shadow-lg); width: 95%; max-width: 560px;
    max-height: 85vh; overflow: hidden;
    display: flex; flex-direction: column;
    animation: modalSlideIn 0.25s ease-out;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes modalSlideIn { from { opacity: 0; transform: translateY(12px) scale(0.97); } to { opacity: 1; transform: translateY(0) scale(1); } }

.modal-header { display: flex; align-items: center; justify-content: space-between; padding: 20px 24px; border-bottom: 1px solid var(--color-border-light); }
.modal-header h2 { font-size: 1.0625rem; font-weight: 700; }
.modal-close { background: none; border: none; color: var(--color-text-muted); cursor: pointer; padding: 4px; border-radius: var(--radius-xs); font-size: 1.25rem; line-height: 1; }
.modal-close:hover { color: var(--color-text); }
.modal-body { padding: 24px; overflow-y: auto; flex: 1; }
.modal-footer { display: flex; align-items: center; justify-content: flex-end; gap: 10px; padding: 16px 24px; border-top: 1px solid var(--color-border-light); }

/* =============================================================
   PAGINATION
   ============================================================= */
.pagination-wrapper { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 12px; margin-top: 20px; }
.pagination { display: flex; align-items: center; gap: 4px; }
.pagination-btn {
    display: inline-flex; align-items: center; justify-content: center;
    min-width: 36px; height: 36px; padding: 0 10px;
    font-size: 0.8125rem; font-weight: 500;
    color: var(--color-text-secondary);
    background: var(--color-surface);
    border: 1px solid var(--color-border); border-radius: var(--radius-xs);
    cursor: pointer; text-decoration: none;
    transition: background var(--transition), color var(--transition);
}
.pagination-btn:hover { background: var(--color-primary-50); color: var(--color-primary); border-color: var(--color-primary-200); }
.pagination-btn.active { background: var(--color-primary); color: #fff; border-color: var(--color-primary); }
.pagination-btn[disabled] { opacity: 0.3; cursor: not-allowed; }
.pagination-info { font-size: 0.8125rem; color: var(--color-text-muted); }

/* =============================================================
   STOCK INDICATORS
   ============================================================= */
.stock-indicator { display: inline-flex; align-items: center; gap: 6px; font-weight: 600; font-size: 0.8125rem; }
.stock-dot { width: 8px; height: 8px; border-radius: 50%; }
.stock-ok .stock-dot    { background: var(--color-success); }
.stock-low .stock-dot   { background: var(--color-warning); }
.stock-empty .stock-dot { background: var(--color-danger); }
.stock-ok    { color: var(--color-success); }
.stock-low   { color: var(--color-warning); }
.stock-empty { color: var(--color-danger); }

/* =============================================================
   EMPTY STATES
   ============================================================= */
.empty-state { display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 60px 24px; text-align: center; }
.empty-state-icon { width: 64px; height: 64px; background: var(--color-primary-50); color: var(--color-primary); border-radius: 20px; display: flex; align-items: center; justify-content: center; margin-bottom: 16px; opacity: 0.7; }
.empty-state h3 { font-size: 1rem; font-weight: 600; color: var(--color-text); margin-bottom: 6px; }
.empty-state p { font-size: 0.875rem; color: var(--color-text-muted); max-width: 380px; }

/* =============================================================
   TOOLBAR
   ============================================================= */
.toolbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }
.toolbar-left, .toolbar-right { display: flex; align-items: center; gap: 10px; }
.toolbar-search { position: relative; width: 260px; }
.toolbar-search input {
    width: 100%; padding: 9px 14px 9px 36px; font-size: 0.8125rem; font-family: var(--font);
    border: 1.5px solid var(--color-border); border-radius: var(--radius-sm);
    outline: none; background: var(--color-surface); color: var(--color-text);
}
.toolbar-search input:focus { border-color: var(--color-primary); box-shadow: 0 0 0 3px rgba(76,140,43,0.10); }
.toolbar-search svg { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); color: var(--color-text-muted); opacity: 0.5; pointer-events: none; }

/* =============================================================
   LOADING / SPINNER
   ============================================================= */
.spinner { width: 24px; height: 24px; border: 3px solid var(--color-border); border-top-color: var(--color-primary); border-radius: 50%; animation: spin 0.7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.loading-overlay { display: flex; align-items: center; justify-content: center; gap: 12px; padding: 40px; color: var(--color-text-muted); font-size: 0.875rem; }

/* =============================================================
   UTILITIES
   ============================================================= */
.text-muted   { color: var(--color-text-muted); }
.text-success { color: var(--color-success); }
.text-warning { color: var(--color-warning); }
.text-danger  { color: var(--color-danger); }
.text-right   { text-align: right; }
.text-center  { text-align: center; }
.text-mono    { font-family: var(--font-mono); font-size: 0.8125rem; }
.font-bold    { font-weight: 700; }
.mt-0 { margin-top: 0; }    .mt-1 { margin-top: 8px; }   .mt-2 { margin-top: 16px; }  .mt-3 { margin-top: 24px; }
.mb-0 { margin-bottom: 0; } .mb-1 { margin-bottom: 8px; } .mb-2 { margin-bottom: 16px; } .mb-3 { margin-bottom: 24px; }
.hidden { display: none !important; }

/* =============================================================
   RESPONSIVE
   ============================================================= */
@media (max-width: 1100px) {
    .sidebar { transform: translateX(-100%); }
    .sidebar.is-open { transform: translateX(0); box-shadow: var(--shadow-lg); }
    .sidebar-close { display: block; }
    .sidebar-overlay.is-active { display: block; }
    .main-content { margin-left: 0; }
    .topbar-menu-btn { display: block; }
}

@media (max-width: 768px) {
    :root { --content-padding: 16px; --topbar-height: 56px; }
    .topbar-search { display: none; }
    .form-row { grid-template-columns: 1fr; }
    .toolbar { flex-direction: column; align-items: stretch; }
    .toolbar-search { width: 100%; }
}
