/**
 * Finance Manager - Hauptstylesheet
 * Grünes Design mit linker Sidebar-Navigation
 * Inspiriert von verwaltung.kliu.at
 */

/* ===== CSS Variables ===== */
:root {
    /* Farben - GRÜNES DESIGN */
    --primary: #10b981;
    --primary-dark: #059669;
    --primary-light: #34d399;
    --success: #22c55e;
    --danger: #ef4444;
    --info: #3b82f6;
    --warning: #f59e0b;
    
    /* Neutrale Farben */
    --white: #ffffff;
    --gray-50: #f9fafb;
    --gray-100: #f3f4f6;
    --gray-200: #e5e7eb;
    --gray-300: #d1d5db;
    --gray-400: #9ca3af;
    --gray-500: #6b7280;
    --gray-600: #4b5563;
    --gray-700: #374151;
    --gray-800: #1f2937;
    --gray-900: #111827;
    
    /* Sidebar */
    --sidebar-width: 240px;
    --sidebar-collapsed: 70px;
    --sidebar-bg: #111827;
    --sidebar-text: #9ca3af;
    --sidebar-active: #10b981;
    
    /* Schatten */
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow: 0 1px 3px 0 rgb(0 0 0 / 0.1), 0 1px 2px -1px rgb(0 0 0 / 0.1);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
    
    /* Abstände */
    --space-1: 0.25rem;
    --space-2: 0.5rem;
    --space-3: 0.75rem;
    --space-4: 1rem;
    --space-5: 1.25rem;
    --space-6: 1.5rem;
    --space-8: 2rem;
    --space-10: 2.5rem;
    --space-12: 3rem;
    
    /* Border Radius */
    --radius-sm: 0.375rem;
    --radius: 0.5rem;
    --radius-md: 0.75rem;
    --radius-lg: 1rem;
    --radius-xl: 1.5rem;
    
    /* Transitions */
    --transition-fast: 150ms ease;
    --transition: 200ms ease;
}

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

html {
    font-size: 16px;
    -webkit-text-size-adjust: 100%;
    -webkit-tap-highlight-color: transparent;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    font-size: 0.9375rem;
    line-height: 1.5;
    color: var(--gray-800);
    background-color: var(--gray-100);
    min-height: 100vh;
}

a {
    color: inherit;
    text-decoration: none;
}

button {
    font-family: inherit;
    cursor: pointer;
    border: none;
    background: none;
}

input, select, textarea {
    font-family: inherit;
    font-size: inherit;
}

/* ===== Layout ===== */
.app {
    min-height: 100vh;
    display: flex;
}

/* ===== Sidebar Navigation ===== */
.sidebar {
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    width: var(--sidebar-width);
    background: var(--sidebar-bg);
    color: var(--sidebar-text);
    display: flex;
    flex-direction: column;
    z-index: 1000;
    overflow-y: auto;
    overflow-x: hidden;
}

.sidebar-header {
    padding: 1.5rem;
    border-bottom: 1px solid rgba(255,255,255,0.1);
}

.sidebar-logo {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    color: var(--white);
    font-size: 1.25rem;
    font-weight: 700;
}

.sidebar-logo i {
    width: 2.5rem;
    height: 2.5rem;
    background: var(--primary);
    border-radius: var(--radius);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.125rem;
}

.sidebar-nav {
    flex: 1;
    padding: 1rem 0;
}

.sidebar-nav a {
    display: flex;
    align-items: center;
    gap: 0.875rem;
    padding: 0.875rem 1.5rem;
    color: var(--sidebar-text);
    font-size: 0.9375rem;
    font-weight: 500;
    transition: all var(--transition-fast);
    border-left: 3px solid transparent;
}

.sidebar-nav a:hover {
    color: var(--white);
    background: rgba(255,255,255,0.05);
}

