/**
 * TapOrder – Haupt-Stylesheet
 * 
 * Design: Modern, Mobile-First, Dark/Light Mode
 * Akzentfarbe: Amber (#BA7517)
 * Font: DM Sans
 */

/* ─── CSS-Variablen (Light Mode) ──────────────────────────── */
:root {
    --color-primary:        #BA7517;
    --color-primary-light:  #FAEEDA;
    --color-primary-dark:   #854F0B;
    --color-primary-text:   #633806;

    --color-success:        #639922;
    --color-success-bg:     #EAF3DE;
    --color-success-text:   #3B6D11;

    --color-danger:         #E24B4A;
    --color-danger-bg:      #FCEBEB;
    --color-danger-text:    #A32D2D;

    --color-info:           #378ADD;
    --color-info-bg:        #E6F1FB;
    --color-info-text:      #185FA5;

    --color-warning:        #EF9F27;
    --color-warning-bg:     #FAEEDA;
    --color-warning-text:   #854F0B;

    --bg-primary:           #FFFFFF;
    --bg-secondary:         #F5F3EE;
    --bg-tertiary:          #ECEAE4;
    --bg-body:              #F5F3EE;

    --text-primary:         #1A1A18;
    --text-secondary:       #6B6A65;
    --text-tertiary:        #9C9B96;

    --border-light:         rgba(0, 0, 0, 0.08);
    --border-medium:        rgba(0, 0, 0, 0.15);
    --border-heavy:         rgba(0, 0, 0, 0.25);

    --radius-sm:            6px;
    --radius-md:            8px;
    --radius-lg:            12px;
    --radius-xl:            16px;
    --radius-pill:          9999px;

    --shadow-sm:            0 1px 2px rgba(0,0,0,0.05);
    --shadow-md:            0 2px 8px rgba(0,0,0,0.08);

    --font-family:          'DM Sans', -apple-system, BlinkMacSystemFont, sans-serif;
    --font-mono:            'JetBrains Mono', 'Fira Code', monospace;

    --sidebar-width:        220px;
    --header-height:        56px;
    --transition:           0.2s ease;
}

/* ─── Dark Mode ───────────────────────────────────────────── */
[data-theme="dark"] {
    --color-primary-light:  #412402;
    --color-primary-text:   #FAC775;

    --color-success-bg:     #173404;
    --color-success-text:   #C0DD97;

    --color-danger-bg:      #501313;
    --color-danger-text:    #F7C1C1;

    --color-info-bg:        #042C53;
    --color-info-text:      #B5D4F4;

    --color-warning-bg:     #412402;
    --color-warning-text:   #FAC775;

    --bg-primary:           #1C1C1A;
    --bg-secondary:         #262624;
    --bg-tertiary:          #2E2E2C;
    --bg-body:              #141413;

    --text-primary:         #EEEDEB;
    --text-secondary:       #A3A29D;
    --text-tertiary:        #6B6A65;

    --border-light:         rgba(255, 255, 255, 0.06);
    --border-medium:        rgba(255, 255, 255, 0.12);
    --border-heavy:         rgba(255, 255, 255, 0.20);

    --shadow-sm:            0 1px 2px rgba(0,0,0,0.2);
    --shadow-md:            0 2px 8px rgba(0,0,0,0.3);
}

/* ─── Reset & Basis ───────────────────────────────────────── */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    font-size: 16px;
    -webkit-text-size-adjust: 100%;
}

body {
    font-family: var(--font-family);
    font-weight: 400;
    line-height: 1.5;
    color: var(--text-primary);
    background: var(--bg-body);
    min-height: 100vh;
}

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

a:hover {
    color: var(--color-primary-dark);
}

img {
    max-width: 100%;
    height: auto;
}

/* ─── Typografie ──────────────────────────────────────────── */
h1, h2, h3, h4 {
    font-weight: 500;
    line-height: 1.3;
    color: var(--text-primary);
}

h1 { font-size: 1.5rem; }
h2 { font-size: 1.25rem; }
h3 { font-size: 1.1rem; }
h4 { font-size: 1rem; }

/* ─── Layout: Sidebar + Hauptbereich ──────────────────────── */
.app-layout {
    display: flex;
    min-height: 100vh;
}

.app-main {
    flex: 1;
    margin-left: var(--sidebar-width);
    padding: 1.5rem;
    max-width: 100%;
    overflow-x: hidden;
}

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

.sidebar__header {
    padding: 1rem;
    border-bottom: 1px solid var(--border-light);
}

