/* ===== DESIGN TOKENS ===== */

:root {
    /* Hitzefrei Brand Colors */
    --brand-cyan: #00BBE4;       /* Pantone 2202 */
    --brand-lavender: #8B8FC7;   /* Pantone 7452 */
    --brand-coral: #F07272;      /* Pantone 178 */
    --brand-sand: #F5D47A;       /* Pantone 7403 */
    --brand-brown: #6B4A3A;      /* Pantone 4695 */
    --brand-green: #82C341;      /* Pantone 7403 green */

    /* Primary */
    --primary: #00BBE4;
    --primary-dark: #0095B7;
    --primary-light: #E0F7FA;

    /* Semantic */
    --success: #82C341;
    --success-light: #E8F5D9;
    --warning: #F5D47A;
    --warning-light: #FEF3CD;
    --danger: #F07272;
    --danger-light: #FDE8E8;

    /* Gray Scale */
    --gray-50: #f9fafb;
    --gray-100: #f3f4f6;
    --gray-200: #e5e5e5;
    --gray-300: #d1d5db;
    --gray-400: #9ca3af;
    --gray-500: #6b7280;
    --gray-600: #4b5563;
    --gray-700: #374151;
    --gray-800: #1f2937;
    --gray-900: #111827;

    /* Aliases */
    --text: var(--gray-800);
    --text-light: var(--gray-500);
    --bg: var(--gray-50);
    --card: #ffffff;
    --border: var(--gray-200);

    /* Elevation */
    --shadow: 0 1px 3px rgba(0,0,0,0.1);
    --shadow-md: 0 4px 6px rgba(0,0,0,0.07), 0 2px 4px rgba(0,0,0,0.06);
    --shadow-lg: 0 4px 12px rgba(0,0,0,0.1);

    /* Shape */
    --radius: 8px;
    --radius-lg: 12px;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.5;
}

/* ===== LOGIN PAGE ===== */

.login-container {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    background: linear-gradient(135deg, #00BBE4 0%, #8B8FC7 100%);
}

.login-card {
    background: var(--card);
    border-radius: 16px;
    padding: 40px;
    width: 100%;
    max-width: 400px;
    box-shadow: var(--shadow-lg);
}

.login-card h1 {
    text-align: center;
    font-size: 24px;
    margin-bottom: 8px;
    color: var(--text);
}

.login-card .subtitle {
    text-align: center;
    color: var(--text-light);
    font-size: 14px;
    margin-bottom: 32px;
}

/* ===== FORMS ===== */

.form-group {
    margin-bottom: 16px;
}

.form-group label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 4px;
}

.form-group input,
.form-group textarea,
.form-group select {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 14px;
    transition: border-color 0.2s;
    background: var(--card);
    color: var(--text);
}

.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-light);
}

/* ===== BUTTONS ===== */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 10px 20px;
    border: none;
    border-radius: var(--radius);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
}

.btn-primary {
    background: var(--primary);
    color: white;
}

.btn-primary:hover { background: var(--primary-dark); }
.btn-primary:disabled { opacity: 0.6; cursor: not-allowed; }