.sidebar-nav a.active {
    color: var(--primary);
    background: rgba(16, 185, 129, 0.1);
    border-left-color: var(--primary);
}

.sidebar-nav a i {
    width: 1.5rem;
    text-align: center;
    font-size: 1.125rem;
}

.sidebar-footer {
    padding: 1rem 1.5rem;
    border-top: 1px solid rgba(255,255,255,0.1);
}

.sidebar-user {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem;
    background: rgba(255,255,255,0.05);
    border-radius: var(--radius);
}

.sidebar-user-icon {
    width: 2.25rem;
    height: 2.25rem;
    background: var(--primary);
    border-radius: var(--radius);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--white);
    font-size: 0.875rem;
}

.sidebar-user-info {
    flex: 1;
    min-width: 0;
}

.sidebar-user-name {
    color: var(--white);
    font-weight: 600;
    font-size: 0.875rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sidebar-user-role {
    font-size: 0.75rem;
    color: var(--gray-400);
}

/* Sidebar Gruppe für Kategorien */
.sidebar-group {
    margin: 0.5rem 0;
}

.sidebar-group-title {
    display: flex;
    align-items: center;
    gap: 0.875rem;
    padding: 0.875rem 1.5rem;
    color: var(--gray-400);
    font-size: 0.9375rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.025em;
    border-left: 3px solid transparent;
}

.sidebar-group-title i {
    width: 1.5rem;
    text-align: center;
    font-size: 1.125rem;
}

.sidebar-subitem {
    display: flex;
    align-items: center;
    gap: 0.875rem;
    padding: 0.625rem 1.5rem 0.625rem 3rem !important;
    color: var(--sidebar-text);
    font-size: 0.875rem !important;
    font-weight: 400 !important;
    transition: all var(--transition-fast);
    border-left: 3px solid transparent;
}

.sidebar-subitem:hover {
    color: var(--white);
    background: rgba(255,255,255,0.05);
}

.sidebar-subitem i {
    width: 1rem !important;
    text-align: center;
    font-size: 0.5rem !important;
    color: var(--gray-500);
}

/* Logout Link */
.sidebar-logout {
    display: flex;
    align-items: center;
    gap: 0.875rem;
    padding: 0.75rem;
    margin-top: 0.75rem;
    color: var(--gray-400);
    font-size: 0.9375rem;
    font-weight: 500;
    border-radius: var(--radius);
    transition: all var(--transition-fast);
}

.sidebar-logout:hover {
    color: var(--danger);
    background: rgba(239, 68, 68, 0.1);
}

.sidebar-logout i {
    width: 1.5rem;
    text-align: center;
    font-size: 1.125rem;
}

/* ===== Main Content ===== */
.main {
    flex: 1;
    margin-left: var(--sidebar-width);
    padding: 1.5rem 2rem;
    min-height: 100vh;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
}

/* ===== Page Header ===== */
.page-header {
    margin-bottom: 1.5rem;
}

.page-title {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--gray-900);
    margin-bottom: 0.25rem;
}

.page-subtitle {
    color: var(--gray-500);
    font-size: 1rem;
}

/* ===== Cards ===== */
.card {
    background: var(--white);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    overflow: hidden;
    margin-bottom: 1.5rem;
}

.card-header {
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid var(--gray-100);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
}

.card-title {
    font-size: 1.125rem;
    font-weight: 600;
    color: var(--gray-800);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.card-title i {
    color: var(--primary);
}

.card-body {
    padding: 1.5rem;
}

.card-footer {
    padding: 1rem 1.5rem;
    border-top: 1px solid var(--gray-100);
    background: var(--gray-50);
}

/* ===== KPI Cards ===== */
.kpi-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 1.5rem;
    margin-bottom: 1.5rem;
}

.kpi-card {
    background: var(--white);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    box-shadow: var(--shadow);
    display: flex;
    align-items: center;
    gap: 1rem;
}

