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

:root {
    /* Main Variables (Dark Mode Default) */
    --primary-color: #9794c9;
    /* User Requested Color */
    --primary-hover: #827fb8;

    --bg-gradient-start: #0f172a;
    --bg-gradient-end: #1e293b;
    --bg-radial-1: #1e1b4b;
    --bg-radial-2: #312e81;

    --glass-bg: rgba(255, 255, 255, 0.05);
    --glass-border: rgba(255, 255, 255, 0.1);

    --card-bg: rgba(30, 41, 59, 0.7);
    --sidebar-bg: rgba(15, 23, 42, 0.7);

    --text-color: #f8fafc;
    --text-muted: #94a3b8;
    --text-head-gradient-start: #fff;
    --text-head-gradient-end: #94a3b8;

    --input-bg: rgba(15, 23, 42, 0.6);
    --input-focus-bg: rgba(15, 23, 42, 0.8);

    --table-head-bg: rgba(15, 23, 42, 0.4);
    --table-hover-bg: rgba(255, 255, 255, 0.02);

    --badge-success-bg: rgba(16, 185, 129, 0.2);
    --badge-success-text: #34d399;
    --badge-success-border: rgba(16, 185, 129, 0.3);

    --badge-info-bg: rgba(59, 130, 246, 0.2);
    --badge-info-text: #60a5fa;
    --badge-info-border: rgba(59, 130, 246, 0.3);

    --badge-warning-bg: rgba(245, 158, 11, 0.2);
    --badge-warning-text: #fbbf24;
    --badge-warning-border: rgba(245, 158, 11, 0.3);

    --badge-danger-bg: rgba(239, 68, 68, 0.2);
    --badge-danger-text: #f87171;
    --badge-danger-border: rgba(239, 68, 68, 0.3);

    --logo-color: #fff;
}

[data-theme="light"] {
    --bg-gradient-start: #f1f5f9;
    --bg-gradient-end: #e2e8f0;
    --bg-radial-1: #e0e7ff;
    /* Lighter Indigo */
    --bg-radial-2: #c7d2fe;

    --glass-bg: rgba(255, 255, 255, 0.6);
    --glass-border: rgba(0, 0, 0, 0.1);

    --card-bg: rgba(255, 255, 255, 0.8);
    --sidebar-bg: rgba(255, 255, 255, 0.8);

    --text-color: #1e293b;
    --text-muted: #64748b;
    --text-head-gradient-start: #1e293b;
    --text-head-gradient-end: #475569;

    --input-bg: rgba(255, 255, 255, 0.8);
    --input-focus-bg: #fff;

    --table-head-bg: rgba(0, 0, 0, 0.05);
    --table-hover-bg: rgba(0, 0, 0, 0.02);

    --badge-success-bg: rgba(16, 185, 129, 0.1);
    --badge-success-text: #059669;
    --badge-success-border: rgba(16, 185, 129, 0.2);

    --badge-info-bg: rgba(59, 130, 246, 0.1);
    --badge-info-text: #2563eb;
    --badge-info-border: rgba(59, 130, 246, 0.2);

    --badge-warning-bg: rgba(245, 158, 11, 0.1);
    --badge-warning-text: #d97706;
    --badge-warning-border: rgba(245, 158, 11, 0.2);

    --badge-danger-bg: rgba(239, 68, 68, 0.1);
    --badge-danger-text: #dc2626;
    --badge-danger-border: rgba(239, 68, 68, 0.2);

    --logo-color: #9794c9;
    /* Lilac for Light Mode */
}


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

a {
    text-decoration: none;
    color: inherit;
    transition: color 0.2s;
}

body {
    font-family: 'Inter', sans-serif;
    background: radial-gradient(circle at top left, var(--bg-radial-1), transparent 40%),
        radial-gradient(circle at bottom right, var(--bg-radial-2), transparent 40%),
        linear-gradient(135deg, var(--bg-gradient-start), var(--bg-gradient-end));
    background-attachment: fixed;
    height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    color: var(--text-color);
    overflow: hidden;
    transition: background 0.5s ease;
}

.login-container {
    width: 100%;
    max-width: 400px;
    padding: 2.5rem;
    background: var(--glass-bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--glass-border);
    border-radius: 24px;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.1);
    animation: fadeIn 0.8s ease-out;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

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

.login-header {
    text-align: center;
    margin-bottom: 2rem;
}

