:root {
    --primary-color: #1e3a8a; /* Lacivert */
    --primary-hover: #1e40af;
    --secondary-color: #64748b; /* Gri */
    --background-color: #f8fafc;
    --text-color: #334155;
    --card-bg: #ffffff;
    --border-color: #e2e8f0;
    
    --success: #10b981;
    --danger: #ef4444;
    --warning: #f59e0b;
    --info: #3b82f6;
    --gray: #94a3b8;
}

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

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background-color: var(--background-color);
    color: var(--text-color);
    line-height: 1.6;
    font-size: 15px;
    overflow-x: hidden;
}

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

/* Sidebar */
.sidebar {
    width: 250px;
    background-color: var(--card-bg);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    transition: transform 0.25s ease;
    flex-shrink: 0;
}

.sidebar-header {
    padding: 20px;
    border-bottom: 1px solid var(--border-color);
    font-weight: 700;
    font-size: 1.2rem;
    color: var(--primary-color);
    text-align: center;
}

.sidebar-menu {
    list-style: none;
    padding: 15px 0;
    flex: 1;
    overflow-y: auto;
}

.sidebar-menu li a {
    display: block;
    padding: 12px 20px;
    color: var(--text-color);
    text-decoration: none;
    font-weight: 500;
    transition: background 0.2s, color 0.2s;
}

.sidebar-menu li a:hover, .sidebar-menu li a.active {
    background-color: #eff6ff;
    color: var(--primary-color);
    border-right: 3px solid var(--primary-color);
}

.sidebar-footer {
    padding: 15px 20px;
    border-top: 1px solid var(--border-color);
    font-size: 0.9rem;
}

/* Main Content */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0; /* Prevents flexbox overflow */
    width: 100%;
}

.topbar {
    height: 60px;
    background-color: var(--card-bg);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: flex-end;
    padding: 0 20px;
    position: relative;
}

.menu-toggle {
    display: none;
    background: none;
    border: none;
    font-size: 1.8rem;
    cursor: pointer;
    color: var(--text-color);
    padding: 5px;
    position: absolute;
    left: 15px;
    z-index: 1001;
}

.user-profile {
    font-weight: 500;
    font-size: 0.95rem;
}

.content {
    padding: 20px;
    flex: 1;
    overflow-y: auto;
    position: relative;
}

.page-title {
    margin-bottom: 20px;
    font-size: 1.5rem;
    color: var(--primary-color);
    word-break: break-word;
}

/* Cards */
.card {
    background: var(--card-bg);
    border-radius: 8px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
    padding: 20px;
    margin-bottom: 20px;
    overflow: hidden; /* For inner contents like tables/canvas */
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 10px;
    flex-wrap: wrap;
    gap: 10px;
}

.card-title {
    font-size: 1.1rem;
    font-weight: 600;
}

/* Grid Layouts */
.grid-cards {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 20px;
    margin-bottom: 20px;
}

.stat-card {
    background: var(--card-bg);
    border-radius: 8px;
    padding: 20px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
    text-align: center;
    border-top: 4px solid var(--primary-color);
    display: flex;
    flex-direction: column;
    justify-content: center;
    min-height: 120px;
}

.stat-card.gorusuldu { border-color: var(--info); }
.stat-card.degerlendirmede { border-color: var(--warning); }
.stat-card.olumlu { border-color: var(--success); }
.stat-card.olumsuz { border-color: var(--danger); }

.stat-number {
    font-size: clamp(1.5rem, 2vw, 2rem);
    font-weight: 700;
    color: var(--text-color);
    margin: 5px 0;
    line-height: 1.2;
}

.stat-label {
    color: var(--secondary-color);
    font-size: 0.9rem;
    font-weight: 500;
    line-height: 1.3;
}

/* Forms */
.form-group {
    margin-bottom: 15px;
}

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

.form-control {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    font-family: inherit;
    font-size: 0.95rem;
    transition: border-color 0.2s;
    background-color: #fff;
}

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

.form-control:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(30, 58, 138, 0.1);
}

