﻿/**
 * iwim.app — Shared UI Components (Phase 2)
 * Benötigt iwim-tokens.css (CSS-Variablen).
 */
*, *::before, *::after { box-sizing: border-box; }

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

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

.container { max-width: 1200px; margin: 0 auto; padding: 0 1.5rem; }

/* Landing */
.landing {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    background: linear-gradient(160deg, var(--color-surface-accent) 0%, var(--color-bg) 50%, var(--color-surface-subtle) 100%);
}

.landing-header {
    padding: 2rem 0;
    text-align: center;
}

.landing-header h1 {
    font-size: 2.5rem;
    font-weight: 700;
    color: var(--color-primary);
    margin: 0 0 0.5rem;
    letter-spacing: -0.02em;
}

.landing-header p {
    color: var(--color-muted);
    font-size: 1.125rem;
    margin: 0;
}

.landing-main {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem 1.5rem 4rem;
}

.entry-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 2rem;
    width: 100%;
    max-width: 720px;
}

.entry-card {
    background: var(--color-surface);
    border-radius: var(--radius);
    padding: 2.5rem 2rem;
    box-shadow: var(--shadow);
    text-align: center;
    transition: transform 0.2s, box-shadow 0.2s;
    border: 1px solid var(--color-primary-alpha-08);
}

.entry-card:hover,
.entry-card--link:focus-visible {
    transform: translateY(-4px);
    box-shadow: 0 8px 32px var(--color-primary-alpha-12);
}

.entry-card--link {
    display: block;
    color: inherit;
    text-decoration: none;
    cursor: pointer;
}

.entry-card--link:hover,
.entry-card--link:focus-visible {
    text-decoration: none;
    color: inherit;
    outline: 2px solid var(--color-primary-light);
    outline-offset: 2px;
}

.entry-card--link .btn {
    pointer-events: none;
}

.entry-card .icon {
    font-size: 3rem;
    margin-bottom: 1rem;
}

.entry-card h2 {
    margin: 0 0 0.75rem;
    font-size: 1.5rem;
    color: var(--color-primary);
}

.entry-card p {
    color: var(--color-muted);
    margin: 0 0 1.5rem;
    font-size: 0.95rem;
}

.btn {
    display: inline-block;
    box-sizing: border-box;
    padding: 0.35rem 0.85rem;
    border-radius: 8px;
    font-weight: 600;
    font-size: 0.875rem;
    line-height: 1.25;
    border: none;
    cursor: pointer;
    transition: background 0.2s, transform 0.1s;
    text-decoration: none;
    vertical-align: middle;
}

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

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

.btn-primary:hover {
    background: var(--color-primary-dark);
    text-decoration: none;
    color: #fff;
}

.btn-secondary {
    background: transparent;
    color: var(--color-primary);
    border: 1px solid var(--color-primary);
}

.btn-secondary:hover {
    background: var(--color-primary);
    color: #fff;
    text-decoration: none;
}

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

.btn-sm { padding: 0.35rem 0.85rem; font-size: 0.875rem; }

.landing-footer {
    text-align: center;
    padding: 1.5rem;
    color: var(--color-muted);
    font-size: 0.875rem;
}

/* App layout */
.app-header {
    position: sticky;
    top: 0;
    z-index: 1100;
    background: var(--color-primary);
    color: #fff;
    padding: 0.75rem 0 0.65rem;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.12);
}

.app-header-inner {
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
}

.app-header-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    width: 100%;
}

.app-header-brand {
    margin: 0;
    font-size: 1.25rem;
    font-weight: 600;
    flex-shrink: 0;
}

.app-header-user {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 0.85rem;
    margin-left: auto;
    text-align: right;
    flex-wrap: wrap;
    padding: 0.4rem 0.95rem;
    background: var(--color-primary-light);
    border: 1px solid rgba(255, 255, 255, 0.22);
    border-radius: 999px;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.18);
}

.app-header-nav {
    display: flex;
    gap: 1.25rem;
    align-items: center;
    flex-wrap: wrap;
    width: 100%;
    padding-top: 0.55rem;
    border-top: 1px solid rgba(255, 255, 255, 0.18);
}

.app-header-nav a,
.app-header-logout {
    color: rgba(255, 255, 255, 0.9);
    font-size: 0.9rem;
    white-space: nowrap;
}

.app-header-nav a:hover,
.app-header-nav a.active,
.app-header-logout:hover {
    color: #fff;
    text-decoration: none;
}

.app-header-nav a.active {
    border-bottom: 2px solid var(--color-accent);
    padding-bottom: 0.1rem;
}

