/* =============================================================================
   Calmi – Farbschemata
   ============================================================================= */

/* Schema A: Ocean (Standard) */
:root, [data-theme="ocean"] {
    --primary: #3D4D6A;
    --primary-light: #5a6d8a;
    --primary-dark: #2c3a52;
    --accent: #80C29F;
    --accent-dark: #5fa882;
    --bg: #f4f7f6;
    --bg-card: #ffffff;
    --text: #2d3748;
    --text-muted: #718096;
    --border: #e2e8f0;
    --success: #80C29F;
    --danger: #e53e3e;
    --warning: #d69e2e;
    --info: #3D4D6A;
    --sidebar-bg: #3D4D6A;
    --sidebar-hover: rgba(128,194,159,0.15);
    --sidebar-active: rgba(128,194,159,0.25);
    --sidebar-text: rgba(255,255,255,0.8);
    --sidebar-text-active: #ffffff;
}

/* Schema B: Violet */
[data-theme="violet"] {
    --primary: #3F225C;
    --primary-light: #7C4F96;
    --primary-dark: #2e1845;
    --accent: #7C4F96;
    --accent-dark: #5e3a73;
    --bg: #f5f0f8;
    --bg-card: #ffffff;
    --text: #2d3748;
    --text-muted: #718096;
    --border: #e2e0e8;
    --success: #7C4F96;
    --danger: #e53e3e;
    --warning: #d69e2e;
    --info: #3F225C;
    --sidebar-bg: #3F225C;
    --sidebar-hover: rgba(124,79,150,0.25);
    --sidebar-active: rgba(214,237,247,0.2);
    --sidebar-text: rgba(214,237,247,0.8);
    --sidebar-text-active: #D6EDF7;
}

/* =============================================================================
   Reset & Base
   ============================================================================= */

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

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

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

/* =============================================================================
   Layout
   ============================================================================= */

.app-wrapper { display: flex; min-height: 100vh; }

/* =============================================================================
   Sidebar – ein-/ausklappbar
   ============================================================================= */

.sidebar {
    width: 240px;
    min-width: 240px;
    background: var(--sidebar-bg);
    color: white;
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    overflow-y: auto;
    z-index: 100;
    transition: width 0.25s ease, min-width 0.25s ease;
    display: flex;
    flex-direction: column;
}

.sidebar.collapsed {
    width: 60px;
    min-width: 60px;
}

.sidebar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem;
    border-bottom: 1px solid rgba(255,255,255,0.1);
    min-height: 56px;
}

.sidebar-logo-link {
    display: flex;
    align-items: center;
    text-decoration: none;
}

.sidebar-logo-link:hover { text-decoration: none; }

.sidebar-logo {
    height: 32px;
    width: auto;
    transition: opacity 0.2s;
}

.sidebar-toggle {
    background: none;
    border: none;
    color: rgba(255,255,255,0.6);
    cursor: pointer;
    font-size: 1.2rem;
    padding: 0.25rem;
    line-height: 1;
    transition: color 0.15s;
    flex-shrink: 0;
}

.sidebar-toggle:hover { color: white; }

/* Suchfeld in Sidebar */
.sidebar-search {
    padding: 0.5rem 0.75rem;
    position: relative;
}

.sidebar-search input {
    width: 100%;
    font-size: 0.8rem;
    padding: 0.4rem 2rem 0.4rem 0.6rem;
    background: rgba(255,255,255,0.1);
    border: 1px solid rgba(255,255,255,0.2);
    border-radius: 6px;
    color: white;
    transition: all 0.15s;
}

.sidebar-search input::placeholder { color: rgba(255,255,255,0.4); }
.sidebar-search input:focus {
    background: rgba(255,255,255,0.15);
    border-color: rgba(255,255,255,0.4);
    outline: none;
}

.search-clear {
    position: absolute;
    right: 1rem;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    color: rgba(255,255,255,0.4);
    cursor: pointer;
    font-size: 0.9rem;
    padding: 0.2rem;
    line-height: 1;
    display: none;
}

.search-clear:hover { color: rgba(255,255,255,0.8); }
.sidebar-search input:not(:placeholder-shown) ~ .search-clear { display: block; }

/* Nav */
.sidebar-nav { list-style: none; padding: 0.5rem 0; flex: 1; }

.sidebar-nav li a {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.7rem 1rem;
    color: var(--sidebar-text);
    text-decoration: none;
    transition: all 0.15s;
    font-size: 0.9rem;
    white-space: nowrap;
    overflow: hidden;
}

.sidebar-nav li a:hover {
    background: var(--sidebar-hover);
    color: var(--sidebar-text-active);
    text-decoration: none;
}

