/* =========================================
   Global Styles
========================================= */
:root {
    --brand-yellow: #f4c400;
    --brand-yellow-soft: #fde68a;
    --brand-navy: #1f2937;
    --background-soft: #f7f7fb;
    --surface-color: #ffffff;
    --surface-muted: #f5f6fc;
    --text-primary: #1f2937;
    --text-secondary: #4b5563;
    --border-subtle: rgba(15, 23, 42, 0.08);
    --shadow-soft: 0 18px 45px rgba(148, 163, 184, 0.18);
    --shadow-strong: 0 28px 70px rgba(148, 163, 184, 0.22);
}

* {
    box-sizing: border-box;
}

html {
    overflow-x: hidden;
    max-width: 100vw;
}

body.app-body {
    font-family: "Inter", "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(160deg, #ffffff 0%, var(--background-soft) 100%);
    color: var(--text-primary);
    min-height: 100vh;
    overflow-x: hidden;
    max-width: 100vw;
    width: 100%;
}

.language-bar {
    background: rgba(255, 255, 255, 0.7);
    border-bottom: 1px solid var(--border-subtle);
}

.language-bar .form-select {
    min-width: 140px;
}

a,
.btn {
    transition: all 0.2s ease-in-out;
}

a:hover,
.btn:hover {
    opacity: 0.85;
}

hr {
    border-color: var(--border-subtle);
}

/* =========================================
   Auth Layout
========================================= */
.auth-layout {
    min-height: 100vh;
    color: var(--text-primary);
}

.auth-hero {
    position: relative;
    overflow: hidden;
    background: linear-gradient(135deg, rgba(255, 247, 210, 0.95), rgba(255, 236, 179, 0.9));
}

.auth-hero > * {
    position: relative;
    z-index: 2;
}

.auth-badge {
    background: rgba(255, 255, 255, 0.75);
    border-radius: 20px;
    padding: 0.75rem 1.4rem;
    display: inline-flex;
    align-items: center;
    gap: 0.75rem;
    font-size: 0.95rem;
    color: var(--text-primary);
    border: 1px solid rgba(244, 196, 0, 0.25);
    backdrop-filter: blur(8px);
}

.auth-badge .badge {
    border-radius: 999px;
    padding: 0.45rem 0.9rem;
    font-weight: 600;
    background: rgba(244, 196, 0, 0.18);
    color: var(--brand-navy);
}

.auth-card {
    background-color: var(--surface-color);
    border-radius: 24px;
    border: 1px solid var(--border-subtle);
    box-shadow: var(--shadow-soft);
    color: var(--text-primary);
}

.auth-card .text-secondary {
    color: var(--text-secondary) !important;
}

.auth-card .form-floating > label {
    color: var(--text-secondary);
}

.auth-card .form-control {
    border-radius: 14px;
    border: 1px solid rgba(15, 23, 42, 0.08);
    background: rgba(255, 255, 255, 0.95);
    color: var(--text-primary);
    padding: 1rem;
}

.auth-card .form-control:focus {
    border-color: rgba(244, 196, 0, 0.65);
    box-shadow: 0 0 0 4px rgba(244, 196, 0, 0.15);
    background: #ffffff;
}

.auth-card .form-control::placeholder {
    color: rgba(79, 70, 229, 0.35);
}

.auth-submit {
    border-radius: 14px;
    background: linear-gradient(135deg, var(--brand-yellow), var(--brand-yellow-soft));
    border: none;
    color: var(--brand-navy);
    font-weight: 600;
    box-shadow: 0 18px 40px rgba(244, 196, 0, 0.3);
}

.auth-submit:hover {
    box-shadow: 0 20px 50px rgba(244, 196, 0, 0.35);
}

.auth-submit:active {
    transform: translateY(1px);
}

.auth-footer-text {
    font-size: 0.875rem;
    color: var(--text-secondary);
}