.kpi-icon {
    width: 3.5rem;
    height: 3.5rem;
    border-radius: var(--radius-lg);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    flex-shrink: 0;
}

.kpi-icon.primary {
    background: rgba(16, 185, 129, 0.1);
    color: var(--primary);
}

.kpi-icon.success {
    background: rgba(34, 197, 94, 0.1);
    color: var(--success);
}

.kpi-icon.danger {
    background: rgba(239, 68, 68, 0.1);
    color: var(--danger);
}

.kpi-icon.info {
    background: rgba(59, 130, 246, 0.1);
    color: var(--info);
}

.kpi-icon.warning {
    background: rgba(245, 158, 11, 0.1);
    color: var(--warning);
}

.kpi-content {
    flex: 1;
    min-width: 0;
}

.kpi-label {
    font-size: 0.875rem;
    color: var(--gray-500);
    font-weight: 500;
    margin-bottom: 0.25rem;
}

.kpi-value {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--gray-900);
}

.kpi-value.positive {
    color: var(--success);
}

.kpi-value.negative {
    color: var(--danger);
}

/* ===== Dashboard Grid ===== */
.dashboard-grid {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 1.5rem;
}

.dashboard-grid .card:first-child {
    grid-column: 1 / -1;
}

/* ===== Charts ===== */
.chart-container {
    position: relative;
    height: 350px;
    width: 100%;
}

.chart-tabs {
    display: flex;
    gap: 0.5rem;
}

.chart-tab {
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--gray-500);
    border-radius: var(--radius);
    transition: all var(--transition-fast);
    border: none;
    background: transparent;
}

.chart-tab:hover {
    color: var(--primary);
    background: var(--gray-100);
}

.chart-tab.active {
    color: var(--white);
    background: var(--primary);
}

/* ===== Lists ===== */
.list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.list-item {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1rem;
    background: var(--gray-50);
    border-radius: var(--radius);
    transition: background var(--transition-fast);
}

.list-item:hover {
    background: var(--gray-100);
}

.list-icon {
    width: 2.5rem;
    height: 2.5rem;
    border-radius: var(--radius);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    flex-shrink: 0;
}

.list-content {
    flex: 1;
    min-width: 0;
}

.list-title {
    font-weight: 600;
    color: var(--gray-800);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.list-subtitle {
    font-size: 0.875rem;
    color: var(--gray-500);
}

.list-amount {
    font-weight: 600;
    font-size: 1rem;
}

.list-amount.income {
    color: var(--success);
}

.list-amount.expense {
    color: var(--danger);
}

.list-actions {
    display: flex;
    gap: 0.25rem;
}

/* ===== Forms ===== */
.form-group {
    margin-bottom: 1.25rem;
}

.form-label {
    display: block;
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--gray-700);
    margin-bottom: 0.5rem;
}

.form-label span.required {
    color: var(--danger);
}

.form-input,
.form-select,
.form-textarea {
    width: 100%;
    padding: 0.75rem 1rem;
    border: 1.5px solid var(--gray-200);
    border-radius: var(--radius);
    background: var(--white);
    color: var(--gray-800);
    transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
    font-size: 0.9375rem;
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.1);
}

.form-input::placeholder,
.form-textarea::placeholder {
    color: var(--gray-400);
}

.form-select {
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='%236b7280'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M19 9l-7 7-7-7'%3E%3C/path%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.75rem center;
    background-size: 1.25rem;
    padding-right: 2.5rem;
}

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

.form-hint {
    font-size: 0.75rem;
    color: var(--gray-500);
    margin-top: 0.25rem;
}

.form-row {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1rem;
}