.sidebar-nav li a.active {
    background: var(--sidebar-active);
    color: var(--sidebar-text-active);
}

.sidebar-nav li a .nav-icon {
    font-size: 1.1rem;
    width: 1.5rem;
    min-width: 1.5rem;
    text-align: center;
}

.nav-label { transition: opacity 0.2s; }

.sidebar-divider {
    border-top: 1px solid rgba(255,255,255,0.1);
    margin: 0.5rem 1rem;
}

.sidebar-section-title {
    padding: 0.5rem 1rem 0.25rem;
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: rgba(255,255,255,0.4);
    white-space: nowrap;
    overflow: hidden;
}

.sidebar-footer {
    padding: 0.75rem 1rem;
    font-size: 0.75rem;
    color: rgba(255,255,255,0.4);
    border-top: 1px solid rgba(255,255,255,0.1);
    white-space: nowrap;
    overflow: hidden;
}

/* Collapsed state */
.sidebar.collapsed .sidebar-search,
.sidebar.collapsed .nav-label,
.sidebar.collapsed .sidebar-section-title,
.sidebar.collapsed .sidebar-footer,
.sidebar.collapsed .sidebar-logo { display: none; }

.sidebar.collapsed .sidebar-header { justify-content: center; padding: 0.75rem 0.5rem; }
.sidebar.collapsed .sidebar-nav li a { justify-content: center; padding: 0.7rem 0.5rem; gap: 0; }
.sidebar.collapsed .sidebar-divider { margin: 0.5rem 0.5rem; }

/* =============================================================================
   Main Content
   ============================================================================= */

.main-content {
    flex: 1;
    margin-left: 240px;
    padding: 1.5rem 2rem;
    min-height: 100vh;
    transition: margin-left 0.25s ease;
}

.sidebar.collapsed ~ .main-content { margin-left: 60px; }

/* =============================================================================
   Page Header
   ============================================================================= */

.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--border);
}

.page-header h1 {
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--primary-dark);
}

/* =============================================================================
   Cards
   ============================================================================= */

.card {
    background: var(--bg-card);
    border-radius: 8px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
    border: 1px solid var(--border);
    padding: 1.5rem;
    margin-bottom: 1.5rem;
}

.card-title {
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: 1rem;
    color: var(--primary-dark);
}

/* =============================================================================
   Forms
   ============================================================================= */

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

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

.form-control {
    width: 100%;
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 0.9rem;
    transition: border-color 0.15s;
    background: white;
    color: var(--text);
}

.form-control:focus {
    outline: none;
    border-color: var(--primary-light);
    box-shadow: 0 0 0 3px rgba(61,77,106,0.12);
}

textarea.form-control { min-height: 120px; resize: vertical; }
select.form-control { appearance: auto; cursor: pointer; }

.form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0 1.5rem;
}

.form-grid .form-group.full-width { grid-column: 1 / -1; }

/* =============================================================================
   Buttons
   ============================================================================= */

.btn {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.5rem 1rem;
    border-radius: 6px;
    font-size: 0.85rem;
    font-weight: 500;
    border: 1px solid transparent;
    cursor: pointer;
    transition: all 0.15s;
    text-decoration: none;
    line-height: 1.4;
}

.btn:hover { text-decoration: none; }

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

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

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

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