.logo-mark {
    width: 120px;
}

.auth-card .logo-wrapper {
    display: inline-block;
    background-color: var(--brand-navy);
    padding: 16px 20px;
    border-radius: 12px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.15);
    border: 1px solid rgba(244, 196, 0, 0.3);
}

.auth-card .logo-mark {
    display: block;
    width: 120px;
    height: auto;
    object-fit: contain;
}

/* =========================================
   Dashboard Layout with Sidebar
========================================= */
.dashboard-wrapper {
    display: flex;
    min-height: calc(100vh - 40px);
}

.dashboard-sidebar {
    width: 280px;
    background: var(--surface-color);
    border-right: 1px solid var(--border-subtle);
    display: flex;
    flex-direction: column;
    position: fixed;
    height: calc(100vh - 40px);
    overflow-y: auto;
    box-shadow: 2px 0 8px rgba(0, 0, 0, 0.05);
}

.sidebar-header {
    padding: 1.5rem;
    border-bottom: 1px solid var(--border-subtle);
    text-align: center;
}

.logo-mark-sidebar {
    width: 80px;
    height: auto;
    display: block;
    margin: 0 auto;
}

.sidebar-nav {
    flex: 1;
    padding: 1rem 0;
}

.nav-menu {
    list-style: none;
    padding: 0;
    margin: 0;
}

.nav-menu .nav-item {
    margin: 0.25rem 0;
}

.nav-menu .nav-link {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1.5rem;
    color: var(--text-secondary);
    text-decoration: none;
    transition: all 0.2s ease;
    border-left: 3px solid transparent;
}

.nav-menu .nav-link:hover {
    background: rgba(244, 196, 0, 0.1);
    color: var(--text-primary);
    border-left-color: var(--brand-yellow);
}

.nav-menu .nav-link.active {
    background: rgba(244, 196, 0, 0.15);
    color: var(--brand-navy);
    font-weight: 600;
    border-left-color: var(--brand-yellow);
}

.nav-menu .nav-link.active i {
    color: var(--brand-yellow);
}

.nav-menu .nav-link i {
    width: 20px;
    text-align: center;
}

.sidebar-footer {
    padding: 1.5rem;
    border-top: 1px solid var(--border-subtle);
}

.dashboard-main {
    flex: 1;
    margin-left: 280px;
    padding: 2rem;
    background: var(--background-soft);
    min-height: calc(100vh - 40px);
    overflow-x: hidden; /* Prevent horizontal overflow */
    max-width: calc(100vw - 280px); /* Account for sidebar width */
}

/* Modal Scrollable Body */
.modal-body {
    max-height: calc(100vh - 250px);
    overflow-y: auto;
}

/* Select2 Bootstrap 5 Theme */
.select2-container--bootstrap-5 {
    width: 100% !important;
}

.select2-container--bootstrap-5 .select2-selection {
    border: 1px solid rgba(15, 23, 42, 0.08);
    border-radius: 14px;
    min-height: 38px;
}

.select2-container--bootstrap-5 .select2-selection--single {
    height: 38px;
}

.select2-container--bootstrap-5 .select2-selection--single .select2-selection__rendered {
    line-height: 36px;
    padding-left: 12px;
    padding-right: 30px;
}

.select2-container--bootstrap-5 .select2-selection__arrow {
    height: 36px;
    right: 12px;
}

.select2-container--bootstrap-5 .select2-dropdown {
    border: 1px solid rgba(15, 23, 42, 0.08);
    border-radius: 14px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.1);
}

.select2-container--bootstrap-5 .select2-results__option--highlighted[aria-selected] {
    background-color: rgba(244, 196, 0, 0.15);
    color: var(--brand-navy);
}

/* Select2 in Input Group */
.input-group .select2-container--bootstrap-5 {
    flex: 1 1 auto;
    width: 1% !important;
}

