@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600&display=swap');

:root {
    --primary: #24b47e; /* Supabase-like green outline or secondary */
    --primary-hover: #1e9e6e;
    --primary-light: #e6f7f0;
    --bg-dark: #fbfbfc; /* Background behind cards */
    --bg-card: #ffffff;
    --text-main: #1f2937; /* Dark almost black text */
    --text-muted: #6b7280; /* Gray for labels */
    --border-light: #ededed;
    --border-strong: #d1d5db;
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    --radius-sm: 4px;
    --radius-md: 6px;
    --radius-lg: 8px;
    --radius-xl: 12px;
    --transition: all 0.2s ease-in-out;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    -webkit-tap-highlight-color: transparent;
}

body {
    background-color: var(--bg-card);
    color: var(--text-main);
    min-height: 100vh;
    display: flex;
    overflow-x: hidden;
    font-size: 14px;
}

/* Glassmorphism Generic (Removed glass effect physically, kept class name for compatibility) */
.glass {
    background: var(--bg-card);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-md);
    box-shadow: none;
    transition: box-shadow var(--transition);
}

/* ================= LOGIN ================= */
.login-container {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    width: 100%;
    padding: 1.5rem;
    position: relative;
    z-index: 1;
    background-color: var(--bg-dark);
}

.login-card {
    width: 100%;
    max-width: 400px;
    padding: 2.5rem 2rem;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    border: 1px solid var(--border-light);
    background: var(--bg-card);
    animation: fadeIn 0.4s var(--transition) forwards;
}

.login-title {
    font-size: 1.5rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
    text-align: center;
    color: var(--text-main);
}

.login-subtitle {
    text-align: center;
    color: var(--text-muted);
    font-size: 0.9rem;
    margin-bottom: 2rem;
}

.form-group {
    margin-bottom: 1.25rem;
}

.form-label {
    display: block;
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-main);
    margin-bottom: 0.5rem;
}

.form-control {
    width: 100%;
    padding: 0.75rem 0.875rem;
    background: var(--bg-card);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm);
    color: var(--text-main);
    font-size: 0.95rem;
    transition: all 0.2s var(--transition);
}

.form-control:focus {
    outline: none;
    border-color: #6366f1; /* subtle focus ring */
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

.btn-primary {
    width: 100%;
    padding: 0.75rem 1rem;
    background: #1f2937; /* Dark flat button */
    color: white;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 0.95rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s var(--transition);
    box-shadow: var(--shadow-sm);
}

.btn-primary:hover {
    background: #111827;
}

.btn-primary:active {
    transform: translateY(1px);
}

.alert-danger {
    background: #fef2f2;
    color: #b91c1c;
    padding: 0.875rem;
    border-radius: var(--radius-sm);
    border: 1px solid #fecaca;
    margin-bottom: 1.5rem;
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

/* ================= DASHBOARD LAYOUT ================= */
.app-layout {
    display: flex;
    width: 100%;
    min-height: 100vh;
}

/* Sidebar */
.sidebar {
    width: 250px;
    background: #f8f9fa; /* Light gray sidebar */
    border-right: 1px solid var(--border-light);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    position: relative;
    z-index: 100;
    transition: transform 0.3s var(--transition);
}

.sidebar-header {
    padding: 1.5rem 1.25rem;
    font-size: 1.25rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--text-main);
    border-bottom: 1px solid var(--border-light);
}

.sidebar-header svg {
    stroke: var(--primary);
}

.sidebar-menu {
    list-style: none;
    padding: 1rem 0.75rem;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    flex: 1;
}

.sidebar-link {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.6rem 0.75rem;
    color: var(--text-muted);
    text-decoration: none;
    border-radius: var(--radius-sm);
    font-weight: 500;
    font-size: 0.9rem;
    transition: all 0.15s var(--transition);
    border: 1px solid transparent;
}

.sidebar-link:hover {
    background: rgba(0, 0, 0, 0.04);
    color: var(--text-main);
}

.sidebar-link.active {
    background: rgba(0, 0, 0, 0.06);
    color: var(--text-main);
    font-weight: 600;
}

.sidebar-footer {
    padding: 1rem 0.75rem;
    border-top: 1px solid var(--border-light);
}

.btn-logout {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 0.5rem;
    padding: 0.6rem 0.75rem;
    background: transparent;
    border: 1px solid transparent;
    color: var(--text-muted);
    border-radius: var(--radius-sm);
    cursor: pointer;
    text-decoration: none;
    transition: all 0.15s var(--transition);
    font-weight: 500;
    font-size: 0.9rem;
    width: 100%;
}

.btn-logout:hover {
    background: #fef2f2;
    color: #ef4444;
}

/* Main Content */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
    background: var(--bg-dark); /* The rest of the dashboard gets the light gray bg */
}

.dashboard-header {
    padding: 1rem 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--bg-card);
    border-bottom: 1px solid var(--border-light);
    position: sticky;
    top: 0;
    z-index: 50;
    height: 60px;
}