/* ===== Buttons ===== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.75rem 1.25rem;
    font-size: 0.9375rem;
    font-weight: 600;
    border-radius: var(--radius);
    transition: all var(--transition-fast);
    cursor: pointer;
    white-space: nowrap;
}

.btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

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

.btn-primary:hover:not(:disabled) {
    background: var(--primary-dark);
    transform: translateY(-1px);
}

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

.btn-success:hover:not(:disabled) {
    background: #16a34a;
}

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

.btn-danger:hover:not(:disabled) {
    background: #dc2626;
}

.btn-secondary {
    background: var(--gray-200);
    color: var(--gray-700);
}

.btn-secondary:hover:not(:disabled) {
    background: var(--gray-300);
}

.btn-outline {
    background: transparent;
    border: 1.5px solid var(--gray-300);
    color: var(--gray-700);
}

.btn-outline:hover:not(:disabled) {
    border-color: var(--primary);
    color: var(--primary);
    background: rgba(16, 185, 129, 0.05);
}

.btn-ghost {
    background: transparent;
    color: var(--gray-600);
}

.btn-ghost:hover:not(:disabled) {
    background: var(--gray-100);
    color: var(--gray-800);
}

.btn-sm {
    padding: 0.5rem 0.75rem;
    font-size: 0.875rem;
}

.btn-lg {
    padding: 1rem 1.5rem;
    font-size: 1rem;
}

.btn-block {
    width: 100%;
}

/* ===== Type Toggle ===== */
.type-toggle {
    display: flex;
    gap: 0.75rem;
    margin-bottom: 1.25rem;
}

.type-toggle-btn {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 1rem;
    border: 2px solid var(--gray-200);
    border-radius: var(--radius);
    background: var(--white);
    font-weight: 600;
    transition: all var(--transition-fast);
    cursor: pointer;
}

.type-toggle-btn.expense.active {
    border-color: var(--danger);
    background: rgba(239, 68, 68, 0.05);
    color: var(--danger);
}

.type-toggle-btn.income.active {
    border-color: var(--success);
    background: rgba(34, 197, 94, 0.05);
    color: var(--success);
}

/* ===== Quick Actions ===== */
.quick-actions {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.quick-action {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    padding: 1.25rem;
    background: var(--white);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    transition: all var(--transition-fast);
}

.quick-action:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.quick-action-icon {
    width: 3rem;
    height: 3rem;
    border-radius: var(--radius);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
}

.quick-action-icon.expense {
    background: rgba(239, 68, 68, 0.1);
    color: var(--danger);
}

.quick-action-icon.income {
    background: rgba(34, 197, 94, 0.1);
    color: var(--success);
}

.quick-action-icon.account {
    background: rgba(16, 185, 129, 0.1);
    color: var(--primary);
}

.quick-action-icon.debt {
    background: rgba(245, 158, 11, 0.1);
    color: var(--warning);
}

.quick-action-text {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--gray-700);
}

/* ===== Alerts ===== */
.alert {
    padding: 1rem 1.25rem;
    border-radius: var(--radius);
    margin-bottom: 1.25rem;
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
}

.alert-success {
    background: rgba(34, 197, 94, 0.1);
    border: 1px solid rgba(34, 197, 94, 0.2);
    color: #15803d;
}

.alert-error {
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid rgba(239, 68, 68, 0.2);
    color: #b91c1c;
}

.alert-info {
    background: rgba(59, 130, 246, 0.1);
    border: 1px solid rgba(59, 130, 246, 0.2);
    color: #1d4ed8;
}

.alert i {
    font-size: 1.125rem;
    flex-shrink: 0;
    margin-top: 0.125rem;
}

/* ===== Badges ===== */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.25rem 0.625rem;
    font-size: 0.75rem;
    font-weight: 600;
    border-radius: 9999px;
    text-transform: uppercase;
    letter-spacing: 0.025em;
}

.badge-success {
    background: rgba(34, 197, 94, 0.1);
    color: var(--success);
}

.badge-danger {
    background: rgba(239, 68, 68, 0.1);
    color: var(--danger);
}

.badge-warning {
    background: rgba(245, 158, 11, 0.1);
    color: var(--warning);
}