.input-group .select2-container--bootstrap-5 .select2-selection {
    border-top-right-radius: 0;
    border-bottom-right-radius: 0;
    border-right: none;
}

.input-group .select2-container--bootstrap-5.select2-container--open .select2-selection {
    border-top-right-radius: 0;
    border-bottom-right-radius: 0;
}

/* Select2 Dropdown in Modal - Fix z-index and positioning */
.modal .select2-container--bootstrap-5 .select2-dropdown {
    z-index: 9999;
}

.modal .select2-container--bootstrap-5.select2-container--open .select2-dropdown {
    z-index: 9999;
}

/* Fix Select2 dropdown positioning in modal */
body.modal-open .select2-container--bootstrap-5 {
    z-index: 1056;
}

body.modal-open .select2-container--bootstrap-5.select2-container--open {
    z-index: 1056;
}

body.modal-open .select2-dropdown {
    z-index: 1056 !important;
}

/* Select2 Search Input Styling */
.select2-container--bootstrap-5 .select2-search--dropdown .select2-search__field {
    border: 1px solid rgba(15, 23, 42, 0.08);
    border-radius: 8px;
    padding: 8px 12px;
}

.select2-container--bootstrap-5 .select2-search--dropdown .select2-search__field:focus {
    border-color: var(--brand-yellow);
    outline: none;
    box-shadow: 0 0 0 0.2rem rgba(244, 196, 0, 0.25);
}

/* Report Charts */
.report-container canvas {
    max-height: 400px;
}

.report-container .card .card-body canvas {
    max-height: 350px;
}

.report-container .chart-container {
    position: relative;
    height: 300px;
    width: 100%;
}

.report-container .chart-container canvas {
    max-height: 100% !important;
    width: 100% !important;
    height: auto !important;
}

/* Mobile responsive chart container adjustments */
@media (max-width: 767.98px) {
    .report-container .chart-container {
        height: 250px !important;
        min-height: 250px;
    }
}

@media (max-width: 575.98px) {
    .report-container .chart-container {
        height: 200px !important;
        min-height: 200px;
    }
}

/* Mobile Header */
.mobile-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem 1rem;
    background: var(--surface-color);
    border-bottom: 1px solid var(--border-subtle);
    position: sticky;
    top: 0;
    z-index: 999;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

.mobile-menu-toggle {
    color: var(--text-primary);
    font-size: 1.25rem;
    padding: 0.5rem;
    border: none;
    background: none;
}

.mobile-menu-toggle:hover,
.mobile-menu-toggle:focus {
    color: var(--brand-yellow);
    background: rgba(244, 196, 0, 0.1);
    border-radius: 8px;
}

.mobile-logo {
    width: 60px;
    height: auto;
    margin: 0 auto;
}

.mobile-spacer {
    width: 40px; /* Toggle button genişliği kadar boşluk */
}

.sidebar-close {
    position: absolute;
    top: 1rem;
    right: 1rem;
    color: var(--text-primary);
    font-size: 1.25rem;
    padding: 0.5rem;
    border: none;
    background: none;
}

.sidebar-close:hover,
.sidebar-close:focus {
    color: var(--brand-yellow);
    background: rgba(244, 196, 0, 0.1);
    border-radius: 8px;
}

.sidebar-header {
    position: relative;
}

.sidebar-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 999;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

.sidebar-overlay.show {
    opacity: 1;
    visibility: visible;
}

@media (max-width: 991.98px) {
    .dashboard-sidebar {
        transform: translateX(-100%);
        transition: transform 0.3s ease;
        z-index: 1000;
        height: 100vh;
        top: 0;
    }

    .dashboard-sidebar.show {
        transform: translateX(0);
    }

    .dashboard-main {
        margin-left: 0;
        padding: 1rem;
        width: 100% !important;
        max-width: 100vw !important;
        overflow-x: hidden;
    }

    .language-bar {
        position: relative;
        z-index: 998;
    }
}