.btn-success { background: var(--success); color: white; }
.btn-success:hover { background: #6BA133; }

.btn-danger { background: var(--danger); color: white; }
.btn-danger:hover { background: #D95858; }

.btn-warning { background: var(--warning); color: var(--text); }
.btn-warning:hover { background: #DDB95E; }

.btn-secondary { background: var(--gray-200); color: var(--text); }
.btn-secondary:hover { background: var(--gray-300); }

.btn-outline {
    background: none;
    border: 1px solid var(--border);
    color: var(--text);
}
.btn-outline:hover { background: var(--gray-50); border-color: var(--gray-300); }

.btn-sm { padding: 8px 14px; font-size: 13px; min-height: 36px; }
.btn-full { width: 100%; }

.error-msg {
    background: var(--danger-light);
    color: var(--danger);
    border: 1px solid #F5C0C0;
    border-radius: var(--radius);
    padding: 10px 12px;
    font-size: 13px;
    margin-bottom: 16px;
    display: none;
}

.error-msg.visible { display: block; }

/* ===== APP HEADER ===== */

.app-header {
    background: var(--card);
    border-bottom: 1px solid var(--border);
    padding: 12px 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: var(--shadow);
}

.app-header h1 {
    font-size: 18px;
    color: var(--primary);
}

.app-header .header-left {
    display: flex;
    align-items: center;
    gap: 16px;
}

.app-header .back-link {
    text-decoration: none;
    color: var(--text-light);
    font-size: 14px;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 4px;
    transition: color 0.2s;
}

.app-header .back-link:hover {
    color: var(--primary);
}

.app-header .user-info {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 13px;
    color: var(--text-light);
}

.app-header .user-name {
    font-weight: 600;
    color: var(--text);
}

.app-header .role-badge {
    background: var(--primary-light);
    color: var(--primary);
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
}

/* ===== HAMBURGER MENU ===== */

.hamburger {
    display: none;
    background: none;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 6px 8px;
    cursor: pointer;
    font-size: 18px;
    line-height: 1;
    color: var(--text);
}

/* ===== APP NAV ===== */

.app-nav {
    background: var(--card);
    border-bottom: 1px solid var(--border);
    padding: 8px 24px;
    display: flex;
    gap: 8px;
    position: sticky;
    top: 57px;
    z-index: 99;
    overflow-x: auto;
}

.nav-btn {
    padding: 8px 16px;
    border: 1px solid var(--border);
    border-radius: 20px;
    background: var(--card);
    font-size: 13px;
    cursor: pointer;
    white-space: nowrap;
    transition: all 0.2s;
}

.nav-btn:hover { border-color: var(--primary); color: var(--primary); }
.nav-btn.active { background: var(--primary); color: white; border-color: var(--primary); }

/* ===== PAGE CONTENT ===== */

.page-content {
    max-width: 1400px;
    margin: 20px auto;
    padding: 0 24px;
}

/* ===== CARDS ===== */

.card {
    background: var(--card);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    overflow: hidden;
}

.card-header {
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 12px;
}

.card-title {
    font-size: 18px;
    font-weight: 700;
}

.card-actions {
    display: flex;
    gap: 8px;
    align-items: center;
}

.card-actions select {
    padding: 6px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 13px;
    background: white;
}

/* ===== BADGES ===== */

.badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 600;
}

.badge-success { background: var(--success-light); color: #5A8E2D; }
.badge-danger { background: var(--danger-light); color: #C04545; }
.badge-warning { background: var(--warning-light); color: #6B5A20; }
.badge-info { background: var(--primary-light); color: var(--primary-dark); }

/* ===== STAT CARDS ===== */

.stat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
    margin-bottom: 20px;
}

.stat-card {
    background: var(--card);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    padding: 20px;
    text-align: center;
    border-top: 3px solid var(--primary);
}

.stat-card.green { border-top-color: var(--success); }
.stat-card.red { border-top-color: var(--danger); }
.stat-card.orange { border-top-color: var(--warning); }

.stat-card .stat-value,
.stat-card .value {
    font-size: 28px;
    font-weight: 700;
    margin: 4px 0;
    color: var(--text);
}

.stat-card .stat-label,
.stat-card .label {
    font-size: 12px;
    color: var(--text-light);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* KPI-Card Alias (Marketing/Finanzen nutzen .kpi-card statt .stat-card) */
.kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
    margin-bottom: 20px;
}

.kpi-card {
    background: var(--card);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    padding: 20px;
}

.kpi-card .kpi-label {
    font-size: 13px;
    color: var(--text-light);
    margin-bottom: 4px;
}

.kpi-card .kpi-value {
    font-size: 28px;
    font-weight: 700;
    color: var(--text);
}

.kpi-card .kpi-sub {
    font-size: 12px;
    color: var(--text-light);
    margin-top: 4px;
}

/* ===== TABLES ===== */

.table-wrap { overflow-x: auto; }

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

th {
    background: var(--gray-50);
    padding: 10px 12px;
    text-align: left;
    font-weight: 600;
    font-size: 12px;
    text-transform: uppercase;
    color: var(--text-light);
    border-bottom: 2px solid var(--border);
    white-space: nowrap;
}

td {
    padding: 10px 12px;
    border-bottom: 1px solid var(--border);
}

tr:hover { background: var(--gray-50); }

/* ===== TOOLBAR ===== */

.toolbar {
    display: flex;
    gap: 8px;
    margin-bottom: 16px;
    flex-wrap: wrap;
    align-items: center;
}

/* ===== MODAL ===== */

.modal-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.5);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 16px;
    animation: fadeIn 0.15s ease;
}

.modal-overlay.active {
    display: flex;
}

.modal {
    background: var(--card);
    border-radius: var(--radius-lg);
    padding: 24px;
    max-width: 500px;
    width: 100%;
    max-height: 85vh;
    overflow-y: auto;
    box-shadow: 0 20px 60px rgba(0,0,0,0.2);
    animation: modalSlideIn 0.2s ease;
}

.modal h3 {
    font-size: 18px;
    margin-bottom: 16px;
    color: var(--text);
}

.modal .btn-row {
    display: flex;
    gap: 8px;
    justify-content: flex-end;
    margin-top: 20px;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes modalSlideIn {
    from { transform: translateY(-10px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

/* ===== CONFIRM DIALOG ===== */

.confirm-dialog .confirm-icon {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 16px;
    font-size: 24px;
}

.confirm-dialog .confirm-icon.danger {
    background: var(--danger-light);
}

.confirm-dialog .confirm-icon.warning {
    background: var(--warning-light);
}

.confirm-dialog .confirm-msg {
    text-align: center;
    font-size: 15px;
    color: var(--text);
    margin-bottom: 8px;
    font-weight: 600;
}

.confirm-dialog .confirm-detail {
    text-align: center;
    font-size: 13px;
    color: var(--text-light);
    margin-bottom: 20px;
}

/* ===== EMPTY STATE ===== */

.empty-state {
    text-align: center;
    color: var(--text-light);
    padding: 48px 20px;
    font-size: 14px;
}

.empty-state .empty-icon {
    font-size: 48px;
    margin-bottom: 12px;
    opacity: 0.6;
}

.empty-state .empty-title {
    font-size: 16px;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 4px;
}

.empty-state .empty-text {
    color: var(--text-light);
    margin-bottom: 16px;
}

/* ===== TOAST ===== */

.toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 10000;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.toast {
    padding: 12px 20px;
    border-radius: var(--radius);
    color: white;
    font-size: 13px;
    font-weight: 500;
    box-shadow: var(--shadow-lg);
    animation: toastSlideIn 0.3s ease;
    max-width: 350px;
}

.toast.success { background: var(--success); }
.toast.error { background: var(--danger); }
.toast.warning { background: var(--warning); color: var(--text); }
.toast.info { background: var(--primary); }

@keyframes toastSlideIn {
    from { transform: translateX(100%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

/* ===== LOADING ===== */

.loading {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 40px;
    color: var(--text-light);
}

.spinner {
    width: 24px;
    height: 24px;
    border: 3px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin-right: 12px;
}

.btn .spinner {
    width: 16px;
    height: 16px;
    border-width: 2px;
    margin-right: 0;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ===== CHART ===== */

.chart-container {
    position: relative;
    width: 100%;
    height: 300px;
    margin: 16px 0;
}

/* ===== MODULE CARDS (Dashboard Home) ===== */

.module-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 16px;
    margin-top: 24px;
}

.module-card {
    cursor: pointer;
    border: 2px solid var(--border);
    transition: border-color 0.2s, box-shadow 0.2s;
    border-radius: var(--radius-lg);
    background: var(--card);
    overflow: hidden;
}

.module-card:hover {
    border-color: var(--primary);
    box-shadow: var(--shadow-md);
}

.module-card-body {
    padding: 24px;
    text-align: center;
}

.module-icon {
    font-size: 36px;
    margin-bottom: 8px;
}

.module-title {
    font-size: 16px;
    font-weight: 700;
    color: var(--text);
}

.module-desc {
    font-size: 13px;
    color: var(--text-light);
    margin-top: 4px;
}

/* ===== FORM ROWS (Grid Layouts) ===== */

.form-row { display: grid; gap: 16px; }
.form-row-2 { grid-template-columns: 1fr 1fr; }
.form-row-3 { grid-template-columns: 1fr 1fr 1fr; }
.form-row-4 { grid-template-columns: repeat(4, 1fr); }

/* ===== SECTION TOTAL ===== */

.section-total {
    display: flex;
    justify-content: flex-end;
    padding: 12px 0;
    font-weight: 700;
    font-size: 16px;
    border-top: 2px solid var(--primary);
}

.section-total span { margin-left: 8px; }

/* ===== ACCORDION ===== */

.accordion {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    margin-bottom: 12px;
    overflow: hidden;
}

.accordion-header {
    padding: 12px 16px;
    background: var(--bg);
    cursor: pointer;
    font-weight: 600;
    display: flex;
    justify-content: space-between;
    align-items: center;
    user-select: none;
}

.accordion-header:hover { background: var(--gray-200); }

.accordion-header .arrow {
    transition: transform 0.3s;
    font-size: 12px;
}

.accordion-header.open .arrow { transform: rotate(90deg); }

.accordion-body { padding: 16px; display: none; }
.accordion-body.open { display: block; }

/* ===== TAB SYSTEM ===== */

.tab { display: none; }
.tab.active { display: block; }

/* ===== UPLOAD ZONE ===== */

.upload-zone {
    border: 2px dashed var(--border);
    border-radius: var(--radius);
    padding: 24px;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s;
    background: var(--gray-50);
}

.upload-zone:hover,
.upload-zone.dragover {
    border-color: var(--primary);
    background: var(--primary-light);
}

.upload-zone p {
    color: var(--text-light);
    font-size: 14px;
    margin: 4px 0;
}

.upload-zone input[type="file"] { display: none; }

/* ===== UTILITY ===== */

.hidden { display: none !important; }
.text-center { text-align: center; }
.text-right { text-align: right; }
.text-muted { color: var(--text-light); }
.font-bold { font-weight: 700; }
.mt-1 { margin-top: 8px; }
.mt-2 { margin-top: 16px; }
.mt-3 { margin-top: 24px; }
.mb-1 { margin-bottom: 8px; }
.mb-2 { margin-bottom: 16px; }
.gap-1 { gap: 8px; }
.gap-2 { gap: 16px; }
.p-0 { padding: 0; }
.p-3 { padding: 24px; }

/* ===== RESPONSIVE ===== */

@media (max-width: 768px) {
    .app-header { padding: 10px 16px; }
    .app-header h1 { font-size: 16px; }
    .page-content { padding: 0 12px; margin: 12px auto; }
    .login-card { padding: 24px; }
    .card-header { flex-direction: column; align-items: flex-start; }
    .stat-grid { grid-template-columns: 1fr 1fr; }
    .modal { width: 95vw; padding: 16px; max-height: 90vh; }
    .module-grid { grid-template-columns: 1fr; }
    .form-row-2, .form-row-3, .form-row-4 { grid-template-columns: 1fr; }

    /* Hamburger responsive nav */
    .hamburger { display: block; }
    .app-nav {
        flex-direction: column;
        padding: 0 16px;
        max-height: 0;
        overflow: hidden;
        border-bottom: none;
        transition: max-height 0.3s ease, padding 0.3s ease;
    }
    .app-nav.open {
        max-height: 500px;
        padding: 8px 16px 12px;
        border-bottom: 1px solid var(--border);
    }
    .nav-btn { width: 100%; text-align: left; }
}

@media (max-width: 480px) {
    .app-header { padding: 8px 12px; }
    .app-header h1 { font-size: 14px; }
    .stat-grid { grid-template-columns: 1fr; }
    .modal { width: 100vw; max-width: 100vw; border-radius: var(--radius) var(--radius) 0 0; max-height: 95vh; padding: 14px; }
}