select.form-control {
    appearance: auto;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-weight: 500;
    text-align: center;
    white-space: nowrap;
    user-select: none;
    border: 1px solid transparent;
    padding: 8px 16px;
    font-size: 0.95rem;
    line-height: 1.5;
    border-radius: 6px;
    transition: all 0.2s;
    cursor: pointer;
    text-decoration: none;
    min-height: 38px;
}

.btn-primary { color: #fff; background-color: var(--primary-color); border-color: var(--primary-color); }
.btn-primary:hover { background-color: var(--primary-hover); }
.btn-secondary { color: #fff; background-color: var(--secondary-color); border-color: var(--secondary-color); }
.btn-success { background-color: var(--success); color: white; border-color: var(--success); }
.btn-danger { background-color: var(--danger); color: white; border-color: var(--danger); }
.btn-warning { background-color: var(--warning); color: white; border-color: var(--warning); }
.btn-info { background-color: var(--info); color: white; border-color: var(--info); }
.btn-sm { padding: 4px 10px; font-size: 0.85rem; min-height: 32px; }
.btn-block { display: flex; width: 100%; }

/* Tables */
.table-responsive {
    overflow-x: auto;
    width: 100%;
    -webkit-overflow-scrolling: touch;
}

.table {
    width: 100%;
    margin-bottom: 1rem;
    color: var(--text-color);
    border-collapse: collapse;
}

.table th, .table td {
    padding: 12px 15px;
    vertical-align: middle;
    border-bottom: 1px solid var(--border-color);
    text-align: left;
    word-break: break-word;
}

.table th {
    background-color: #f1f5f9;
    font-weight: 600;
    font-size: 0.9rem;
    white-space: nowrap;
}

/* Badges */
.status-badge {
    display: inline-block;
    padding: 4px 8px;
    font-size: 0.75rem;
    font-weight: 600;
    border-radius: 12px;
    text-align: center;
    white-space: nowrap;
}

.status-gorusuldu { background-color: #eff6ff; color: var(--info); }
.status-degerlendirmede { background-color: #fffbeb; color: var(--warning); }
.status-olumlu { background-color: #ecfdf5; color: var(--success); }
.status-olumsuz { background-color: #fef2f2; color: var(--danger); }
.status-yok { background-color: #f1f5f9; color: var(--secondary-color); }

/* Alerts */
.alert {
    padding: 12px 15px;
    margin-bottom: 20px;
    border-radius: 6px;
    font-weight: 500;
    word-break: break-word;
}

.alert-success { background-color: #ecfdf5; color: #065f46; border: 1px solid #a7f3d0; }
.alert-danger { background-color: #fef2f2; color: #991b1b; border: 1px solid #fecaca; }
.alert-warning { background-color: #fffbeb; color: #92400e; border: 1px solid #fde68a; }
.alert-info { background-color: #eff6ff; color: #1e40af; border: 1px solid #bfdbfe; }

/* Login Page Specific */
.login-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background-color: #e0e7ff;
    padding: 15px;
}

.login-box {
    width: 100%;
    max-width: 400px;
    background: var(--card-bg);
    border-radius: 10px;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    padding: 30px;
}

.login-logo {
    text-align: center;
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--primary-color);
    margin-bottom: 20px;
}

/* Auth Notes / History */
.note-item {
    padding: 15px;
    border-left: 3px solid var(--primary-color);
    background: #f8fafc;
    margin-bottom: 10px;
    border-radius: 0 6px 6px 0;
}
.note-meta {
    font-size: 0.8rem;
    color: var(--secondary-color);
    margin-bottom: 5px;
}

/* Pagination */
.pagination {
    display: flex;
    list-style: none;
    margin-top: 20px;
    justify-content: flex-end;
    flex-wrap: wrap;
    gap: 5px;
}

.pagination a, .pagination span {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 6px 12px;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    color: var(--text-color);
    text-decoration: none;
    min-width: 35px;
    min-height: 35px;
}

.pagination a:hover { background-color: #f1f5f9; }
.pagination .active span { background-color: var(--primary-color); color: white; border-color: var(--primary-color); }

/* Chart.js Container */
canvas {
    max-width: 100%;
    height: auto !important;
}

/* Mobile Overlay */
.mobile-overlay {
    display: none;
}

/* Responsive Breakpoints */

/* Tablet (1024px and below) */
@media (max-width: 1024px) {
    .grid-cards {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
    
    .grid-cards[style*="grid-template-columns: 1fr 2fr;"] {
        grid-template-columns: 1fr !important;
    }
}

/* Mobile (768px and below) */
@media (max-width: 768px) {
    .menu-toggle.mobile-menu-toggle {
        display: block;
    }
    
    .topbar {
        justify-content: flex-end; /* Keep user profile right, toggle is absolute left */
    }

    .sidebar {
        position: fixed;
        top: 0;
        left: 0;
        width: 260px;
        height: 100%;
        bottom: 0;
        transform: translateX(-100%);
        z-index: 10000;
        box-shadow: 2px 0 10px rgba(0,0,0,0.1);
        background-color: var(--card-bg);
        transition: transform 0.3s ease;
    }
    
    /* Pure CSS Toggle Logic */
    #nav-toggle:checked ~ .app-container .sidebar {
        transform: translateX(0);
    }

    .mobile-overlay {
        display: block;
        position: fixed;
        inset: 0;
        background: rgba(0,0,0,0.4);
        opacity: 0;
        pointer-events: none;
        transition: opacity 0.3s ease;
        z-index: 9999;
    }

    /* Prevent body scroll when open (using pseudo class hack if needed, but not strictly required with fixed overlay) */
    body:has(#nav-toggle:checked) {
        overflow: hidden;
    }

    #nav-toggle:checked ~ .app-container .content .mobile-overlay {
        opacity: 1;
        pointer-events: auto;
    }
    
    .main-content {
        width: 100%;
    }

    .content {
        padding: 15px;
    }

    /* Stack Grids */
    .grid-cards,
    .grid-cards[style*="grid-template-columns"] {
        grid-template-columns: 1fr !important;
        gap: 15px;
    }

    /* Convert Tables to Cards on Mobile */
    .table-responsive .table, 
    .table-responsive .table tbody, 
    .table-responsive .table tr, 
    .table-responsive .table td {
        display: block;
        width: 100%;
    }
    
    .table-responsive .table thead {
        display: none; /* Hide standard headers */
    }
    
    .table-responsive .table tr {
        margin-bottom: 15px;
        background: var(--card-bg);
        border: 1px solid var(--border-color);
        border-radius: 8px;
        padding: 10px 10px 10px 45%;
        position: relative;
    }
    
    .table-responsive .table td {
        border: none;
        border-bottom: 1px solid #f1f5f9;
        padding: 8px 5px;
        min-height: 40px;
    }
    
    .table-responsive .table td:last-child {
        border-bottom: 0;
        margin-top: 10px;
        padding-bottom: 5px;
        display: flex;
        justify-content: flex-start;
        gap: 10px;
        flex-wrap: wrap;
    }
    
    /* Labels before cells */
    .table-responsive .table td::before {
        content: attr(data-label);
        position: absolute;
        left: 15px;
        width: 40%;
        text-align: left;
        font-weight: 600;
        color: var(--secondary-color);
        font-size: 0.9rem;
    }

    /* Fix company details page table */
    .card > .table tr {
        display: flex;
        flex-direction: column;
        padding: 0;
        border: none;
        margin-bottom: 10px;
        background: transparent;
    }
    .card > .table th, .card > .table td {
        display: block;
        width: 100%;
        padding: 5px 0;
    }
    .card > .table th {
        color: var(--secondary-color);
        font-size: 0.85rem;
    }
    .card > .table td::before {
        display: none;
    }

    /* Ensure buttons are large enough for touch */
    .btn {
        min-height: 44px;
        width: 100%;
    }

    .btn-sm {
        min-height: 38px;
        width: auto;
    }

    /* Search Filters Wrapper */
    form[style*="display: flex"] {
        flex-direction: column;
        align-items: stretch !important;
    }
    
    form[style*="display: flex"] > div {
        width: 100%;
    }
    
    form[style*="display: flex"] .btn {
        margin-bottom: 10px;
    }
}

/* Small Mobile (480px and below) */
@media (max-width: 480px) {
    .page-title {
        font-size: 1.3rem;
    }
    .stat-number {
        font-size: 1.6rem;
    }
}