/* =========================================
   Dashboard Styles
========================================= */
/* Container overflow control */
.customer-sale-container,
.user-container,
.stock-entry-container,
.report-container {
    width: 100%;
    max-width: 100%;
    overflow-x: hidden;
}

.dashboard-nav {
    background: var(--surface-color);
    border-bottom: 1px solid var(--border-subtle);
    box-shadow: 0 15px 30px rgba(148, 163, 184, 0.15);
}

.dashboard-nav .navbar-brand,
.dashboard-nav .nav-link {
    color: var(--text-primary);
}

.dashboard-nav .btn {
    background: rgba(244, 196, 0, 0.18);
    border: 1px solid rgba(244, 196, 0, 0.45);
    color: var(--brand-navy);
}

.dashboard-card {
    border-radius: 24px;
    border: 1px solid var(--border-subtle);
    background-color: var(--surface-color);
    box-shadow: var(--shadow-soft);
}

.dashboard-card .text-secondary {
    color: var(--text-secondary) !important;
}

.dashboard-card .badge {
    border-radius: 999px;
    padding: 0.6rem 1.1rem;
    font-weight: 600;
    background: rgba(244, 196, 0, 0.18);
    color: var(--brand-navy);
}

.dashboard-card .avatar-ring {
    width: 92px;
    height: 92px;
    border-radius: 50%;
    background: linear-gradient(135deg, rgba(244, 196, 0, 0.25), rgba(244, 196, 0, 0.08));
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--brand-yellow);
    font-size: 2rem;
    border: 1px solid rgba(244, 196, 0, 0.35);
}

.dashboard-feature {
    border-radius: 24px;
    border: 1px solid var(--border-subtle);
    background-color: var(--surface-color);
    box-shadow: var(--shadow-soft);
    transition: transform 0.25s ease, box-shadow 0.25s ease, border-color 0.25s ease;
    color: var(--text-primary);
}

.dashboard-feature:hover {
    transform: translateY(-6px);
    box-shadow: var(--shadow-strong);
    border-color: rgba(244, 196, 0, 0.35);
}

.dashboard-feature .feature-icon {
    width: 70px;
    height: 70px;
    border-radius: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.6rem;
    border: 1px solid rgba(15, 23, 42, 0.08);
}

.dashboard-feature .feature-icon.primary {
    background: rgba(244, 196, 0, 0.15);
    color: var(--brand-yellow);
}

.dashboard-feature .feature-icon.success {
    background: rgba(34, 197, 94, 0.12);
    color: #16a34a;
}

.dashboard-feature .feature-icon.info {
    background: rgba(59, 130, 246, 0.12);
    color: #2563eb;
}

.dashboard-feature .feature-icon.warning {
    background: rgba(245, 158, 11, 0.12);
    color: #d97706;
}

.dashboard-feature .feature-icon.danger {
    background: rgba(239, 68, 68, 0.12);
    color: #dc2626;
}

.dashboard-feature .feature-icon.neutral {
    background: rgba(107, 114, 128, 0.12);
    color: #4b5563;
}

.dashboard-feature .feature-title {
    font-weight: 600;
}

.dashboard-feature .feature-text {
    color: var(--text-secondary);
    font-size: 0.93rem;
}

.dashboard-feature .feature-link {
    border-radius: 12px;
    padding: 0.5rem 1.6rem;
    border-width: 1.5px;
}

/* =========================================
   Responsive Tweaks
========================================= */
@media (max-width: 991.98px) {
    .auth-card {
        margin: 0 1rem;
        border-radius: 20px;
    }

    .auth-hero {
        min-height: 40vh;
        padding: 2rem 1rem;
    }
    
    .auth-hero h1 {
        font-size: 1.75rem;
    }
    
    .auth-hero .lead {
        font-size: 1rem;
    }

    .dashboard-card {
        border-radius: 20px;
    }
    
    /* Auth form adjustments on tablet */
    .auth-card .card-body {
        padding: 1.5rem !important;
    }
}