.dashboard-title {
    font-size: 1.15rem;
    font-weight: 600;
    color: var(--text-main);
}

.user-info {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.4rem 0.75rem;
    background: var(--bg-dark);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-light);
    font-size: 0.8rem;
    color: var(--text-muted);
}

.dashboard-container {
    padding: 2rem;
    max-width: 1600px;
    margin: 0 auto;
    width: 100%;
    animation: fadeIn 0.3s var(--transition);
}

/* ================= FORMS & FILTERS ================= */
.filter-form {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    margin-bottom: 1.5rem;
    padding: 1.25rem;
    background: var(--bg-card);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
}

.filter-group {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
    flex: 1;
    min-width: 180px;
}

.filter-label {
    font-size: 0.75rem;
    color: var(--text-muted);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.filter-input {
    padding: 0.6rem 0.75rem;
    background: var(--bg-card);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm);
    color: var(--text-main);
    font-size: 0.85rem;
    transition: border 0.15s;
    appearance: none;
}

select.filter-input {
    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='M8 9l4 4 4-4'%3E%3C/path%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.75rem center;
    background-size: 1.2rem;
    padding-right: 2.2rem;
}

select.filter-input option {
    background: var(--bg-card);
    color: var(--text-main);
}

.filter-input:focus {
    outline: none;
    border-color: #6366f1;
    box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.1);
}

.filter-actions {
    display: flex;
    gap: 0.75rem;
    align-items: flex-end;
    flex-wrap: wrap;
}

.filter-btn {
    padding: 0.6rem 1.2rem;
    background: var(--text-main);
    color: white;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.15s;
    height: 38px;
    box-shadow: var(--shadow-sm);
}

.filter-btn:hover {
    background: #111827;
}

.clear-btn {
    padding: 0.6rem 1.2rem;
    background: var(--bg-card);
    color: var(--text-muted);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    height: 38px;
    transition: all 0.15s;
    box-shadow: var(--shadow-sm);
}

.clear-btn:hover {
    background: #f9fafb;
    border-color: #9ca3af;
    color: var(--text-main);
}

/* ================= CHARTS ================= */
.charts-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1.5rem;
    margin-bottom: 1.5rem;
}

.chart-card {
    padding: 2rem;
    height: 400px;
    display: flex;
    justify-content: center;
    align-items: center;
    background: var(--bg-card);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
}

.chart-card canvas {
    max-height: 100%;
}

/* ================= TABLES (SUPABASE STUDIO STYLE) ================= */
.table-container {
    padding: 0;
    background: #ffffff;
    border: 1px solid var(--border-light);
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-sm);
    overflow: hidden; /* To keep border radius */
}

.table-header-row {
    display: none; /* Hide old dashboard-y title row, since the screenshot showed just a plain table */
}

.table-wrapper {
    overflow-x: auto;
    width: 100%;
}

table {
    width: 100%;
    border-collapse: collapse; /* Essential for joining borders like the screenshot */
    white-space: nowrap;
    font-size: 13px; /* Smaller font strictly matching the image */
}

th, td {
    padding: 8px 16px;
    text-align: left;
    border-bottom: 1px solid var(--border-light);
    border-right: 1px solid var(--border-light); /* Cells dividing lines */
    color: var(--text-main);
}

th:last-child, td:last-child {
    border-right: none;
}

th {
    color: var(--text-main);
    font-weight: 600;
    font-size: 13px;
    text-transform: none; /* Keep natural case per image ('SubeAdi text') */
    background: #f9fafb; /* Light header background */
    position: relative;
}

th::after {
    display: none; /* remove pseudo-element divider since we use border-right */
}

tbody tr {
    transition: background 0.1s;
}

tbody tr:last-child td {
    border-bottom: none;
}

tbody tr:hover td {
    background: #f9fafb;
}

.clickable-row {
    cursor: pointer;
}

/* Status Badges - Made simpler for minimal aesthetic */
.status-badge {
    padding: 0.2rem 0.5rem;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 500;
    display: inline-block;
}

.status-success {
    background: #f0fdf4;
    color: #166534;
    border: 1px solid #bbf7d0;
}

.status-danger {
    background: #fef2f2;
    color: #991b1b;
    border: 1px solid #fecaca;
}

.status-info {
    background: #eff6ff;
    color: #1e40af;
    border: 1px solid #bfdbfe;
}

.status-neutral {
    background: #f3f4f6;
    color: #374151;
    border: 1px solid #e5e7eb;
}

/* Pagination - Bottom Bar */
.pagination {
    display: flex;
    justify-content: flex-start;
    align-items: center;
    gap: 0.25rem;
    padding: 10px 16px;
    background: #f9fafb; /* The pagination bar in the image is at the table footer with this bg */
    border-top: 1px solid var(--border-light);
    flex-wrap: wrap;
    margin: 0; 
}

