/* ===================================================================
   EINSZWEI Lizenzsystem – App Stylesheet
   Plain CSS, no framework dependency
   =================================================================== */

/* ------------------------------------------------------------------
   1. Reset & Base
   ------------------------------------------------------------------ */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
    --color-primary:     #4f46e5;
    --color-primary-h:   #4338ca;
    --color-success:     #16a34a;
    --color-danger:      #dc2626;
    --color-warning:     #d97706;
    --color-info:        #0ea5e9;
    --color-muted:       #6b7280;
    --color-border:      #e5e7eb;
    --color-bg:          #f3f4f6;
    --color-surface:     #ffffff;
    --color-text:        #111827;
    --sidebar-w:         220px;
    --topbar-h:          56px;
    --radius:            .5rem;
    --shadow:            0 1px 3px rgba(0,0,0,.1), 0 1px 2px rgba(0,0,0,.06);
    --shadow-md:         0 4px 6px -1px rgba(0,0,0,.1), 0 2px 4px -2px rgba(0,0,0,.1);
}

html { font-size: 16px; }

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    font-size: .9375rem;
    line-height: 1.5;
    color: var(--color-text);
    background: var(--color-bg);
}

a { color: var(--color-primary); text-decoration: none; }
a:hover { text-decoration: underline; }

code {
    font-family: 'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, monospace;
    font-size: .8125em;
    background: #f1f5f9;
    padding: .125em .375em;
    border-radius: .25rem;
    color: #475569;
}

small { font-size: .8125em; }

hr {
    border: none;
    border-top: 1px solid var(--color-border);
    margin: 1rem 0;
}

/* ------------------------------------------------------------------
   2. Layout – Sidebar + Main
   ------------------------------------------------------------------ */
.layout {
    display: flex;
    min-height: 100vh;
}

/* Sidebar */
.sidebar {
    width: var(--sidebar-w);
    min-height: 100vh;
    background: #1e1b4b;
    color: #c7d2fe;
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    position: fixed;
    top: 0; left: 0; bottom: 0;
    overflow-y: auto;
    z-index: 100;
}

.sidebar__brand {
    display: flex;
    align-items: center;
    gap: .5rem;
    padding: 1.125rem 1.25rem;
    font-weight: 700;
    font-size: 1rem;
    color: #fff;
    border-bottom: 1px solid rgba(255,255,255,.1);
    flex-shrink: 0;
}

.sidebar__logo { font-size: 1.25rem; }

.sidebar__section {
    padding: 1rem 1.25rem .25rem;
    font-size: .6875rem;
    font-weight: 600;
    letter-spacing: .07em;
    text-transform: uppercase;
    color: #818cf8;
}

.sidebar__nav { flex: 1; padding-top: .5rem; }

.sidebar__nav ul { list-style: none; }

.sidebar__nav ul li a {
    display: flex;
    align-items: center;
    gap: .625rem;
    padding: .5rem 1.25rem;
    color: #c7d2fe;
    font-size: .875rem;
    text-decoration: none;
    transition: background .15s, color .15s;
    border-radius: 0;
}

.sidebar__nav ul li a:hover {
    background: rgba(255,255,255,.07);
    color: #fff;
}

.sidebar__nav ul li a.active {
    background: var(--color-primary);
    color: #fff;
    font-weight: 600;
}

.sidebar__footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: .875rem 1.25rem;
    border-top: 1px solid rgba(255,255,255,.1);
    font-size: .8125rem;
    color: #a5b4fc;
    flex-shrink: 0;
}

.sidebar__footer a {
    color: #f87171;
    text-decoration: none;
    font-weight: 500;
}

.sidebar__footer a:hover { text-decoration: underline; }