@media (max-width: 575.98px) {
    .auth-layout {
        padding: 0;
    }
    
    .auth-hero {
        min-height: auto;
        padding: 1.5rem 1rem;
        text-align: center;
    }
    
    .auth-hero h1 {
        font-size: 1.5rem;
        margin-bottom: 1rem;
    }
    
    .auth-hero .lead {
        font-size: 0.9rem;
        margin-bottom: 1.5rem;
    }
    
    .auth-badge {
        font-size: 0.85rem;
        padding: 0.5rem 1rem;
    }
    
    .auth-card {
        margin: 1rem 0.75rem;
        border-radius: 16px;
    }
    
    .auth-card .card-body {
        padding: 1.25rem !important;
    }
    
    .auth-card h3 {
        font-size: 1.25rem;
    }
    
    .auth-card .form-control {
        padding: 0.875rem;
        font-size: 0.95rem;
    }
    
    .auth-submit {
        padding: 0.875rem;
        font-size: 0.95rem;
    }
    
    .auth-hero .d-flex.flex-column.gap-3 {
        gap: 1rem !important;
    }
    
    .auth-hero .badge {
        font-size: 0.8rem;
        padding: 0.4rem 0.8rem;
    }
    
    .auth-hero h6 {
        font-size: 0.9rem;
    }
    
    .auth-hero p {
        font-size: 0.85rem;
    }
}

@media (max-width: 767.98px) {
    .dashboard-main {
        padding: 1rem 0.75rem;
        overflow-x: hidden; /* Prevent horizontal overflow */
        max-width: 100%;
    }
    
    /* Container overflow control */
    .customer-sale-container,
    .user-container,
    .stock-entry-container,
    .report-container {
        overflow-x: hidden;
        max-width: 100%;
        width: 100%;
    }
    
    /* Page Headers */
    .customer-sale-container h2,
    .user-container h2,
    .stock-entry-container h2,
    .report-container h2 {
        font-size: 1.5rem;
    }
    
    /* Buttons */
    #btnNewSale,
    #btnNewUser,
    #btnNewStockEntry {
        font-size: 0.875rem;
        padding: 0.5rem 1rem;
    }
    
    #btnNewSale i,
    #btnNewUser i,
    #btnNewStockEntry i {
        margin-right: 0.25rem !important;
    }
    
    /* Search and Filter Bar */
    .card-body .row {
        margin: 0;
    }
    
    .card-body .row > [class*="col-"] {
        padding-left: 0.5rem;
        padding-right: 0.5rem;
    }
    
    /* Tables - Make them scrollable horizontally on mobile */
    .table-responsive {
        -webkit-overflow-scrolling: touch;
        overflow-x: auto;
        overflow-y: auto;
        display: block;
        width: 100%;
        max-width: 100%;
        margin: 0;
    }
    
    .table-responsive table {
        width: 100%;
        min-width: 1200px; /* Minimum width for table content */
    }
    
    /* Table header filters */
    .table thead th {
        min-width: 120px;
        white-space: nowrap;
        font-size: 0.75rem;
    }
    
    .table thead th .filter-input {
        font-size: 0.75rem;
        padding: 0.25rem 0.5rem;
    }
    
    .table tbody td {
        font-size: 0.75rem;
        white-space: nowrap;
    }
    
    /* Modals */
    .modal-dialog {
        margin: 0.5rem;
        max-width: calc(100% - 1rem);
    }
    
    .modal-dialog.modal-lg {
        max-width: calc(100% - 1rem);
    }
    
    .modal-body {
        max-height: calc(100vh - 200px);
        padding: 1rem;
    }
    
    /* Form Groups */
    .row.g-3 {
        margin-left: -0.375rem;
        margin-right: -0.375rem;
    }
    
    .row.g-3 > [class*="col-"] {
        padding-left: 0.375rem;
        padding-right: 0.375rem;
    }
    
    /* Card padding on mobile */
    .card-body {
        padding: 1rem !important;
    }
    
    /* Home page header */
    .dashboard-card .d-flex.flex-column.flex-lg-row {
        flex-direction: column !important;
        text-align: center;
    }
    
    .avatar-ring {
        margin-bottom: 1rem;
    }
    
    /* Report Charts on mobile */
    .report-container .chart-container {
        height: 250px !important;
    }
    
    .report-container .card-title {
        font-size: 0.95rem;
        margin-bottom: 0.75rem;
    }
    
    /* Report summary cards stack on mobile */
    .report-container .row.g-3 > [class*="col-"] {
        margin-bottom: 1rem;
    }
}

