@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');

:root {
    --bg-main: #F8FAFC;
    /* Very light gray/slate background */
    --bg-surface: #FFFFFF;
    /* Pure white cards/sidebar */
    --bg-highlight: #F1F5F9;
    /* Light gray for hovers/secondary buttons */
    --accent: #0F172A;
    /* Dark Slate/Almost Black for primary actions */
    --accent-dim: #64748B;
    --text-primary: #0F172A;
    --text-secondary: #64748B;
    --border: #E2E8F0;
    /* Light border */
    --success: #16A34A;
    /* Green - slightly darker for text legibility */
    --warning: #D97706;
    /* Amber - darker for text legibility */
    --radius: 1rem;
    --radius-sm: 0.5rem;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Inter', sans-serif;
    -webkit-font-smoothing: antialiased;
}

body {
    background-color: var(--bg-main);
    color: var(--text-primary);
    min-height: 100vh;
    font-size: 14px;
    /* Base size */
}

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

/* Sidebar */
.sidebar {
    width: 240px;
    background: var(--bg-surface);
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 2rem;
    position: fixed;
    height: 100vh;
    border-right: 1px solid var(--border);
    z-index: 50;
    transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.brand {
    font-size: 1.1rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--accent);
}

.brand i {
    font-size: 0.9rem;
}

.nav-links {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.nav-item {
    padding: 0.75rem 0.875rem;
    border-radius: var(--radius-sm);
    cursor: pointer;
    color: var(--text-secondary);
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-weight: 500;
    font-size: 0.85rem;
}

.nav-item:hover {
    color: var(--text-primary);
    background: var(--bg-highlight);
}

.nav-item.active {
    color: var(--bg-surface);
    background: var(--accent);
}

.user-profile {
    margin-top: auto;
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--bg-highlight);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 0.8rem;
    border: 1px solid var(--border);
    color: var(--text-primary);
}

.user-info div:first-child {
    font-size: 0.85rem !important;
}

.user-info div:last-child {
    font-size: 0.75rem !important;
}

/* Main Content */
.main-content {
    flex: 1;
    margin-left: 240px;
    padding: 2rem;
    max-width: 100%;
}

.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2.5rem;
}

.header h1 {
    font-size: 1.5rem;
    font-weight: 600;
    letter-spacing: -0.03em;
    color: var(--accent);
}

.mobile-menu-btn {
    display: none;
    background: none;
    border: none;
    color: var(--text-primary);
    font-size: 1.25rem;
    cursor: pointer;
}

/* Cards */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 1.5rem;
    margin-bottom: 3rem;
}

.stat-card {
    background: var(--bg-surface);
    border-radius: var(--radius);
    padding: 1.5rem;
    position: relative;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05), 0 2px 4px -1px rgba(0, 0, 0, 0.03);
    /* Subtle shadow for white cards */
    border: 1px solid var(--border);
}

.stat-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.stat-title {
    color: var(--text-secondary);
    font-size: 0.8rem;
    font-weight: 500;
}

.stat-value {
    font-size: 1.75rem;
    font-weight: 700;
    letter-spacing: -0.04em;
    line-height: 1;
    color: var(--accent);
}

.stat-trend {
    font-size: 0.75rem;
    display: flex;
    align-items: center;
    gap: 0.4rem;
    color: var(--text-secondary);
}

.trend-up {
    color: var(--success);
    font-weight: 600;
}

/* Table Section */
.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
}

.section-header h3 {
    font-size: 1.1rem;
    font-weight: 600;
    letter-spacing: -0.02em;
    color: var(--accent);
}

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

table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0 0.25rem;
}

th {
    text-align: left;
    padding: 0.75rem 1rem;
    color: var(--text-secondary);
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-weight: 600;
    border: none;
}

td {
    padding: 1rem;
    background: var(--bg-surface);
    font-size: 0.85rem;
    color: var(--text-primary);
    border-top: 1px solid var(--border);
    border-bottom: 1px solid var(--border);
}

td:first-child {
    border-radius: var(--radius-sm) 0 0 var(--radius-sm);
    border-left: 1px solid var(--border);
}

td:last-child {
    border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
    border-right: 1px solid var(--border);
}