.app-header-logout {
    font-weight: 500;
    padding-left: 0.85rem;
    border-left: 1px solid rgba(255, 255, 255, 0.28);
}

.user-badge {
    font-size: 0.85rem;
    line-height: 1.35;
}

.user-badge-role {
    opacity: 0.92;
}

.user-badge-company {
    margin-left: 0.15rem;
}

.app-main { padding: 2rem 0 3rem; }

.page-title {
    margin: 0 0 1.5rem;
    font-size: 1.75rem;
    color: var(--color-primary);
}

.page-header-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    flex-wrap: nowrap;
    width: 100%;
    margin-bottom: 1.5rem;
}

.page-header-row .page-title {
    margin: 0;
    flex: 1 1 auto;
    min-width: 0;
}

.page-header-date {
    font-size: 1.125rem;
    font-weight: 600;
    color: var(--color-muted);
    white-space: nowrap;
    margin-left: auto;
    flex-shrink: 0;
}

.page-header-row + .page-lead {
    margin-top: -0.75rem;
    margin-bottom: 1.25rem;
}

/* Cards & tables */
.card {
    background: var(--color-surface);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 1.5rem;
    margin-bottom: 1.5rem;
    border: 1px solid var(--color-primary-alpha-06);
}

.card h3 {
    margin: 0 0 1rem;
    font-size: 1.1rem;
    color: var(--color-primary);
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 1rem;
    margin-bottom: 2rem;
}

.stat-card {
    background: var(--color-surface);
    border-radius: var(--radius);
    padding: 1.25rem;
    box-shadow: var(--shadow);
    border-left: 4px solid var(--color-primary);
}

.stat-card .value {
    font-size: 2rem;
    font-weight: 700;
    color: var(--color-primary);
}

.stat-card .label {
    color: var(--color-muted);
    font-size: 0.875rem;
}

.stat-card .label.label--upper {
    text-transform: uppercase;
    font-weight: 700;
    font-size: 0.75rem;
    letter-spacing: 0.02em;
}