.login-header h2 {
    font-size: 2rem;
    font-weight: 700;
    letter-spacing: -0.025em;
    background: linear-gradient(to right, var(--text-head-gradient-start), var(--text-head-gradient-end));
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    margin-bottom: 0.5rem;
}

.login-header p {
    color: var(--text-muted);
    font-size: 0.95rem;
}

.form-group {
    margin-bottom: 1.5rem;
    position: relative;
}

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

.form-control {
    width: 100%;
    padding: 0.75rem 1rem;
    background: var(--input-bg);
    border: 1px solid var(--glass-border);
    border-radius: 12px;
    color: var(--text-color);
    font-size: 1rem;
    transition: all 0.3s ease;
}

.form-control:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 4px rgba(151, 148, 201, 0.2);
    background: var(--input-focus-bg);
}

.btn {
    padding: 0.875rem 1.5rem;
    border-radius: 12px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    border: none;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

.btn-primary {
    width: 100%;
    background: linear-gradient(135deg, var(--primary-color), var(--primary-hover));
    color: white;
    box-shadow: 0 4px 6px -1px rgba(151, 148, 201, 0.3);
}

.btn-secondary {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-color);
    border: 1px solid var(--glass-border);
}

.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.2);
}

.btn-success {
    background: linear-gradient(135deg, #10b981, #059669);
    color: white;
    box-shadow: 0 4px 6px -1px rgba(16, 185, 129, 0.3);
}

.btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 10px 15px -3px rgba(151, 148, 201, 0.4);
}

.form-actions {
    display: flex;
    gap: 1rem;
    margin-top: 2rem;
    justify-content: flex-start;
}

.form-actions [class*="btn"],
.header-actions [class*="btn"],
.search-bar [class*="btn"] {
    width: auto !important;
    min-width: 120px;
    flex: 0 0 auto;
}

.search-bar .btn-secondary {
    /* Exception for "Sıfırla" button to allow smaller size if needed, but min-width hits it. */
}

.btn-primary:active {
    transform: translateY(0);
}

.footer-text {
    text-align: center;
    margin-top: 1.5rem;
    color: var(--text-muted);
    font-size: 0.875rem;
}

.footer-text a {
    color: var(--primary-color);
    text-decoration: none;
    font-weight: 500;
}

.footer-text a:hover {
    text-decoration: underline;
}

/* Dashboard Styles */
.dashboard-container {
    display: flex;
    width: 100%;
    height: 100vh;
    background: transparent;
}

.sidebar {
    width: 260px;
    background: var(--sidebar-bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-right: 1px solid var(--glass-border);
    display: flex;
    flex-direction: column;
    padding: 1.5rem;
    transition: all 0.3s ease;
}

.sidebar-header {
    margin-bottom: 2rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--glass-border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-shrink: 0;
}

.sidebar-header h2 {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-color);
    background: linear-gradient(to right, var(--text-head-gradient-start), var(--text-head-gradient-end));
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

.nav-menu {
    list-style: none;
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding-right: 4px;
    /* Space for scrollbar */
    scrollbar-width: thin;
    scrollbar-color: var(--glass-border) transparent;
}

.nav-menu::-webkit-scrollbar {
    width: 4px;
}

.nav-menu::-webkit-scrollbar-track {
    background: transparent;
}

.nav-menu::-webkit-scrollbar-thumb {
    background: var(--glass-border);
    border-radius: 4px;
}

.nav-menu::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

.nav-item {
    margin-bottom: 0.5rem;
}

.nav-link {
    display: flex;
    align-items: center;
    padding: 0.75rem 1rem;
    color: var(--text-muted);
    text-decoration: none;
    border-radius: 12px;
    transition: all 0.3s ease;
    font-weight: 500;
}

.nav-link:hover,
.nav-link.active {
    background: rgba(151, 148, 201, 0.1);
    color: var(--primary-color);
    transform: translateX(5px);
}

.nav-link.active {
    font-weight: 700;
}

.nav-link span {
    margin-left: 0.75rem;
}

.user-profile {
    margin-top: auto;
    padding: 1rem;
    background: var(--glass-bg);
    border-radius: 12px;
    display: flex;
    align-items: center;
    border: 1px solid var(--glass-border);
    flex-shrink: 0;
}

.user-avatar {
    width: 40px;
    height: 40px;
    background: linear-gradient(135deg, var(--primary-color), var(--primary-hover));
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: 600;
    margin-right: 1rem;
}

.user-info h4 {
    font-size: 0.9rem;
    color: var(--text-color);
    margin-bottom: 0.2rem;
}

.user-info p {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.main-content {
    flex: 1;
    overflow-y: auto;
    padding: 2rem;
}

.top-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
}

.page-title h1 {
    font-size: 1.8rem;
    font-weight: 700;
    color: var(--text-color);
}

.card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 1.5rem;
}

