/* ============================================================
   DJK Inventar – Stylesheet
   ============================================================ */

:root {
    --blue:       #1a5c9a;
    --blue-dark:  #134a7d;
    --blue-light: #e8f0f9;
    --green:      #2d7d46;
    --green-bg:   #e6f4ec;
    --amber:      #b45309;
    --amber-bg:   #fef3c7;
    --red:        #b91c1c;
    --red-bg:     #fee2e2;
    --gray-50:    #f9fafb;
    --gray-100:   #f3f4f6;
    --gray-200:   #e5e7eb;
    --gray-300:   #d1d5db;
    --gray-500:   #6b7280;
    --gray-700:   #374151;
    --gray-900:   #111827;
    --radius:     6px;
    --shadow:     0 1px 3px rgba(0,0,0,.1), 0 1px 2px rgba(0,0,0,.06);
    --shadow-md:  0 4px 6px rgba(0,0,0,.07), 0 2px 4px rgba(0,0,0,.06);
}

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

html { font-size: 15px; }

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    color: var(--gray-900);
    background: var(--gray-50);
    line-height: 1.6;
    min-height: 100vh;
}

/* ---- Header ---- */
.site-header {
    background: var(--blue);
    color: white;
    box-shadow: var(--shadow-md);
    position: sticky; top: 0; z-index: 100;
}
.header-inner {
    max-width: 1200px; margin: 0 auto;
    display: flex; align-items: center; gap: 1.5rem;
    padding: 0 1.5rem; height: 56px;
}
.site-logo {
    display: flex; align-items: center; gap: 10px;
    text-decoration: none; color: white;
    font-weight: 600; font-size: 1rem; white-space: nowrap;
}
.site-logo svg { flex-shrink: 0; }
.main-nav { display: flex; gap: 4px; flex: 1; }
.main-nav a {
    color: rgba(255,255,255,.85); text-decoration: none;
    padding: 6px 14px; border-radius: var(--radius);
    font-size: .9rem; transition: background .15s;
}
.main-nav a:hover, .main-nav a.active {
    background: rgba(255,255,255,.15); color: white;
}
.header-user {
    display: flex; align-items: center; gap: 8px;
    flex-shrink: 0;
}
.user-name { font-size: .85rem; color: rgba(255,255,255,.85); }

/* ---- Layout ---- */
.container { max-width: 1200px; margin: 0 auto; padding: 1.5rem; }
.container-narrow { max-width: 860px; }

/* ---- Stat cards ---- */
.stat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 12px; margin-bottom: 1.25rem;
}
.stat-card {
    background: white; border-radius: var(--radius);
    border: 1px solid var(--gray-200);
    padding: .85rem 1rem;
}
.stat-label { font-size: .75rem; color: var(--gray-500); text-transform: uppercase; letter-spacing: .04em; }
.stat-value { font-size: 1.75rem; font-weight: 700; color: var(--gray-900); }
.stat-ok   .stat-value { color: var(--green); }
.stat-low  .stat-value { color: var(--amber); }
.stat-out  .stat-value { color: var(--red); }

/* ---- Toolbar ---- */
.toolbar {
    display: flex; gap: 10px; align-items: center;
    flex-wrap: wrap; margin-bottom: 1rem;
}
.filter-form {
    display: flex; gap: 8px; flex-wrap: wrap; flex: 1;
}
.filter-form input[type=text], .filter-form select {
    height: 36px; padding: 0 10px;
    border: 1px solid var(--gray-300); border-radius: var(--radius);
    font-size: .875rem; background: white; color: var(--gray-900);
}
.filter-form input[type=text] { min-width: 180px; flex: 1; }
.filter-form select { min-width: 150px; }
.filter-form input:focus, .filter-form select:focus {
    outline: 2px solid var(--blue); border-color: transparent;
}