.stat-card--warning { border-left-color: #eab308; }
.stat-card--info { border-left-color: var(--color-accent); }
.stat-card--success { border-left-color: #22c55e; }
.stat-card--dark {
    background: #1f2937;
    border-left-color: #4b5563;
}
.stat-card--dark .label { color: #d1d5db; }
.stat-card--dark .value { color: #fff; }

.stat-card--link {
    display: block;
    color: inherit;
    text-decoration: none;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}
.stat-card--link:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 32px var(--color-primary-alpha-12);
    color: inherit;
    text-decoration: none;
}

.stats-grid--4 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}
@media (min-width: 1024px) {
    .stats-grid--4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}

.dashboard-layout {
    display: grid;
    grid-template-columns: 1fr;
    gap: 2rem;
    margin-bottom: 2rem;
}
@media (min-width: 1024px) {
    .dashboard-layout { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); }
}

.section-title {
    margin: 0 0 1rem;
    font-size: 1.35rem;
    font-weight: 700;
    color: var(--color-text);
}

.nav-cards {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1.5rem;
}
@media (min-width: 768px) {
    .nav-cards { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

.nav-card {
    display: flex;
    align-items: flex-start;
    gap: 1rem;
    background: var(--color-surface);
    border-radius: var(--radius);
    padding: 1.5rem;
    box-shadow: var(--shadow);
    border: 1px solid var(--color-primary-alpha-06);
    color: inherit;
    text-decoration: none;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}
.nav-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 32px var(--color-primary-alpha-12);
    color: inherit;
    text-decoration: none;
}
.nav-card-icon {
    flex-shrink: 0;
    width: 3rem;
    height: 3rem;
    border-radius: 999px;
    display: flex;
    align-items: center;
    justify-content: center;
}
.nav-card-icon svg { width: 1.5rem; height: 1.5rem; }
.nav-card-icon--blue { background: #dbeafe; color: #2563eb; }
.nav-card-icon--green { background: #dcfce7; color: #16a34a; }
.nav-card-icon--yellow { background: #fef9c3; color: #ca8a04; }
.nav-card-icon--purple { background: #f3e8ff; color: #9333ea; }
.nav-card-body h4 {
    margin: 0 0 0.35rem;
    font-size: 1.15rem;
    color: var(--color-text);
}
.nav-card-body p {
    margin: 0;
    color: var(--color-muted);
    font-size: 0.95rem;
    line-height: 1.45;
}

.activity-list {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}
.activity-item {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
}
.activity-icon {
    flex-shrink: 0;
    width: 2rem;
    height: 2rem;
    border-radius: 999px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
}
.activity-icon svg { width: 1.1rem; height: 1.1rem; }
.activity-icon--success { background: #22c55e; }
.activity-icon--info { background: var(--color-accent); }
.activity-text {
    margin: 0;
    font-size: 0.9rem;
    color: var(--color-text);
    line-height: 1.45;
}
.activity-meta {
    margin: 0.15rem 0 0;
    font-size: 0.8rem;
    color: var(--color-muted);
}

.table-wrap { overflow-x: auto; }

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

th, td {
    padding: 0.75rem 1rem;
    text-align: left;
    border-bottom: 1px solid var(--color-border);
}

th {
    background: var(--color-surface-subtle);
    font-weight: 600;
    color: var(--color-primary);
}

tr:hover td { background: var(--color-surface-muted); }

.badge {
    display: inline-block;
    padding: 0.2rem 0.6rem;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 600;
}

.badge-success { background: #d4edda; color: #155724; }
.badge-danger { background: #f8d7da; color: #721c24; }
.badge-warning { background: #fff3cd; color: #856404; }
.badge-info { background: #d1ecf1; color: #0c5460; }

/* Forms */
.form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 1rem;
}

.checkbox-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem 1.25rem;
}

.checkbox-inline {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    font-size: 0.9rem;
}

.quick-user-panel {
    margin: 0.75rem 0 1rem;
    padding: 1rem;
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    background: var(--color-surface-subtle);
}

.quick-user-panel h4 {
    margin: 0 0 0.75rem;
    font-size: 0.95rem;
    color: var(--color-primary);
}

#location_responsibles {
    width: 100%;
    min-height: 6.5rem;
}

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

.form-group label {
    display: block;
    margin-bottom: 0.35rem;
    font-weight: 500;
    font-size: 0.9rem;
}

.form-group label.checkbox-inline {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    margin-bottom: 0;
    font-weight: normal;
    cursor: pointer;
}

.form-group label.checkbox-inline input[type="checkbox"] {
    width: auto;
    padding: 0;
    border: none;
    border-radius: 0;
    box-shadow: none;
    flex-shrink: 0;
}

.form-group label.checkbox-inline input[type="checkbox"]:focus {
    outline: none;
    border-color: transparent;
    box-shadow: none;
}

.help-text {
    margin: 0 0 0.75rem;
    font-size: 0.8rem;
    color: var(--color-muted);
    line-height: 1.4;
}

input[type="range"] {
    width: 100%;
    margin-top: 0.35rem;
}

.color-input-row {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

.color-input-row input[type="color"] {
    width: 44px;
    height: 36px;
    padding: 2px;
    border: 1px solid var(--color-border-input);
    border-radius: 8px;
    cursor: pointer;
    flex-shrink: 0;
}

.color-input-row input[type="text"] {
    flex: 1;
    min-width: 0;
    padding: 0.6rem 0.75rem;
    border: 1px solid var(--color-border-input);
    border-radius: 8px;
    font-family: inherit;
    font-size: 0.9rem;
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 0.6rem 0.75rem;
    border: 1px solid var(--color-border-input);
    border-radius: 8px;
    font-size: 0.95rem;
    font-family: inherit;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px var(--color-primary-alpha-15);
}

.form-actions {
    display: flex;
    gap: 0.75rem;
    margin-top: 1rem;
    flex-wrap: wrap;
}

.alert {
    padding: 0.875rem 1rem;
    border-radius: 8px;
    margin-bottom: 1rem;
    font-size: 0.9rem;
}

.alert-error { background: #f8d7da; color: #721c24; border: 1px solid #f5c6cb; }
.alert-success { background: #d4edda; color: #155724; border: 1px solid #c3e6cb; }

/* Login */
.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(160deg, var(--color-surface-accent) 0%, var(--color-bg) 100%);
    padding: 1.5rem;
}

.login-card {
    background: var(--color-surface);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 2.5rem;
    width: 100%;
    max-width: 420px;
}

.login-card h1,
.login-card-brand {
    text-align: center;
    color: var(--color-primary);
    margin: 0 0 0.5rem;
    font-size: 1.75rem;
    font-weight: 700;
    line-height: 1.25;
}

.login-card-brand-line {
    display: block;
}

.login-card-brand-line + .login-card-brand-line {
    margin-top: 0.15rem;
}

.login-card .subtitle {
    text-align: center;
    color: var(--color-muted);
    margin: 0 0 2rem;
    font-size: 0.95rem;
}
.form-hint {
    margin: 0 0 0.75rem;
    font-size: 0.85rem;
    color: var(--color-muted);
    line-height: 1.45;
}

.page-lead {
    color: var(--color-muted);
    margin-top: -1rem;
    margin-bottom: 1.25rem;
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.form-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 1rem;
}

.app-header-brand-link {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    color: #fff;
    text-decoration: none;
}

.app-header-brand-link:hover {
    color: #fff;
    text-decoration: none;
}

.app-header-logo {
    width: 3rem;
    height: 3rem;
    flex-shrink: 0;
}

.app-header-mobile-toggle {
    display: none;
    background: transparent;
    border: none;
    color: #fff;
    cursor: pointer;
    padding: 0.25rem;
    margin-left: auto;
}

.app-header-mobile-toggle svg {
    width: 2rem;
    height: 2rem;
}

.app-header-nav-mobile {
    display: none;
    flex-direction: column;
    gap: 0.2rem;
    width: 100%;
    padding-top: 0.5rem;
}

.app-header-nav-mobile.is-open {
    display: flex;
}

.app-header-nav-mobile a {
    display: block;
    padding: 0.5rem 0.75rem;
    border-radius: 6px;
    color: rgba(255, 255, 255, 0.92);
    text-decoration: none;
}

.app-header-nav-mobile a:hover,
.app-header-nav-mobile a.active {
    background: rgba(255, 255, 255, 0.12);
    color: #fff;
    text-decoration: none;
}

.app-header-logout-btn {
    display: inline-block;
    padding: 0.45rem 0.95rem;
    border-radius: 6px;
    background: var(--color-danger);
    color: #fff;
    font-weight: 600;
    font-size: 0.9rem;
    text-decoration: none;
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.app-header-logout-btn:hover {
    filter: brightness(0.95);
    color: #fff;
    text-decoration: none;
}

.login-card--wide {
    max-width: 28rem;
}

.login-card-logo {
    display: block;
    width: auto;
    max-width: 12rem;
    height: auto;
    margin: 0 auto 1.5rem;
}

@keyframes iwim-login-bounce {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-12px); }
}

.login-card-logo:hover {
    animation: iwim-login-bounce 0.6s ease-in-out;
}

.login-footer-links {
    text-align: center;
    margin-top: 1.5rem;
    font-size: 0.875rem;
    color: var(--color-muted);
}

.login-footer-links a {
    color: var(--color-muted);
}

.login-footer-links a:hover {
    color: var(--color-primary);
}

.btn-block {
    width: 100%;
    text-align: center;
}

.btn__icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.25rem;
    height: 1.25rem;
    flex-shrink: 0;
    color: inherit;
}

.btn__icon-svg {
    display: block;
    width: 1.25rem;
    height: 1.25rem;
    max-width: 1.25rem;
    max-height: 1.25rem;
}

.btn--icon-mobile {
    gap: 0.35rem;
}

.btn--icon-mobile .btn__icon {
    display: none;
}

/* Schmal ODER Touch-Phone/Tablet (z. B. Galaxy Ultra Querformat ~824px) */
@media (max-width: 768px), ((hover: none) and (pointer: coarse) and (max-width: 1200px)) {
    .btn--icon-mobile .btn__icon {
        display: inline-flex;
        width: 1.25rem;
        height: 1.25rem;
    }

    .btn--icon-mobile {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        gap: 0;
    }

    .btn--icon-mobile .btn__label {
        display: none;
    }

    .action-bar,
    .item-actions,
    .location-list-row--actions {
        flex-wrap: nowrap;
        gap: 0.35rem;
    }

    .table-wrap td:last-child,
    table td:last-child {
        white-space: nowrap;
    }

    .app-header-top {
        flex-wrap: wrap;
        row-gap: 0.5rem;
    }

    .app-header-brand-link {
        flex: 1 1 auto;
        min-width: 0;
    }

    .app-header-user {
        order: 10;
        width: 100%;
        margin-left: 0;
        justify-content: space-between;
        align-items: center;
        border-radius: 8px;
        flex-wrap: nowrap;
        padding: 0.5rem 0.85rem;
        text-align: left;
    }

    .app-header-user .user-badge {
        flex: 1 1 auto;
        min-width: 0;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .app-header-logout {
        flex-shrink: 0;
    }

    .app-header-mobile-toggle {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        flex-shrink: 0;
    }

    .app-header-nav {
        display: none;
    }
}