.card {
    background: var(--card-bg);
    backdrop-filter: blur(12px);
    border: 1px solid var(--glass-border);
    border-radius: 16px;
    padding: 1.5rem;
    transition: transform 0.3s ease;
}

.card:hover {
    transform: translateY(-5px);
    border-color: rgba(151, 148, 201, 0.3);
}

.card h3 {
    font-size: 1.1rem;
    color: var(--text-muted);
    margin-bottom: 1rem;
}

.card .value {
    font-size: 2rem;
    font-weight: 700;
    color: var(--text-color);
}

.content-card {
    background: var(--card-bg);
    backdrop-filter: blur(12px);
    border: 1px solid var(--glass-border);
    border-radius: 16px;
    padding: 1.5rem;
}

.content-card h3 {
    color: var(--text-color);
    margin-bottom: 1rem;
}

/* Table Styles */
.table-container {
    background: var(--card-bg);
    backdrop-filter: blur(12px);
    border: 1px solid var(--glass-border);
    border-radius: 16px;
    border-radius: 16px;
    overflow-x: auto;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
}

.data-table th,
.data-table td {
    padding: 0.5rem 0.25rem;
    text-align: left;
    border-bottom: 1px solid var(--glass-border);
}

.data-table th {
    background: var(--table-head-bg);
    font-weight: 600;
    color: var(--text-muted);
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.data-table td {
    color: var(--text-color);
    font-size: 0.95rem;
}

.data-table tr:last-child td {
    border-bottom: none;
}

.data-table tr:hover {
    background: var(--table-hover-bg);
}

/* Utilities */
.text-right,
.data-table td.text-right,
.data-table th.text-right {
    text-align: right !important;
}

/* Badges */
.badge {
    padding: 0.25rem 0.75rem;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 600;
}

.badge-success {
    background: var(--badge-success-bg);
    color: var(--badge-success-text);
    border: 1px solid var(--badge-success-border);
}

.badge-info {
    background: var(--badge-info-bg);
    color: var(--badge-info-text);
    border: 1px solid var(--badge-info-border);
}

.badge-warning {
    background: var(--badge-warning-bg);
    color: var(--badge-warning-text);
    border: 1px solid var(--badge-warning-border);
}

.badge-danger {
    background: var(--badge-danger-bg);
    color: var(--badge-danger-text);
    border: 1px solid var(--badge-danger-border);
}

/* Action Buttons */
.action-buttons {
    display: flex;
    gap: 0.5rem;
}

.btn-icon {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    background: var(--glass-bg);
    color: var(--text-muted);
    transition: all 0.3s ease;
    text-decoration: none;
    border: 1px solid transparent;
}

.btn-icon:hover {
    background: rgba(151, 148, 201, 0.1);
    color: var(--primary-color);
    border-color: var(--primary-color);
}

.btn-icon.delete:hover {
    background: rgba(239, 68, 68, 0.2);
    color: #f87171;
    border-color: #f87171;
}

/* Back Button */
.btn-secondary {
    padding: 0.875rem 1.5rem;
    background: var(--glass-bg);
    color: var(--text-color);
    border: 1px solid var(--glass-border);
    border-radius: 12px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    display: inline-block;
    text-decoration: none;
}

.btn-secondary:hover {
    background: var(--glass-border);
    border-color: var(--text-muted);
}

/* Customer Detail Styles */
.customer-detail-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(350px, 1fr));
    gap: 1.5rem;
}

.detail-card h3 {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--glass-border);
    margin-bottom: 1.5rem;
    font-size: 1.1rem;
    color: var(--text-color);
}

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

.detail-row {
    display: flex;
    justify-content: space-between;
    margin-bottom: 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--glass-border);
}

.detail-row:last-child {
    border-bottom: none;
    margin-bottom: 0;
}