/* ---- Buttons ---- */
.btn {
    display: inline-flex; align-items: center; gap: 5px;
    height: 36px; padding: 0 16px;
    border-radius: var(--radius); border: 1px solid transparent;
    font-size: .875rem; font-weight: 500; cursor: pointer;
    text-decoration: none; transition: background .15s, opacity .15s;
    white-space: nowrap;
}
.btn-primary   { background: var(--blue); color: white; border-color: var(--blue-dark); }
.btn-primary:hover { background: var(--blue-dark); }
.btn-secondary { background: white; color: var(--gray-700); border-color: var(--gray-300); }
.btn-secondary:hover { background: var(--gray-100); }
.btn-ghost     { background: transparent; color: var(--gray-500); border-color: transparent; }
.btn-ghost:hover { background: var(--gray-100); color: var(--gray-700); }
.btn-danger    { background: var(--red-bg); color: var(--red); border-color: #fca5a5; }
.btn-danger:hover { background: #fca5a5; }
.btn-full      { width: 100%; justify-content: center; }
.btn-xs        { height: 28px; padding: 0 10px; font-size: .8rem; }

/* ---- Table ---- */
.table-wrap {
    background: white; border-radius: var(--radius);
    border: 1px solid var(--gray-200); overflow-x: auto;
}
table { width: 100%; border-collapse: collapse; font-size: .875rem; }
thead { background: var(--gray-50); border-bottom: 1px solid var(--gray-200); }
th {
    padding: 10px 14px; text-align: left;
    font-size: .75rem; font-weight: 600;
    color: var(--gray-500); text-transform: uppercase; letter-spacing: .04em;
    white-space: nowrap;
}
th a { color: inherit; text-decoration: none; }
th a:hover { color: var(--blue); }
td { padding: 10px 14px; border-bottom: 1px solid var(--gray-100); vertical-align: middle; }
tr:last-child td { border-bottom: none; }
tbody tr:hover td { background: var(--gray-50); }
.row-inactive td { opacity: .5; }
.sort-icon { font-size: .7rem; margin-left: 2px; opacity: .5; }
.sort-icon.active { opacity: 1; color: var(--blue); }
.empty-msg { text-align: center; padding: 2rem; color: var(--gray-500); }
.result-count { margin-top: .5rem; font-size: .8rem; color: var(--gray-500); }
.actions { white-space: nowrap; }
.actions form { display: inline; }

/* ---- Badges ---- */
.badge {
    display: inline-block; font-size: .72rem; font-weight: 600;
    padding: 2px 8px; border-radius: 20px; white-space: nowrap;
}
.badge-ok  { background: var(--green-bg); color: var(--green); }
.badge-low { background: var(--amber-bg); color: var(--amber); }
.badge-out { background: var(--red-bg);   color: var(--red); }
.badge-role-admin  { background: #ede9fe; color: #5b21b6; }
.badge-role-editor { background: var(--blue-light); color: var(--blue); }
.badge-role-viewer { background: var(--gray-100); color: var(--gray-500); }

/* ---- Item link ---- */
.item-link { color: var(--blue); font-weight: 500; text-decoration: none; display: block; }
.item-link:hover { text-decoration: underline; }
.qty { font-weight: 600; font-size: 1rem; }
.text-muted { color: var(--gray-500); }
.small { font-size: .8rem; }
small.text-muted { display: block; font-size: .75rem; color: var(--gray-500); }

/* ---- Alerts ---- */
.alert {
    padding: .8rem 1rem; border-radius: var(--radius);
    margin-bottom: 1rem; font-size: .875rem;
}
.alert-success { background: var(--green-bg); color: var(--green); border: 1px solid #a7f3d0; }
.alert-error   { background: var(--red-bg); color: var(--red); border: 1px solid #fca5a5; }

/* ---- Forms ---- */
.form-group { display: flex; flex-direction: column; gap: 4px; }
.form-group label { font-size: .8rem; font-weight: 600; color: var(--gray-700); }
.form-group input, .form-group select, .form-group textarea {
    width: 100%; padding: 8px 10px;
    border: 1px solid var(--gray-300); border-radius: var(--radius);
    font-size: .875rem; font-family: inherit; color: var(--gray-900); background: white;
    transition: border-color .15s;
}
.form-group input:focus, .form-group select:focus, .form-group textarea:focus {
    outline: 2px solid var(--blue); border-color: transparent;
}
.form-group-lg { flex: 2; }
.form-group-check { justify-content: flex-end; padding-bottom: 4px; }
.form-group-check label { display: flex; align-items: center; gap: 8px; font-size: .875rem; cursor: pointer; }
.form-row { display: flex; gap: 14px; flex-wrap: wrap; align-items: flex-start; }
.form-row .form-group { flex: 1; min-width: 160px; }
.req { color: var(--red); }
.form-actions { display: flex; gap: 10px; padding-top: .5rem; }

fieldset {
    border: 1px solid var(--gray-200); border-radius: var(--radius);
    padding: 1.1rem 1.25rem; margin-bottom: 1.25rem;
}
legend {
    font-size: .8rem; font-weight: 700; text-transform: uppercase;
    letter-spacing: .05em; color: var(--gray-500);
    padding: 0 6px;
}

/* ---- Edit form ---- */
.edit-form { }
.edit-panel {
    background: white; border: 1px solid var(--gray-200);
    border-radius: var(--radius); padding: 1.25rem;
    margin-bottom: 1.5rem;
}
.edit-panel h3 { margin-bottom: 1rem; font-size: 1rem; }

/* ---- Page header ---- */
.page-header {
    display: flex; align-items: center; justify-content: space-between;
    flex-wrap: wrap; gap: .75rem; margin-bottom: 1.25rem;
}
.page-header h2 { font-size: 1.3rem; font-weight: 700; }
.btn-group { display: flex; gap: 8px; }

/* ---- Detail view ---- */
.detail-grid {
    display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 14px; margin-bottom: 1.5rem;
}
.detail-card {
    background: white; border: 1px solid var(--gray-200);
    border-radius: var(--radius); padding: 1rem 1.25rem;
}
.detail-card h3 {
    font-size: .8rem; text-transform: uppercase; letter-spacing: .05em;
    color: var(--gray-500); margin-bottom: .75rem; font-weight: 700;
}
dl { display: grid; grid-template-columns: auto 1fr; gap: 6px 14px; }
dt { font-size: .8rem; color: var(--gray-500); align-self: start; padding-top: 1px; white-space: nowrap; }
dd { font-size: .875rem; color: var(--gray-900); }
.qty-big { font-size: 2rem; font-weight: 700; color: var(--green); }
.qty-low  { color: var(--amber) !important; }
.qty-out  { color: var(--red) !important; }

.log-section { background: white; border: 1px solid var(--gray-200); border-radius: var(--radius); padding: 1rem 1.25rem; }
.log-section h3 { font-size: .9rem; margin-bottom: .75rem; }

/* ---- Login ---- */
.login-page {
    display: flex; align-items: center; justify-content: center;
    min-height: 100vh; background: var(--gray-100);
}
.login-box {
    background: white; border-radius: 10px; padding: 2.5rem 2rem;
    width: 100%; max-width: 380px; box-shadow: var(--shadow-md);
    border: 1px solid var(--gray-200);
}
.login-logo {
    display: flex; flex-direction: column; align-items: center;
    gap: 12px; margin-bottom: 2rem;
}
.login-logo h1 { font-size: 1rem; font-weight: 700; text-align: center; color: var(--gray-900); }
.login-box .form-group { margin-bottom: 1rem; }
.login-box .btn { margin-top: .5rem; height: 42px; font-size: .95rem; }

/* ---- Wartung Farben ---- */
.maintenance-overdue { color: var(--red); font-weight: 600; }
.maintenance-soon    { color: var(--amber); font-weight: 600; }

/* ---- Responsive ---- */
@media (max-width: 640px) {
    .header-inner { padding: 0 1rem; gap: 1rem; }
    .site-logo span { display: none; }
    .container { padding: 1rem; }
    .stat-grid { grid-template-columns: repeat(2, 1fr); }
    .toolbar { flex-direction: column; align-items: stretch; }
    .filter-form { flex-direction: column; }
    .filter-form input, .filter-form select { width: 100%; }
    .page-header { flex-direction: column; align-items: flex-start; }
    .detail-grid { grid-template-columns: 1fr; }
}