@media (max-width: 575.98px) {
    .dashboard-feature {
        border-radius: 20px;
    }

    .dashboard-feature .feature-icon {
        width: 60px;
        height: 60px;
        font-size: 1.4rem;
    }
    
    /* Home page feature cards stack on mobile */
    .row.g-4 > [class*="col-"] {
        margin-bottom: 1rem;
    }
    
    .dashboard-feature {
        margin-bottom: 0;
    }
    
    .feature-title {
        font-size: 1.1rem;
    }
    
    .feature-text {
        font-size: 0.9rem;
    }
    
    /* Language bar */
    .language-bar {
        padding: 0.5rem 0.75rem;
        font-size: 0.875rem;
        flex-wrap: wrap;
        gap: 0.5rem;
    }
    
    .language-bar .form-select-sm {
        font-size: 0.75rem;
        padding: 0.25rem 1.75rem 0.25rem 0.5rem;
        min-width: 120px;
    }
    
    .language-bar label {
        font-size: 0.8rem;
    }
    
    /* Smaller padding on mobile */
    .dashboard-main {
        padding: 0.75rem 0.5rem;
        overflow-x: hidden;
        max-width: 100vw;
    }
    
    /* Container overflow control for very small screens */
    .customer-sale-container,
    .user-container,
    .stock-entry-container,
    .report-container {
        overflow-x: hidden;
        max-width: 100vw;
        width: 100%;
        padding: 0;
        margin: 0;
    }
    
    /* Table responsive improvements */
    .table-responsive {
        overflow-x: auto;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
        width: 100%;
        max-width: 100%;
        margin: 0;
        padding: 0;
    }
    
    .table-responsive table {
        min-width: 1000px; /* Slightly smaller for very small screens */
    }
    
    /* Table font size */
    .table {
        font-size: 0.75rem;
    }
    
    .table th,
    .table td {
        padding: 0.4rem 0.2rem;
    }
    
    .table thead th {
        font-size: 0.7rem;
        min-width: 100px;
    }
    
    .table thead th .filter-input {
        font-size: 0.65rem;
        padding: 0.2rem 0.4rem;
    }
    
    /* Button groups stack vertically */
    .btn-group-vertical {
        flex-direction: column;
    }
    
    /* Action buttons in tables */
    .table td .btn {
        padding: 0.2rem 0.4rem;
        font-size: 0.7rem;
        min-width: 35px;
    }
    
    .table td .btn i {
        font-size: 0.7rem;
    }
}

/* CustomerSale Table Dynamic Column Widths */
#salesTable {
    table-layout: auto !important;
    width: 100% !important;
}

#salesTable thead th {
    white-space: normal !important;
    word-wrap: break-word;
}

#salesTable tbody td {
    white-space: normal !important;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

/* StockEntry Table Dynamic Column Widths */
#stockEntriesTable {
    table-layout: auto !important;
    width: 100% !important;
}

#stockEntriesTable thead th {
    white-space: normal !important;
    word-wrap: break-word;
}

#stockEntriesTable tbody td {
    white-space: normal !important;
    word-wrap: break-word;
    overflow-wrap: break-word;
}