.detail-row label {
    color: var(--text-muted);
    font-weight: 500;
}

.detail-row span {
    color: var(--text-color);
    font-weight: 500;
    text-align: right;
}

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

.map-container {
    background: var(--glass-bg);
    border-radius: 12px;
    padding: 1rem;
    margin-top: 1rem;
}

/* Theme Toggle Button */
.theme-toggle {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text-muted);
    font-size: 1.2rem;
    transition: color 0.3s ease;
    padding: 0.5rem;
    border-radius: 50%;
}

.theme-toggle:hover {
    color: var(--primary-color);
    background: var(--glass-bg);
}

/* Customer Name Link */
.customer-name-link {
    color: var(--primary-color);
    text-decoration: none;
    font-weight: 600;
    transition: all 0.2s ease;
}


/* Collapsed Sidebar Styles */
.sidebar.collapsed {
    width: 80px;
    padding: 1.5rem 0.5rem;
}

.sidebar.collapsed .brand-text,
.sidebar.collapsed .nav-link span,
.sidebar.collapsed .user-info {
    display: none;
}

.sidebar.collapsed .sidebar-header {
    justify-content: center;
    flex-direction: column;
    gap: 1rem;
    padding-bottom: 1rem;
    text-align: center;
}

.sidebar.collapsed .header-buttons {
    flex-direction: column;
    gap: 0.5rem;
    align-items: center;
    width: 100%;
}

.sidebar.collapsed .nav-link {
    justify-content: center;
    padding: 0.75rem;
}

.sidebar.collapsed .nav-link i {
    margin: 0;
    font-size: 1.2rem;
}

.sidebar.collapsed .user-profile {
    flex-direction: column;
    padding: 0.5rem;
    gap: 0.5rem;
}

.sidebar.collapsed .user-profile>a:first-child {
    flex-direction: column;
    justify-content: center;
    align-items: center;
    width: 100%;
}

.sidebar.collapsed .user-avatar {
    margin: 0;
    width: 36px;
    height: 36px;
    font-size: 0.9rem;
}

/* Submenu Styles */
.nav-item.has-submenu {
    position: relative;
}

.submenu-toggle {
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
}

.submenu-toggle .arrow {
    font-size: 0.8em;
    transition: transform 0.3s ease;
}

.nav-item.open>.submenu-toggle .arrow {
    transform: rotate(180deg);
}

.submenu {
    list-style: none;
    padding-left: 1rem;
    overflow: hidden;
    max-height: 0;
    transition: max-height 0.3s ease-out;
    opacity: 0;
    /* Hide by default */
}

.nav-item.open .submenu {
    max-height: 500px;
    /* Arbitrary large height */
    opacity: 1;
    margin-top: 0.25rem;
}

.submenu .nav-link {
    font-size: 0.9em;
    padding: 0.6rem 1rem;
    color: var(--text-muted);
    gap: 0.75rem;
}

.submenu .nav-link:hover,
.submenu .nav-link.active {
    color: var(--primary-color);
    background: rgba(255, 255, 255, 0.05);
}

/* Sidebar Collapsed State Handling */
.sidebar.collapsed .submenu {
    display: none;
    /* Hide submenus when collapsed for now, or implement hover */
}

.sidebar.collapsed .submenu-toggle .arrow {
    display: none;
}

/* Sidebar Logo Handling */
.sidebar-header .full-logo {
    display: block;
    transition: opacity 0.3s ease;
}

.sidebar-header .small-logo {
    display: none;
    height: 35px;
    width: auto;
    transition: opacity 0.3s ease;
}

.sidebar.collapsed .sidebar-header .full-logo {
    display: none;
}

.sidebar.collapsed .sidebar-header .small-logo {
    display: block;
}

.full-logo,
.small-logo .logo-path {
    fill: var(--logo-color);
    transition: fill 0.3s ease;
}


/* Re-enable toggle button for collapsed sidebar? */
/* Actually, if we hide header buttons, we can't un-collapse.
   So we should keep the toggle button visible or move it.
   Common pattern: Toggle button is outside or stays visible.
   Let's keep buttons visible but maybe stack them or hide search/theme if space is tight.
*/
.sidebar.collapsed .sidebar-header {
    flex-direction: column;
    gap: 1rem;
    padding: 0.5rem;
}

.sidebar.collapsed .header-buttons {
    display: flex !important;
    justify-content: center;
    width: 100%;
}