tr {
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

tr:hover {
    transform: translateY(-1px);
    box-shadow: 0 2px 4px -1px rgba(0, 0, 0, 0.05);
    /* Hover shadow on light theme */
}

.status-badge {
    position: relative;
    padding-left: 0.85rem;
    font-size: 0.75rem;
    font-weight: 600;
}

.status-badge::before {
    content: '';
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 5px;
    height: 5px;
    border-radius: 50%;
    background: currentColor;
}

.status-badge.status-completed {
    color: var(--success);
}

.status-badge.status-pending {
    color: var(--warning);
}

/* Buttons */
.btn {
    padding: 0.6rem 1.2rem;
    border-radius: 100px;
    border: none;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    font-size: 0.85rem;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
}

.btn-primary {
    background: var(--accent);
    color: #FFFFFF;
    /* High contrast text for dark button */
}

.btn-primary:hover {
    transform: translateY(-1px);
    background: #1e293b;
    /* Slightly lighter shade of dark slate */
    box-shadow: 0 4px 12px rgba(15, 23, 42, 0.15);
}

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

.btn-secondary:hover {
    background: #E2E8F0;
    /* Darker gray for hover */
}

/* Modal */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.4);
    /* Lighter overlay for light mode */
    backdrop-filter: blur(4px);
    z-index: 1000;
    display: none;
    justify-content: center;
    align-items: center;
    opacity: 0;
    transition: opacity 0.3s;
}

.modal-overlay.active {
    display: flex;
    opacity: 1;
}

.modal {
    background: var(--bg-surface);
    border-radius: var(--radius);
    width: 100%;
    max-width: 30%;
    padding: 2rem;
    position: relative;
    transform: scale(0.95);
    transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    border: 1px solid var(--border);
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
}

.modal-overlay.active .modal {
    transform: scale(1);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
}

.modal-header h3 {
    font-size: 1.15rem;
    letter-spacing: -0.02em;
    color: var(--accent);
}

.modal-close {
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 1.25rem;
    cursor: pointer;
}

.tabs {
    display: flex;
    background: var(--bg-highlight);
    padding: 0.25rem;
    border-radius: 0.75rem;
    margin-bottom: 1.5rem;
}

.tab {
    flex: 1;
    padding: 0.5rem;
    text-align: center;
    background: none;
    border: none;
    color: var(--text-secondary);
    border-radius: 0.5rem;
    cursor: pointer;
    font-weight: 500;
    transition: all 0.2s;
    font-size: 0.85rem;
}

.tab.active {
    background: var(--bg-surface);
    color: var(--text-primary);
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
    /* Subtle shadow for active tab */
}

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

.form-group label {
    display: block;
    color: var(--text-primary);
    margin-bottom: 0.5rem;
    font-size: 0.8rem;
    font-weight: 600;
}

.form-control {
    width: 100%;
    background: var(--bg-surface);
    border: 1px solid var(--border);
    padding: 0.75rem;
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 0.9rem;
    outline: none;
    transition: border-color 0.2s box-shadow 0.2s;
}

.form-control:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(15, 23, 42, 0.05);
}

.balance-preview {
    text-align: center;
    margin-bottom: 1.5rem;
    padding: 1rem;
    border-radius: var(--radius-sm);
    background: var(--bg-highlight);
    border: 1px solid var(--border);
}

.balance-preview span {
    color: var(--text-secondary);
    font-size: 0.85rem;
}

.balance-preview strong {
    display: block;
    font-size: 1.5rem;
    color: var(--accent);
    margin-top: 0.25rem;
}

/* Utilities */
.hidden {
    display: none !important;
}

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

    .sidebar.active {
        transform: translateX(0);
        box-shadow: 5px 0 15px rgba(0, 0, 0, 0.1);
    }

    .main-content {
        margin-left: 0;
        padding: 1.5rem;
    }

    .mobile-menu-btn {
        display: block;
    }

    .mobile-overlay {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background: rgba(0, 0, 0, 0.5);
        z-index: 40;
        display: none;
    }

    .mobile-overlay.active {
        display: block;
    }
}