.page-link {
    padding: 4px 10px;
    background: var(--bg-card);
    border: 1px solid var(--border-strong);
    border-radius: 4px;
    color: var(--text-main);
    text-decoration: none;
    font-size: 13px;
    font-weight: 500;
    transition: all 0.1s;
}

.page-link:hover {
    background: #f3f4f6;
    border-color: #9ca3af;
}

.page-link.active {
    background: var(--text-main);
    border-color: var(--text-main);
    color: white;
    box-shadow: none;
}

/* Footer note */
.table-container > div:last-child > p {
    color: var(--text-muted) !important;
    font-size: 12px !important;
}
.table-container > div[style*="background: rgba(0,0,0,0.1)"] {
    background: var(--bg-card) !important; /* Fix old dark dashboard padding */
    padding: 0.5rem 1rem !important;
}


/* ================= MODAL ================= */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.4);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease;
}

.modal-overlay.show {
    opacity: 1;
    pointer-events: auto;
}

.modal-content {
    background: var(--bg-card);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-md);
    width: 90%;
    max-width: 500px;
    max-height: 85vh;
    display: flex;
    flex-direction: column;
    box-shadow: var(--shadow-lg);
    transform: scale(0.98);
    transition: transform 0.2s ease;
    overflow: hidden;
}

.modal-overlay.show .modal-content {
    transform: scale(1);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.25rem 1.5rem;
    background: #f9fafb;
    border-bottom: 1px solid var(--border-light);
}

.modal-title {
    font-size: 1.1rem;
    color: var(--text-main);
    font-weight: 600;
}

.modal-close {
    background: transparent;
    border: none;
    color: var(--text-muted);
    width: 28px;
    height: 28px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background 0.1s;
}

.modal-close:hover {
    background: #f3f4f6;
    color: var(--text-main);
}

.modal-body {
    overflow-y: auto;
    padding: 1.5rem;
    font-size: 13px;
}

.detail-row {
    display: flex;
    justify-content: space-between;
    padding: 0.75rem 0;
    border-bottom: 1px solid #f3f4f6;
}

.detail-row:last-child {
    border-bottom: none;
}

.detail-label {
    color: var(--text-muted);
    font-weight: 500;
    flex: 1;
}

.detail-value {
    color: var(--text-main);
    font-weight: 500;
    flex: 2;
    text-align: right;
    word-break: break-word;
}

/* Animations */
@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* Scrollbar Style */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}
::-webkit-scrollbar-track {
    background: transparent;
}
::-webkit-scrollbar-thumb {
    background: #d1d5db;
    border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
    background: #9ca3af;
}

/* ================= MOBİL (100% RESPONSIVE) ================= */
.mobile-menu-btn {
    display: none;
    background: transparent;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm);
    color: var(--text-main);
    cursor: pointer;
    padding: 0.4rem;
    z-index: 100;
    transition: background 0.15s;
}

.mobile-menu-btn:hover {
    background: #f3f4f6;
}

.mobile-menu-btn svg {
    width: 20px;
    height: 20px;
}

.sidebar-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.4);
    z-index: 90;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease;
}

.sidebar-overlay.show {
    opacity: 1;
    pointer-events: auto;
}

/* Tablet & Mobile */
@media (max-width: 1024px) {
    .dashboard-container {
        padding: 1.5rem;
    }
}

@media (max-width: 768px) {
    .app-layout {
        position: relative;
    }

    .sidebar {
        position: fixed;
        top: 0;
        left: -280px;
        height: 100vh;
        width: 260px;
        z-index: 95;
        box-shadow: var(--shadow-xl);
    }

    .sidebar.open {
        transform: translateX(280px); 
    }

    .sidebar-overlay {
        display: block; 
    }

    .main-content {
        max-width: 100%;
        width: 100%;
    }

    .dashboard-header {
        padding: 0.75rem 1rem;
        height: auto;
    }

    .user-info {
        display: none;
    }

    .mobile-menu-btn {
        display: flex;
        align-items: center;
        justify-content: center;
    }

    .filter-form {
        flex-direction: column;
        padding: 1rem;
    }

    .filter-group {
        min-width: 100%;
    }

    .filter-actions {
        width: 100%;
        flex-direction: column;
    }
    
    .filter-actions > button, .filter-actions > a {
        width: 100%;
    }

    th, td {
        padding: 0.75rem 1rem;
    }

    .chart-card {
        height: 300px;
        padding: 1rem;
    }

    .modal-content {
        width: 100%;
        max-width: 100%;
        max-height: 85vh;
        margin-top: auto;
        border-radius: 16px 16px 0 0;
        transform: translateY(100%);
    }

    .modal-overlay.show .modal-content {
        transform: translateY(0);
    }
    
    .detail-row {
        flex-direction: column;
        gap: 0.2rem;
        align-items: flex-start;
    }
    
    .detail-value {
        text-align: left;
        color: var(--text-main);
    }
}