.btn-secondary { background: #edf2f7; color: var(--text); border-color: var(--border); }
.btn-secondary:hover { background: #e2e8f0; color: var(--text); }

.btn-sm { padding: 0.3rem 0.6rem; font-size: 0.8rem; }
.btn-group { display: flex; gap: 0.5rem; flex-wrap: wrap; }

/* =============================================================================
   Tables
   ============================================================================= */

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

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

th {
    text-align: left;
    padding: 0.6rem 0.75rem;
    background: var(--bg);
    border-bottom: 2px solid var(--border);
    font-weight: 600;
    font-size: 0.8rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

td {
    padding: 0.6rem 0.75rem;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}

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

/* =============================================================================
   Alerts
   ============================================================================= */

.alert {
    padding: 0.75rem 1rem;
    border-radius: 6px;
    margin-bottom: 1rem;
    font-size: 0.9rem;
    border: 1px solid transparent;
}

.alert-success { background: #f0fff4; color: #22543d; border-color: #c6f6d5; }
.alert-danger { background: #fff5f5; color: #742a2a; border-color: #fed7d7; }
.alert-warning { background: #fffff0; color: #744210; border-color: #fefcbf; }
.alert-info { background: #ebf8ff; color: #2a4365; border-color: #bee3f8; }

/* =============================================================================
   Badges
   ============================================================================= */

.badge {
    display: inline-block;
    padding: 0.15rem 0.5rem;
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 500;
}

.badge-admin { background: #feebc8; color: #7b341e; }
.badge-mitarbeiter { background: #bee3f8; color: #2a4365; }
.badge-active { background: #c6f6d5; color: #22543d; }
.badge-inactive { background: #fed7d7; color: #742a2a; }
.badge-category { background: #e9d8fd; color: #44337a; }

/* =============================================================================
   Search bar (page content)
   ============================================================================= */

.search-bar {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1rem;
    max-width: 400px;
}

.search-bar input { flex: 1; }

.search-field-wrapper {
    position: relative;
    flex: 1;
}

.search-field-wrapper input { width: 100%; padding-right: 2rem; }

.search-field-clear {
    position: absolute;
    right: 0.5rem;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 1rem;
    padding: 0.2rem;
    line-height: 1;
    display: none;
}

.search-field-wrapper input:not(:placeholder-shown) ~ .search-field-clear { display: block; }
.search-field-clear:hover { color: var(--text); }

/* =============================================================================
   Folders (Belegesammlung)
   ============================================================================= */

.folder-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 1rem;
}

.folder-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 1.25rem 1rem;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 8px;
    text-decoration: none;
    color: var(--text);
    transition: all 0.15s;
    text-align: center;
}

.folder-item:hover {
    border-color: var(--primary-light);
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
    text-decoration: none;
    color: var(--text);
}

.folder-icon { font-size: 2rem; margin-bottom: 0.5rem; }
.folder-name { font-weight: 500; font-size: 0.9rem; }
.folder-count { font-size: 0.8rem; color: var(--text-muted); }

.year-section { margin-bottom: 2rem; }
.year-title {
    font-size: 1.2rem;
    font-weight: 600;
    margin-bottom: 1rem;
    color: var(--primary-dark);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

/* =============================================================================
   File items
   ============================================================================= */

.file-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.6rem 0;
    border-bottom: 1px solid var(--border);
}

.file-item:last-child { border-bottom: none; }
.file-info { flex: 1; }
.file-name { font-weight: 500; font-size: 0.9rem; }
.file-meta { font-size: 0.8rem; color: var(--text-muted); }

/* =============================================================================
   Detail view
   ============================================================================= */

.detail-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.5rem 2rem;
}

.detail-item label {
    font-size: 0.8rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.detail-item .value { font-size: 0.95rem; margin-top: 0.1rem; }
.detail-item.full-width { grid-column: 1 / -1; }

/* =============================================================================
   Login page
   ============================================================================= */

.login-wrapper {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    background: linear-gradient(135deg, var(--primary-dark) 0%, var(--primary) 100%);
}

.login-card {
    background: white;
    padding: 2.5rem;
    border-radius: 12px;
    box-shadow: 0 10px 40px rgba(0,0,0,0.15);
    width: 100%;
    max-width: 400px;
    text-align: center;
}

.login-logo { height: 48px; margin-bottom: 1.5rem; }

.login-subtitle {
    color: var(--text-muted);
    margin-bottom: 2rem;
    font-size: 0.9rem;
}

/* =============================================================================
   Empty state
   ============================================================================= */

.empty-state {
    text-align: center;
    padding: 3rem 1rem;
    color: var(--text-muted);
}

.empty-state .icon { font-size: 3rem; margin-bottom: 1rem; }
.empty-state p { margin-bottom: 1rem; }

/* =============================================================================
   Color scheme selector
   ============================================================================= */

.scheme-option {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    border: 2px solid var(--border);
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.15s;
    margin-right: 0.5rem;
}

.scheme-option:hover { border-color: var(--primary-light); }
.scheme-option.active { border-color: var(--primary); background: var(--bg); }

.scheme-swatch {
    display: flex;
    gap: 2px;
    border-radius: 4px;
    overflow: hidden;
}

.scheme-swatch span { width: 16px; height: 16px; }

/* =============================================================================
   Responsive
   ============================================================================= */

@media (max-width: 768px) {
    .sidebar { width: 60px; min-width: 60px; }
    .sidebar .sidebar-search,
    .sidebar .nav-label,
    .sidebar .sidebar-section-title,
    .sidebar .sidebar-footer,
    .sidebar .sidebar-logo { display: none; }
    .sidebar .sidebar-header { justify-content: center; padding: 0.75rem 0.5rem; }
    .sidebar .sidebar-nav li a { justify-content: center; padding: 0.7rem 0.5rem; gap: 0; }
    .main-content { margin-left: 60px; padding: 1rem; }
    .form-grid { grid-template-columns: 1fr; }
    .detail-grid { grid-template-columns: 1fr; }
    .page-header { flex-direction: column; gap: 0.75rem; align-items: flex-start; }
}