@media (max-width: 768px) {
    .header {
        gap: 1rem;
        flex-wrap: wrap;
        margin-bottom: 2rem;
    }

    .header h1 {
        order: 2;
        font-size: 1.5rem;
    }

    .mobile-menu-btn {
        order: 1;
    }

    .header .btn-primary {
        order: 3;
        width: 100%;
        justify-content: center;
    }

    .stats-grid {
        gap: 1rem;
        margin-bottom: 2rem;
    }

    .stat-card {
        padding: 1.5rem;
        gap: 0.5rem;
    }

    .stat-value {
        font-size: 2rem;
    }

    /* Card-like Table for Mobile - Light Mode Adjustments */
    table,
    thead,
    tbody,
    th,
    td,
    tr {
        display: block;
    }

    thead tr {
        position: absolute;
        top: -9999px;
        left: -9999px;
    }

    tr {
        margin-bottom: 1rem;
        border: 1px solid var(--border);
        border-radius: var(--radius-sm);
        overflow: hidden;
        background: var(--bg-surface);
        box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
    }

    /* Remove default table borders/padding for mobile card view rework */
    td {
        position: relative;
        padding-left: 50%;
        border: none;
        border-bottom: 1px solid var(--border);
        border-radius: 0;
    }

    td:last-child {
        border-bottom: none;
    }

    td:before {
        position: absolute;
        top: 1.25rem;
        left: 1rem;
        width: 45%;
        white-space: nowrap;
        font-weight: 600;
        color: var(--text-secondary);
        text-transform: uppercase;
        font-size: 0.75rem;
        letter-spacing: 0.05em;
    }

    /* Simulate headers for mobile labels */
    td:nth-of-type(1):before {
        content: "Tarih";
    }

    td:nth-of-type(2):before {
        content: "Kaynak";
    }

    td:nth-of-type(3):before {
        content: "Açıklama";
    }

    td:nth-of-type(4):before {
        content: "Durum";
    }

    td:nth-of-type(5):before {
        content: "Tutar";
    }

    /* Fix for Empty Row on Mobile */
    tr.empty-row {
        background: transparent;
        box-shadow: none;
        border: none;
        text-align: center;
    }

    tr.empty-row td {
        padding: 2rem !important;
        text-align: center !important;
        padding-left: 0 !important;
        /* Remove half-width padding padding-left: 50% from generic rule */
    }

    tr.empty-row td:before {
        content: none !important;
        /* Remove "Tarih" label */
        display: none;
    }

    .table-container {
        overflow: visible;
    }

    /* Filter Section Mobile Fix */
    .filter-group {
        width: 100%;
        flex-direction: column;
        align-items: stretch !important;
        gap: 0.75rem !important;
    }

    /* Ensure the inner custom date wrapper also stacks */
    #customDateInputs {
        width: 100%;
        flex-direction: column;
        gap: 0.75rem !important;
    }

    /* Wrapper for the input needs to be full width too */
    .date-input-wrapper {
        width: 100%;
    }

    .filter-control {
        width: 100% !important;
        box-sizing: border-box;
        /* Ensure padding doesn't overflow width */
    }

    .section-header button {
        width: 100%;
        justify-content: center;
    }

    /* Force inputs to ignore inline width on mobile */
    #dateRangeInput {
        width: 100% !important;
    }

    .hide-mobile {
        display: inline;
    }

    /* Mobile Fullscreen Modals */
    .modal-overlay {
        align-items: flex-end;
        /* Align to bottom, helpful for transitions if we added slide */
        padding: 0;
        /* Remove any padding around overlay */
    }

    .modal {
        max-width: 100% !important;
        width: 100% !important;
        height: 100% !important;
        border-radius: 0 !important;
        /* Remove corners */
        display: flex;
        flex-direction: column;
        padding: 1.5rem;
        border: none;
        /* Remove border */
        overflow-y: auto;
        /* Scrollable content */
    }

    .modal-header {
        margin-top: 1rem;
        /* Breathing room from top status bar area */
        flex-shrink: 0;
    }

    .modal form {
        flex: 1;
        /* allow form to grow */
        display: flex;
        flex-direction: column;
    }

    /* Push submit button to bottom for easy reach? Optional but nice */
    .modal form button[type="submit"] {
        margin-top: auto;
    }
}

/* Desktop Filter Styles (Global) */
.filter-group {
    display: flex;
    gap: 0.5rem;
    align-items: center;
    flex-wrap: wrap;
}

.filter-control {
    width: auto;
    padding: 0.5rem 2rem 0.5rem 1rem;
    /* Extra right padding for select arrow */
    font-size: 0.85rem;
    height: 40px;
    /* Increased slightly for better tap target and alignment */
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    background-color: var(--bg-surface);
    color: var(--text-primary);
    cursor: pointer;
    background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2364748B' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6 9 12 15 18 9'%3e%3c/polyline%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: right 0.5rem center;
    background-size: 1em;
    appearance: none;
    -webkit-appearance: none;
}

/* Remove arrow for non-select inputs if reusing class */
input.filter-control {
    background-image: none;
    padding-right: 1rem;
    text-align: center;
}

/* Toast Notifications */
.toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 10px;
    pointer-events: none;
}

.toast {
    background: var(--bg-surface);
    color: var(--text-primary);
    padding: 1rem 1.25rem;
    border-radius: var(--radius-sm);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    border: 1px solid var(--border);
    border-left: 4px solid var(--accent);
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 300px;
    max-width: 400px;
    animation: slideIn 0.3s cubic-bezier(0.16, 1, 0.3, 1) forwards;
    pointer-events: auto;
    font-size: 0.9rem;
}

.toast.success {
    border-left-color: var(--success);
}

.toast.error {
    border-left-color: #EF4444;
    /* Red-500 */
}

.toast i {
    font-size: 1.1rem;
}

.toast.success i {
    color: var(--success);
}

.toast.error i {
    color: #EF4444;
}

.toast.hiding {
    animation: fadeOut 0.3s forwards;
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateX(20px);
    }

    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes fadeOut {
    to {
        opacity: 0;
        transform: translateX(20px);
    }
}