.sidebar.collapsed #theme-toggle {
    display: none;
    /* Hide theme toggle in collapsed state to save space */
}

.sidebar.collapsed .sidebar-header .small-logo {
    display: block;
    margin: 0 auto;
}

/* MOBILE RESPONSIVE STYLES */
@media (max-width: 768px) {
    .dashboard-container {
        position: relative;
    }

    .sidebar {
        position: fixed;
        left: -280px;
        /* Hide off-canvas */
        top: 0;
        bottom: 0;
        z-index: 1000;
        box-shadow: 5px 0 15px rgba(0, 0, 0, 0.2);
    }

    /* Force expanded width on mobile even if collapsed class exists */
    .sidebar.collapsed {
        width: 260px !important;
        padding: 1.5rem !important;
    }

    /* Force show elements hidden by collapsed state */
    .sidebar.collapsed .brand-text,
    .sidebar.collapsed .nav-link span,
    .sidebar.collapsed .user-info,
    .sidebar.collapsed .sidebar-header .full-logo {
        display: block !important;
    }

    .sidebar.collapsed .sidebar-header .small-logo {
        display: none !important;
    }

    .sidebar.collapsed .nav-link {
        justify-content: flex-start !important;
    }

    .sidebar.collapsed .submenu {
        display: block !important;
        /* Allow JS to toggle max-height/opacity instead of display:none */
        /* Reset opacity/max-height logic in case it interferes, but basic display block enables interaction */
    }

    .sidebar.collapsed .submenu-toggle .arrow {
        display: block !important;
    }

    .sidebar.mobile-open {
        left: 0;
        /* Slide in */
    }

    .sidebar-overlay {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background: rgba(0, 0, 0, 0.5);
        z-index: 999;
        display: none;
        backdrop-filter: blur(4px);
    }

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

    /* Adjust Topbar for Mobile */
    .top-bar {
        flex-wrap: wrap;
        gap: 1rem;
    }

    #mobile-menu-toggle {
        display: block !important;
    }

    .page-title h1 {
        font-size: 1.5rem;
    }

    /* Stack Search Bar */
    .global-search-container {
        order: 3;
        max-width: 100% !important;
        margin: 0 !important;
        flex: 0 0 100%;
    }

    /* Hide Sidebar Toggle on Mobile */
    #sidebar-toggle {
        display: none;
    }

    /* Adjust Main Content Padding */
    .main-content {
        padding: 1rem;
    }

    /* Adjust Grid Columns */
    .dashboard-grid,
    .charts-row,
    .lists-row,
    .customer-detail-grid {
        grid-template-columns: 1fr !important;
    }

    .card-grid {
        grid-template-columns: 1fr;
    }

    /* Fix Chart Overflow */
    .chart-card {
        width: 100%;
        overflow: hidden;
        padding: 1rem;
        /* Reduce padding on mobile */
    }

    .chart-card canvas {
        max-width: 100% !important;
    }

    .charts-row {
        width: 100%;
        overflow-x: hidden;
    }

    .products-grid {
        grid-template-columns: 1fr !important;
    }
}

/* Modal Styles */
.modal {
    display: none;
    position: fixed;
    z-index: 2000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    overflow: auto;
    background-color: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    animation: fadeIn 0.2s ease-out;
}

.modal-content {
    background: var(--card-bg);
    margin: 10% auto;
    padding: 2rem;
    border: 1px solid var(--glass-border);
    border-radius: 16px;
    width: 90%;
    max-width: 500px;
    position: relative;
    backdrop-filter: blur(12px);
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.3);
}

.modal-content h2 {
    margin-bottom: 1.5rem;
    color: var(--text-color);
}

.close-modal {
    position: absolute;
    top: 1rem;
    right: 1.5rem;
    color: var(--text-muted);
    font-size: 1.75rem;
    font-weight: bold;
    cursor: pointer;
    transition: color 0.2s;
}

.close-modal:hover {
    color: var(--primary-color);
}

/* Date Picker Icon Fixes */
/* Use color-scheme to automatically handle calendar icon colors */
input[type="date"] {
    color-scheme: dark;
    cursor: pointer;
}

input[type="date"]::-webkit-calendar-picker-indicator {
    cursor: pointer;
    opacity: 1;
}

/* Light Mode */
[data-theme="light"] input[type="date"] {
    color-scheme: light;
}