/* Main */
.main {
    flex: 1;
    margin-left: var(--sidebar-w);
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

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

.topbar__title {
    font-size: 1.0625rem;
    font-weight: 600;
    color: var(--color-text);
}

.topbar__date {
    font-size: .8125rem;
    color: var(--color-muted);
}

.content {
    flex: 1;
    padding: 1.5rem;
}

/* ------------------------------------------------------------------
   3. Cards
   ------------------------------------------------------------------ */
.card {
    background: var(--color-surface);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    border: 1px solid var(--color-border);
    overflow: hidden;
}

.card__header {
    padding: .75rem 1.25rem;
    font-weight: 600;
    font-size: .9375rem;
    border-bottom: 1px solid var(--color-border);
    background: var(--color-surface);
}

.card__body {
    padding: 1.25rem;
}

.card__footer {
    padding: .75rem 1.25rem;
    border-top: 1px solid var(--color-border);
    background: #f9fafb;
}

/* ------------------------------------------------------------------
   4. Tables
   ------------------------------------------------------------------ */
.table-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.table {
    width: 100%;
    border-collapse: collapse;
}

.table thead tr {
    background: #f8fafc;
    border-bottom: 2px solid var(--color-border);
}

.table th {
    padding: .625rem 1rem;
    text-align: left;
    font-size: .75rem;
    font-weight: 600;
    letter-spacing: .04em;
    text-transform: uppercase;
    color: var(--color-muted);
    white-space: nowrap;
}

.table td {
    padding: .625rem 1rem;
    border-bottom: 1px solid #f1f5f9;
    vertical-align: middle;
}

.table tbody tr:last-child td { border-bottom: none; }

.table tbody tr:hover { background: #f8fafc; }

.table .empty {
    text-align: center;
    color: var(--color-muted);
    padding: 2rem 1rem;
    font-style: italic;
}

/* ------------------------------------------------------------------
   5. Buttons
   ------------------------------------------------------------------ */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: .375rem;
    padding: .5rem 1rem;
    font-size: .875rem;
    font-weight: 500;
    line-height: 1;
    border-radius: .375rem;
    border: 1px solid transparent;
    cursor: pointer;
    text-decoration: none;
    white-space: nowrap;
    transition: background .15s, border-color .15s, color .15s, box-shadow .15s;
    background: #e5e7eb;
    color: #374151;
}

.btn:hover { text-decoration: none; filter: brightness(.95); }
.btn:focus-visible { outline: 2px solid var(--color-primary); outline-offset: 2px; }
.btn:active { transform: translateY(1px); }

.btn--primary {
    background: var(--color-primary);
    color: #fff;
    border-color: var(--color-primary);
}
.btn--primary:hover { background: var(--color-primary-h); border-color: var(--color-primary-h); }

.btn--secondary {
    background: #fff;
    color: #374151;
    border-color: var(--color-border);
}
.btn--secondary:hover { background: #f9fafb; }

.btn--danger {
    background: var(--color-danger);
    color: #fff;
    border-color: var(--color-danger);
}
.btn--danger:hover { background: #b91c1c; }

.btn--outline {
    background: transparent;
    color: var(--color-primary);
    border-color: var(--color-primary);
}
.btn--outline:hover { background: #eff6ff; }

.btn--sm {
    padding: .3125rem .625rem;
    font-size: .8125rem;
}

.btn--full { width: 100%; }

/* ------------------------------------------------------------------
   6. Forms
   ------------------------------------------------------------------ */
.form { /* no extra styles needed; groups handle spacing */ }

.form-group {
    margin-bottom: 1rem;
}

.form-group.has-error .form-input,
.form-group.has-error select.form-input {
    border-color: var(--color-danger);
}

.form-label {
    display: block;
    font-size: .875rem;
    font-weight: 600;
    margin-bottom: .375rem;
    color: #374151;
}

.form-input {
    display: block;
    width: 100%;
    padding: .5rem .75rem;
    font-size: .9375rem;
    line-height: 1.5;
    color: var(--color-text);
    background: #fff;
    border: 1px solid #d1d5db;
    border-radius: .375rem;
    transition: border-color .15s, box-shadow .15s;
    appearance: none;
    -webkit-appearance: none;
}

.form-input:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px rgba(79,70,229,.12);
}

select.form-input {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='%236b7280' d='M1 1l5 5 5-5'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right .75rem center;
    padding-right: 2rem;
}

.form-textarea {
    resize: vertical;
    min-height: 80px;
}

.form-check {
    display: flex;
    align-items: center;
    gap: .5rem;
    cursor: pointer;
    font-size: .9375rem;
}

.form-check input[type="checkbox"] {
    width: 1rem;
    height: 1rem;
    cursor: pointer;
    accent-color: var(--color-primary);
}

.form-actions {
    display: flex;
    align-items: center;
    gap: .625rem;
    margin-top: 1.25rem;
    padding-top: 1.25rem;
    border-top: 1px solid var(--color-border);
}

.form-row {
    display: flex;
    align-items: center;
    gap: .625rem;
    flex-wrap: wrap;
}

.form-row .form-input { flex: 1; min-width: 0; }

.form-error {
    display: block;
    font-size: .8125rem;
    color: var(--color-danger);
    margin-top: .25rem;
}

small.text-muted {
    display: block;
    margin-top: .25rem;
    font-size: .8125rem;
}

/* ------------------------------------------------------------------
   7. Badges
   ------------------------------------------------------------------ */
.badge {
    display: inline-flex;
    align-items: center;
    padding: .2em .55em;
    font-size: .75em;
    font-weight: 600;
    line-height: 1;
    border-radius: 9999px;
    letter-spacing: .02em;
    text-transform: lowercase;
}

.badge--green  { background: #dcfce7; color: #15803d; }
.badge--gray   { background: #f1f5f9; color: #475569; }
.badge--red    { background: #fee2e2; color: #b91c1c; }
.badge--orange { background: #fef3c7; color: #92400e; }
.badge--dark   { background: #e2e8f0; color: #1e293b; }
.badge--blue   { background: #e0f2fe; color: #0369a1; }

/* ------------------------------------------------------------------
   8. Alerts
   ------------------------------------------------------------------ */
.alert {
    padding: .875rem 1rem;
    border-radius: var(--radius);
    border: 1px solid transparent;
    margin-bottom: 1rem;
    font-size: .9375rem;
}

.alert--success {
    background: #f0fdf4;
    border-color: #bbf7d0;
    color: #15803d;
}

.alert--error {
    background: #fef2f2;
    border-color: #fecaca;
    color: #b91c1c;
}

.alert--info {
    background: #eff6ff;
    border-color: #bfdbfe;
    color: #1d4ed8;
}

/* ------------------------------------------------------------------
   9. Environment Indicators
   ------------------------------------------------------------------ */
.env-live    { color: #15803d; font-weight: 500; }
.env-staging { color: #b45309; }
.env-dev     { color: #1d4ed8; }

/* ------------------------------------------------------------------
   10. Toolbar
   ------------------------------------------------------------------ */
.toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1rem;
    gap: .75rem;
}

/* ------------------------------------------------------------------
   11. Actions (table cell)
   ------------------------------------------------------------------ */
.actions {
    display: flex;
    align-items: center;
    gap: .375rem;
    justify-content: flex-end;
    white-space: nowrap;
}

/* ------------------------------------------------------------------
   12. Text Helpers
   ------------------------------------------------------------------ */
.text-muted { color: var(--color-muted); }

/* ------------------------------------------------------------------
   13. Grid
   ------------------------------------------------------------------ */
.grid { display: grid; gap: 1.5rem; }

.grid--2col {
    grid-template-columns: 1fr 1fr;
}

@media (max-width: 768px) {
    .grid--2col { grid-template-columns: 1fr; }
}

/* ------------------------------------------------------------------
   14. Item List (sites in customer edit)
   ------------------------------------------------------------------ */
.item-list { list-style: none; }

.item-list__item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: .5rem;
    padding: .75rem 1.25rem;
    border-bottom: 1px solid var(--color-border);
    font-size: .875rem;
}

.item-list__item:last-child { border-bottom: none; }

/* ------------------------------------------------------------------
   15. Login Page
   ------------------------------------------------------------------ */
.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--color-bg);
    padding: 1rem;
}

.login-box {
    width: 100%;
    max-width: 400px;
}

.login-box .card__header {
    text-align: center;
    font-size: 1.125rem;
    padding: 1.5rem;
    background: #1e1b4b;
    color: #fff;
}

/* ------------------------------------------------------------------
   16. Form row within table filters (inline)
   ------------------------------------------------------------------ */
.card__body form[method="GET"] .form-input {
    display: inline-block;
    width: auto;
}

/* ------------------------------------------------------------------
   17. Responsive – hide sidebar on small screens
   ------------------------------------------------------------------ */
@media (max-width: 900px) {
    .sidebar { display: none; }
    .main    { margin-left: 0; }
}

/* ------------------------------------------------------------------
   18. Misc
   ------------------------------------------------------------------ */
strong { font-weight: 600; }

.text-danger  { color: var(--color-danger); font-weight: 600; }
.text-success { color: var(--color-success); font-weight: 600; }