.badge-info {
    background: rgba(59, 130, 246, 0.1);
    color: var(--info);
}

/* ===== Empty State ===== */
.empty-state {
    text-align: center;
    padding: 3rem 1.5rem;
}

.empty-state-icon {
    width: 4rem;
    height: 4rem;
    margin: 0 auto 1rem;
    border-radius: var(--radius-xl);
    background: var(--gray-100);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    color: var(--gray-400);
}

.empty-state-title {
    font-size: 1.125rem;
    font-weight: 600;
    color: var(--gray-700);
    margin-bottom: 0.25rem;
}

.empty-state-text {
    color: var(--gray-500);
    font-size: 0.9375rem;
}

/* ===== Filters ===== */
.filter-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    margin-bottom: 1.25rem;
    padding: 1rem;
    background: var(--white);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
}

.filter-group {
    flex: 1;
    min-width: 150px;
}

/* ===== Tables ===== */
.table-container {
    overflow-x: auto;
}

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

.table th,
.table td {
    padding: 0.875rem 1rem;
    text-align: left;
}

.table th {
    font-weight: 600;
    color: var(--gray-600);
    background: var(--gray-50);
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.table tbody tr {
    border-bottom: 1px solid var(--gray-100);
    transition: background var(--transition-fast);
}

.table tbody tr:hover {
    background: var(--gray-50);
}

/* ===== Stats Summary ===== */
.stats-summary {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1rem;
    padding: 1rem;
    background: var(--gray-50);
    border-radius: var(--radius);
    margin-bottom: 1.25rem;
}

.stat-item {
    text-align: center;
}

.stat-label {
    font-size: 0.75rem;
    color: var(--gray-500);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 0.25rem;
}

.stat-value {
    font-size: 1.25rem;
    font-weight: 700;
}

.stat-value.income {
    color: var(--success);
}

.stat-value.expense {
    color: var(--danger);
}

.stat-value.balance {
    color: var(--info);
}

/* ===== Color Picker ===== */
.color-picker {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.color-option {
    width: 2.25rem;
    height: 2.25rem;
    border-radius: var(--radius);
    cursor: pointer;
    transition: transform var(--transition-fast);
    position: relative;
}

.color-option:hover {
    transform: scale(1.1);
}

.color-option.selected::after {
    content: '\f00c';
    font-family: 'Font Awesome 6 Free';
    font-weight: 900;
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 0.875rem;
    text-shadow: 0 1px 2px rgba(0,0,0,0.3);
}

/* ===== Animations ===== */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.fade-in {
    animation: fadeIn 0.3s ease forwards;
}

/* ===== Responsive ===== */
@media (max-width: 1200px) {
    .kpi-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .dashboard-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 768px) {
    .sidebar {
        width: var(--sidebar-collapsed);
    }
    
    .sidebar-logo span,
    .sidebar-nav a span,
    .sidebar-user-info {
        display: none;
    }
    
    .sidebar-nav a {
        justify-content: center;
        padding: 1rem;
    }
    
    .sidebar-nav a i {
        width: auto;
        font-size: 1.25rem;
    }
    
    .main {
        margin-left: var(--sidebar-collapsed);
        padding: 1rem;
    }
    
    .kpi-grid {
        grid-template-columns: 1fr;
    }
    
    .quick-actions {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .form-row {
        grid-template-columns: 1fr;
    }
}

/* ===== Utility Classes ===== */
.text-success { color: var(--success); }
.text-danger { color: var(--danger); }
.text-info { color: var(--info); }
.text-warning { color: var(--warning); }
.text-muted { color: var(--gray-500); }

.d-none { display: none; }
.d-flex { display: flex; }
.align-items-center { align-items: center; }
.justify-content-between { justify-content: space-between; }
.gap-2 { gap: 0.5rem; }
.gap-3 { gap: 0.75rem; }

.w-100 { width: 100%; }