.sidebar__logo {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.sidebar__logo-icon {
    width: 36px;
    height: 36px;
    border-radius: var(--radius-md);
    background: var(--color-primary);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.sidebar__logo-name {
    font-size: 0.9rem;
    font-weight: 600;
    display: block;
}

.sidebar__logo-role {
    font-size: 0.7rem;
    color: var(--color-primary);
    font-weight: 500;
}

.sidebar__nav {
    flex: 1;
    padding: 0.5rem;
    overflow-y: auto;
}

.sidebar__link {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.55rem 0.75rem;
    border-radius: var(--radius-md);
    font-size: 0.85rem;
    color: var(--text-secondary);
    transition: all var(--transition);
    margin-bottom: 2px;
}

.sidebar__link:hover {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

.sidebar__link.active {
    background: var(--color-primary-light);
    color: var(--color-primary-text);
    font-weight: 500;
}

.sidebar__footer {
    padding: 0.75rem 1rem;
    border-top: 1px solid var(--border-light);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.sidebar__user {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.sidebar__user-avatar {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    background: var(--bg-tertiary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    font-weight: 500;
    flex-shrink: 0;
}

.sidebar__user-name {
    font-size: 0.78rem;
    font-weight: 500;
    display: block;
}

.sidebar__user-logout {
    font-size: 0.68rem;
    color: var(--text-tertiary);
}

.sidebar__theme-toggle {
    background: var(--bg-tertiary);
    border: none;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: var(--text-secondary);
    transition: all var(--transition);
}

.sidebar__theme-toggle:hover {
    background: var(--color-primary-light);
    color: var(--color-primary);
}

.sidebar__toggle {
    display: none;
    position: fixed;
    top: 0.75rem;
    left: 0.75rem;
    z-index: 101;
    background: var(--bg-primary);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-md);
    width: 40px;
    height: 40px;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: var(--text-primary);
}

/* ─── Karten ──────────────────────────────────────────────── */
.card {
    background: var(--bg-primary);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-lg);
    padding: 1.25rem;
}

.card--accent {
    border-color: var(--color-primary);
    border-width: 2px;
}

.card__title {
    font-size: 0.95rem;
    font-weight: 500;
    margin-bottom: 0.5rem;
}

.card__subtitle {
    font-size: 0.8rem;
    color: var(--text-secondary);
}

/* ─── Metric Cards ────────────────────────────────────────── */
.metrics {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 0.75rem;
    margin-bottom: 1.5rem;
}

.metric {
    background: var(--bg-secondary);
    border-radius: var(--radius-md);
    padding: 0.85rem 1rem;
    text-align: center;
}

.metric--highlight {
    background: var(--color-primary-light);
}

.metric__label {
    font-size: 0.7rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.metric--highlight .metric__label {
    color: var(--color-primary-dark);
}

.metric__value {
    font-size: 1.35rem;
    font-weight: 500;
    margin-top: 0.2rem;
}

.metric--highlight .metric__value {
    color: var(--color-primary);
}

/* ─── Buttons ─────────────────────────────────────────────── */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    padding: 0.55rem 1.1rem;
    font-family: inherit;
    font-size: 0.85rem;
    font-weight: 500;
    border-radius: var(--radius-md);
    border: 1px solid transparent;
    cursor: pointer;
    transition: all var(--transition);
    text-decoration: none;
    line-height: 1;
}

.btn:active {
    transform: scale(0.98);
}

.btn--primary {
    background: var(--color-primary);
    color: white;
    border-color: var(--color-primary);
}

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

.btn--secondary {
    background: transparent;
    color: var(--text-secondary);
    border-color: var(--border-medium);
}

.btn--secondary:hover {
    background: var(--bg-secondary);
    color: var(--text-primary);
}

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

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

.btn--sm {
    padding: 0.35rem 0.75rem;
    font-size: 0.78rem;
}

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

/* ─── Formulare ───────────────────────────────────────────── */
.form-group {
    margin-bottom: 1rem;
}

.form-label {
    display: block;
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 0.3rem;
}

.form-input,
.form-select,
.form-textarea {
    width: 100%;
    padding: 0.6rem 0.85rem;
    font-family: inherit;
    font-size: 0.88rem;
    border: 1px solid var(--border-medium);
    border-radius: var(--radius-md);
    background: var(--bg-primary);
    color: var(--text-primary);
    transition: border-color var(--transition);
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px rgba(186, 117, 23, 0.15);
}

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

/* ─── Tabellen ────────────────────────────────────────────── */
.table-wrap {
    overflow-x: auto;
    border: 1px solid var(--border-light);
    border-radius: var(--radius-lg);
}

.table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
}

.table th {
    text-align: left;
    padding: 0.7rem 1rem;
    background: var(--bg-secondary);
    font-weight: 500;
    font-size: 0.78rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.table td {
    padding: 0.65rem 1rem;
    border-top: 1px solid var(--border-light);
}

.table tr:hover td {
    background: var(--bg-secondary);
}

/* ─── Badges ──────────────────────────────────────────────── */
.badge {
    display: inline-block;
    padding: 0.15rem 0.55rem;
    font-size: 0.7rem;
    font-weight: 500;
    border-radius: var(--radius-pill);
}

.badge--active    { background: var(--color-success-bg); color: var(--color-success-text); }
.badge--inactive  { background: var(--bg-tertiary); color: var(--text-secondary); }
.badge--new       { background: var(--color-primary-light); color: var(--color-primary-text); }
.badge--progress  { background: var(--color-info-bg); color: var(--color-info-text); }
.badge--done      { background: var(--color-success-bg); color: var(--color-success-text); }
.badge--open      { background: var(--color-warning-bg); color: var(--color-warning-text); }
.badge--paid      { background: var(--color-success-bg); color: var(--color-success-text); }

/* ─── Flash-Nachrichten ───────────────────────────────────── */
.flash {
    position: fixed;
    bottom: 1.5rem;
    left: 50%;
    transform: translateX(-50%);
    padding: 0.75rem 1.25rem;
    border-radius: var(--radius-md);
    font-size: 0.85rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    z-index: 200;
    animation: flashIn 0.3s ease;
    max-width: 90%;
    box-shadow: var(--shadow-md);
}

.flash--success { background: var(--color-success-bg); color: var(--color-success-text); }
.flash--error   { background: var(--color-danger-bg); color: var(--color-danger-text); }
.flash--info    { background: var(--color-info-bg); color: var(--color-info-text); }
.flash--warning { background: var(--color-warning-bg); color: var(--color-warning-text); }

.flash__close {
    background: none;
    border: none;
    font-size: 1.2rem;
    cursor: pointer;
    color: inherit;
    opacity: 0.7;
}

@keyframes flashIn {
    from { opacity: 0; transform: translateX(-50%) translateY(10px); }
    to   { opacity: 1; transform: translateX(-50%) translateY(0); }
}

/* ─── Page Header ─────────────────────────────────────────── */
.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
    gap: 0.75rem;
}

.page-header__title {
    font-size: 1.25rem;
    font-weight: 500;
}

.page-header__subtitle {
    font-size: 0.82rem;
    color: var(--text-secondary);
    margin-top: 0.15rem;
}

/* ─── Utilities ───────────────────────────────────────────── */
.text-center  { text-align: center; }
.text-right   { text-align: right; }
.text-muted   { color: var(--text-secondary); }
.text-sm      { font-size: 0.8rem; }
.text-xs      { font-size: 0.7rem; }
.text-primary { color: var(--color-primary) !important; }
.text-success { color: var(--color-success) !important; }
.text-danger  { color: var(--color-danger) !important; }
.mt-1  { margin-top: 0.5rem; }
.mt-2  { margin-top: 1rem; }
.mt-3  { margin-top: 1.5rem; }
.mb-1  { margin-bottom: 0.5rem; }
.mb-2  { margin-bottom: 1rem; }
.mb-3  { margin-bottom: 1.5rem; }
.gap-1 { gap: 0.5rem; }
.gap-2 { gap: 1rem; }
.d-flex    { display: flex; }
.flex-wrap { flex-wrap: wrap; }
.align-center { align-items: center; }
.justify-between { justify-content: space-between; }

/* ─── Login-Seite ─────────────────────────────────────────── */
.login-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 1rem;
}

.login-card {
    width: 100%;
    max-width: 380px;
    background: var(--bg-primary);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-xl);
    padding: 2rem;
}

.login-card__logo {
    width: 52px;
    height: 52px;
    border-radius: var(--radius-lg);
    background: var(--color-primary);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 1rem;
}

.login-card__title {
    text-align: center;
    font-size: 1.25rem;
    margin-bottom: 0.25rem;
}

.login-card__subtitle {
    text-align: center;
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-bottom: 1.5rem;
}

.login-card__error {
    background: var(--color-danger-bg);
    color: var(--color-danger-text);
    padding: 0.6rem 0.85rem;
    border-radius: var(--radius-md);
    font-size: 0.82rem;
    margin-bottom: 1rem;
}

/* ─── Responsive ──────────────────────────────────────────── */
@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
    }

    .sidebar.open {
        transform: translateX(0);
    }

    .sidebar__toggle {
        display: flex;
    }

    .app-main {
        margin-left: 0;
        padding: 1rem;
        padding-top: 3.5rem;
    }

    .metrics {
        grid-template-columns: repeat(2, 1fr);
    }

    .page-header {
        flex-direction: column;
        align-items: flex-start;
    }
}

@media (max-width: 480px) {
    .metrics {
        grid-template-columns: 1fr 1fr;
        gap: 0.5rem;
    }

    .metric {
        padding: 0.65rem 0.5rem;
    }

    .metric__value {
        font-size: 1.15rem;
    }
}
