/* ============================================
   MOBILE-SPECIFIC STYLES — Mobile-First
   Design System v2.0 — Outfit + Stone + Teal
   ============================================ */

/* Prevent text selection on interactive elements */
.btn,
.nav-link,
.mobile-menu-toggle,
.mobile-menu-close,
.sidebar-link,
.payment-btn,
.product-row {
    -webkit-tap-highlight-color: transparent;
    -webkit-touch-callout: none;
    user-select: none;
}

/* Smooth scrolling on mobile */
.content-wrapper,
.product-list,
.cart-items,
.table-responsive,
.product-list-container,
.cart-items-container,
.dashboard-grid {
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
}

/* Fix iOS input zoom — base mobile rule */
input[type="text"],
input[type="number"],
input[type="email"],
input[type="tel"],
input[type="password"],
textarea,
select {
    font-size: 16px;
}

@media (min-width: 768px) {
    input[type="text"],
    input[type="number"],
    input[type="email"],
    input[type="tel"],
    input[type="password"],
    textarea,
    select {
        font-size: inherit;
    }
}

/* Better modals — base is full-screen on mobile */
.modal-dialog {
    margin: 0;
    max-width: 100%;
    height: 100%;
}

.modal-content {
    height: 100%;
    border-radius: 0;
    border: none;
}

.modal-body {
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

@media (min-width: 768px) {
    .modal-dialog {
        margin: 1.75rem auto;
        max-width: 500px;
        height: auto;
    }

    .modal-content {
        height: auto;
        border-radius: var(--radius-lg, 16px);
        border: 1px solid var(--border-default, #e7e5e4);
    }
}

/* DataTables mobile touch targets — base mobile */
.dataTables_wrapper .dataTables_length,
.dataTables_wrapper .dataTables_filter {
    margin-bottom: 0.5rem;
}

.dataTables_wrapper .dataTables_length select,
.dataTables_wrapper .dataTables_filter input {
    min-height: 44px;
    font-size: 16px;
}

.dataTables_wrapper .dataTables_paginate {
    margin-top: 0.5rem;
}

.dataTables_wrapper .dataTables_paginate .paginate_button {
    min-height: 44px;
    min-width: 44px;
    padding: 0.5rem;
}

@media (min-width: 768px) {
    .dataTables_wrapper .dataTables_length select,
    .dataTables_wrapper .dataTables_filter input {
        min-height: auto;
        font-size: inherit;
    }

    .dataTables_wrapper .dataTables_paginate .paginate_button {
        min-height: auto;
        min-width: auto;
        padding: 0.35rem 0.75rem;
    }
}

/* Form layouts — base mobile */
.form-row,
.row {
    margin-left: 0;
    margin-right: 0;
}

.form-row > [class*="col-"],
.row > [class*="col-"] {
    padding-left: 0.5rem;
    padding-right: 0.5rem;
    margin-bottom: 0.75rem;
}

.input-group {
    flex-wrap: wrap;
}

.input-group .form-control {
    flex: 1 1 auto;
    min-width: 0;
}

@media (min-width: 768px) {
    .input-group {
        flex-wrap: nowrap;
    }

    .form-row > [class*="col-"],
    .row > [class*="col-"] {
        margin-bottom: 0;
    }
}

/* Cards — base mobile */
.card {
    margin-bottom: 0.75rem;
    border-radius: var(--radius-md, 12px);
}

.card-header {
    padding: 0.75rem;
    font-size: 0.875rem;
}

.card-body {
    padding: 0.75rem;
}

.card-footer {
    padding: 0.75rem;
}

@media (min-width: 768px) {
    .card {
        margin-bottom: 1rem;
    }

    .card-header {
        padding: 1rem 1.25rem;
        font-size: 1rem;
    }

    .card-body {
        padding: 1.25rem;
    }

    .card-footer {
        padding: 1rem 1.25rem;
    }
}

/* Button groups — base mobile */
.btn-group-vertical {
    width: 100%;
}

.btn-group-vertical .btn {
    width: 100%;
    margin-bottom: 0.5rem;
}

.btn-toolbar {
    flex-direction: column;
}

.btn-toolbar .btn-group {
    width: 100%;
    margin-bottom: 0.5rem;
}

@media (min-width: 768px) {
    .btn-group-vertical {
        width: auto;
    }

    .btn-group-vertical .btn {
        width: auto;
        margin-bottom: 0;
    }

    .btn-toolbar {
        flex-direction: row;
    }

    .btn-toolbar .btn-group {
        width: auto;
        margin-bottom: 0;
    }
}

/* Alerts — base mobile */
.alert {
    padding: 0.75rem;
    font-size: 0.8125rem;
    border-radius: var(--radius-sm, 8px);
}

.alert-dismissible .btn-close {
    padding: 0.75rem;
}

@media (min-width: 768px) {
    .alert {
        padding: 1rem 1.25rem;
        font-size: 0.875rem;
        border-radius: var(--radius-md, 12px);
    }
}

/* Badges — base mobile */
.badge {
    font-size: 0.6875rem;
    padding: 0.25rem 0.5rem;
}

/* Loading bar */
.mobile-loader {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 2px;
    background: var(--accent, #0d9488);
    z-index: 9999;
    animation: loading 1.2s cubic-bezier(0.16, 1, 0.3, 1) infinite;
}

@keyframes loading {
    0% { transform: translateX(-100%); }
    100% { transform: translateX(100%); }
}

/* PWA Install Banner */
.pwa-install-banner {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--stone-950, #0c0a09);
    color: white;
    padding: 1rem;
    box-shadow: 0 -4px 24px rgba(0, 0, 0, 0.15);
    z-index: 1000;
    display: none;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    border-radius: var(--radius-lg, 16px) var(--radius-lg, 16px) 0 0;
    padding-bottom: max(1rem, env(safe-area-inset-bottom));
}

.pwa-install-banner.show { display: flex; }

.pwa-install-banner .banner-content { flex: 1; }

.pwa-install-banner .banner-content h6 {
    margin: 0 0 0.25rem;
    font-size: 0.875rem;
    font-weight: 700;
    letter-spacing: -0.01em;
}

.pwa-install-banner .banner-content p {
    margin: 0;
    font-size: 0.8125rem;
    opacity: 0.7;
}

.pwa-install-banner .banner-actions {
    display: flex;
    gap: 0.5rem;
}

.pwa-install-banner .btn {
    white-space: nowrap;
    min-width: 80px;
}

/* Landscape orientation */
@media (orientation: landscape) and (max-height: 500px) {
    .navbar-container { padding: 0.4rem 1rem; }
    .content-wrapper { padding: 0.75rem; }
    .mobile-menu-sidebar { width: 260px; }
}

/* Dashboard mobile base */
.row .col-md-3 { margin-bottom: 0.75rem; }

.card .card-body h3 { font-size: 1.375rem; }
.card .card-body h5 { font-size: 0.875rem; margin-bottom: 0.5rem; }

.chart-container {
    margin-bottom: 0.75rem;
}

@media (min-width: 768px) {
    .row .col-md-3 { margin-bottom: 0; }
}

/* Print */
@media print {
    .top-navbar,
    .sidebar-nav,
    .mobile-menu-toggle,
    .mobile-menu-overlay,
    .mobile-menu-sidebar {
        display: none !important;
    }

    .content-wrapper { padding: 0; }
}

/* ============================================
   REPORTS PAGE — Mobile-First
   ============================================ */
.reports-page-container {
    padding: 0.25rem;
    height: auto;
    min-height: 100%;
    display: block;
    overflow: visible;
    width: 100%;
}

.reports-page-container::-webkit-scrollbar { width: 8px; }
.reports-page-container::-webkit-scrollbar-track { background: transparent; }
.reports-page-container::-webkit-scrollbar-thumb { background: var(--stone-300, #d6d3d1); border-radius: 8px; }
.reports-page-container::-webkit-scrollbar-thumb:hover { background: var(--stone-400, #a8a29e); }
.reports-page-container { scrollbar-width: thin; scrollbar-color: var(--stone-300, #d6d3d1) transparent; }

.reports-page-container h3 {
    flex: 0 0 auto;
    margin-bottom: 0.75rem;
    font-size: 1.1rem;
    font-weight: 800;
    letter-spacing: -0.03em;
}

.reports-card {
    flex: 0 0 auto;
    display: flex;
    flex-direction: column;
    margin-bottom: 0.5rem;
    overflow: visible;
}

.reports-card-header {
    flex: 0 0 auto;
    padding: 0.5rem 0.75rem;
}

.reports-card-header h5 {
    font-size: 0.9375rem;
    font-weight: 700;
    margin: 0;
    letter-spacing: -0.02em;
}

.reports-card-body {
    flex: 0 0 auto;
    display: flex;
    flex-direction: column;
    padding: 0.75rem;
    overflow: visible;
}

.reports-button-row { flex: 0 0 auto; margin-bottom: 0.5rem; }

.reports-button-row .reports-btn {
    padding: 0.375rem 0.75rem;
    font-size: 0.8125rem;
    min-height: 44px;
    font-weight: 600;
}

.reports-date-row { flex: 0 0 auto; margin-bottom: 0.5rem; }
.reports-date-row .form-label { font-size: 0.8125rem; margin-bottom: 0.25rem; font-weight: 600; }
.reports-date-row .form-control { padding: 0.375rem 0.5rem; font-size: 0.8125rem; min-height: 44px; }

.reports-summary {
    flex: 0 0 auto;
    padding: 0.75rem;
    font-size: 0.8125rem;
    margin-bottom: 0.75rem;
}

.reports-summary h5 { font-size: 0.875rem; font-weight: 700; margin-bottom: 0.5rem; }
.reports-summary p { margin-bottom: 0.25rem; font-size: 0.75rem; }

.reports-charts-row {
    flex: 0 0 auto;
    display: flex;
    flex-direction: column;
    overflow: visible;
    -webkit-overflow-scrolling: touch;
}

.reports-chart-container {
    height: 280px;
    position: relative;
    min-height: 250px;
    width: 100%;
}

.reports-chart-container canvas { position: relative; z-index: 10; }

.reports-chart-no-data {
    display: none;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 1;
    pointer-events: none;
    background-color: rgba(255, 255, 255, 0.9);
    padding: 0.625rem;
    border-radius: var(--radius-sm, 8px);
}

.reports-table-responsive {
    flex: 1;
    overflow-y: auto;
    overflow-x: auto;
    min-height: 0;
    -webkit-overflow-scrolling: touch;
}

.reports-table-responsive table { font-size: 0.75rem; margin-bottom: 0; }
.reports-table-responsive th, .reports-table-responsive td { padding: 0.4rem 0.3rem; font-size: 0.75rem; }

/* Reports tabs — horizontal scrolling on mobile */
.reports-tabs {
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
    flex-wrap: nowrap;
    white-space: nowrap;
    margin-bottom: 0.75rem;
    display: flex;
    -ms-overflow-style: none;
    scrollbar-width: none;
}

.reports-tabs::-webkit-scrollbar { display: none; }
.reports-tabs .nav-item { flex-shrink: 0; }

.reports-tabs .nav-link {
    padding: 0.5rem 0.75rem;
    font-size: 0.8125rem;
    white-space: nowrap;
    min-height: 44px;
    display: flex;
    align-items: center;
}

.reports-button-row .col-6 { padding-left: 0.25rem; padding-right: 0.25rem; }
.reports-charts-row .col-12 { width: 100%; margin-bottom: 0.75rem; }
.reports-card-body .form-check { margin-bottom: 0.5rem; }
.reports-card-body .form-check-label { font-size: 0.8125rem; padding-left: 0.5rem; }
.reports-card-body .form-check-input { width: 1.25rem; height: 1.25rem; margin-top: 0.125rem; }
.reports-card-body .d-flex.gap-2 { flex-direction: column; gap: 0.5rem !important; }
.reports-card-body .d-flex.gap-2 .btn { width: 100%; min-height: 44px; }

body.reports-page .content-wrapper {
    overflow-y: auto;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
}

@media (min-width: 768px) {
    .reports-page-container {
        padding: 0.5rem;
    }

    .reports-page-container h3 { font-size: 1.25rem; }
    .reports-card-body { padding: 0.5rem; }
    .reports-table-responsive table { font-size: 0.8125rem; }
    .reports-table-responsive th, .reports-table-responsive td { padding: 0.5rem; font-size: 0.8125rem; }
    .reports-summary p { font-size: 0.8125rem; }
    .reports-chart-container { height: 300px; }
    .reports-charts-row { flex-direction: row; flex-wrap: wrap; }
    .reports-card-body .d-flex.gap-2 { flex-direction: row; }
    .reports-card-body .d-flex.gap-2 .btn { width: auto; }
}

/* ============================================
   LIST PAGE — Mobile-First
   ============================================ */
.list-page-container {
    padding: 0.25rem;
    height: 100%;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.list-page-container h3 {
    flex: 0 0 auto;
    margin-bottom: 0.5rem;
    font-size: 1.1rem;
    font-weight: 800;
    letter-spacing: -0.03em;
}

.list-page-actions { flex: 0 0 auto; margin-bottom: 0.5rem; }
.list-page-actions .btn { min-height: 44px; }

.list-page-filters { flex: 0 0 auto; margin-bottom: 0.5rem; }
.list-page-filters .form-select { min-height: 44px; font-size: 16px; }

.list-page-card {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
    overflow: hidden;
    margin-bottom: 0;
}

.list-page-card-body {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
    overflow: hidden;
    padding: 0.5rem;
}

.list-page-table-responsive {
    flex: 1;
    overflow-x: auto;
    overflow-y: auto;
    min-height: 0;
    -webkit-overflow-scrolling: touch;
    font-size: 0.8125rem;
}

.list-page-table-responsive .dataTables_wrapper { font-size: 0.8125rem; }
.list-page-table-responsive .dataTables_wrapper .dataTables_length,
.list-page-table-responsive .dataTables_wrapper .dataTables_filter { margin-bottom: 0.5rem; }

.list-page-table-responsive .dataTables_wrapper .dataTables_length select,
.list-page-table-responsive .dataTables_wrapper .dataTables_filter input {
    min-height: 44px;
    font-size: 16px;
    padding: 0.5rem;
}

.list-page-table-responsive .dataTables_wrapper .dataTables_paginate { margin-top: 0.5rem; }

.list-page-table-responsive .dataTables_wrapper .dataTables_paginate .paginate_button {
    min-height: 44px;
    min-width: 44px;
    padding: 0.5rem;
    margin: 0.25rem;
}

.list-page-table-responsive table { font-size: 0.75rem; }
.list-page-table-responsive th, .list-page-table-responsive td { padding: 0.4rem 0.3rem; font-size: 0.75rem; }

@media (min-width: 768px) {
    .list-page-container { padding: 0.5rem; }
    .list-page-container h3 { font-size: 1.25rem; }
    .list-page-card-body { padding: 1rem; }
    .list-page-table-responsive { font-size: 0.875rem; }
    .list-page-table-responsive table { font-size: 0.8125rem; }
    .list-page-table-responsive th, .list-page-table-responsive td { padding: 0.5rem 0.75rem; font-size: 0.8125rem; }

    .list-page-table-responsive .dataTables_wrapper .dataTables_length select,
    .list-page-table-responsive .dataTables_wrapper .dataTables_filter input {
        min-height: auto;
        font-size: inherit;
    }

    .list-page-table-responsive .dataTables_wrapper .dataTables_paginate .paginate_button {
        min-height: auto;
        min-width: auto;
        padding: 0.35rem 0.75rem;
    }
}

/* ============================================
   ADMIN PAGES — Mobile-First
   ============================================ */
.admin-table-responsive {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.admin-table-responsive table {
    font-size: 0.75rem;
    min-width: 600px;
}

@media (min-width: 768px) {
    .admin-table-responsive table {
        font-size: 0.8125rem;
        min-width: auto;
    }
}

/* ============================================
   ORDERS CREATE — Mobile-First
   ============================================ */
.order-create-layout {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

@media (min-width: 992px) {
    .order-create-layout {
        flex-direction: row;
        gap: 1rem;
    }
}

/* ============================================
   TRANSACTIONS — Mobile-First
   ============================================ */
.transaction-filters {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

@media (min-width: 768px) {
    .transaction-filters {
        flex-direction: row;
        flex-wrap: wrap;
        gap: 0.75rem;
    }
}

/* ============================================
   SAFE AREA INSETS (notch devices)
   ============================================ */
@supports (padding: max(0px)) {
    .pwa-install-banner {
        padding-bottom: max(1rem, env(safe-area-inset-bottom));
    }

    .content-wrapper {
        padding-left: max(0.5rem, env(safe-area-inset-left));
        padding-right: max(0.5rem, env(safe-area-inset-right));
    }

    @media (min-width: 768px) {
        .content-wrapper {
            padding-left: max(0.75rem, env(safe-area-inset-left));
            padding-right: max(0.75rem, env(safe-area-inset-right));
        }
    }
}

/* ============================================
   375px KÜCÜK TELEFON DESTEĞİ (iPhone SE/8)
   ============================================ */
@media (max-width: 480px) {
    /* Ana içerik padding'i minimize et — safe area korumalı */
    .content-wrapper {
        padding: 0.25rem;
        padding-left: max(0.25rem, env(safe-area-inset-left));
        padding-right: max(0.25rem, env(safe-area-inset-right));
    }

    /* Sayfa toolbar sıkışıklığı gider */
    .page-toolbar {
        gap: 0.5rem;
        margin-bottom: 0.75rem;
    }

    .page-toolbar h3 {
        font-size: 1rem;
    }

    /* Toolbar butonları tam genişlik */
    .toolbar-actions {
        width: 100%;
    }

    .toolbar-actions .btn {
        flex: 1;
        font-size: 0.75rem;
        padding: 0.5rem 0.625rem;
        min-height: 44px;
    }

    /* Kartlar daha kompakt */
    .card-body {
        padding: 0.5rem;
    }

    .card-header {
        padding: 0.5rem 0.625rem;
        font-size: 0.8125rem;
    }

    .card-footer {
        padding: 0.5rem 0.625rem;
    }

    /* Tablo responsive — yatay scroll garanti */
    .table-card .card-body,
    .list-page-table-responsive {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    .list-page-table-responsive table,
    .table-card table {
        font-size: 0.6875rem;
        min-width: 500px;
    }

    .list-page-table-responsive th,
    .list-page-table-responsive td,
    .table-card th,
    .table-card td {
        padding: 0.3rem 0.25rem;
        font-size: 0.6875rem;
        white-space: nowrap;
    }

    /* DataTable filter/pagination küçült */
    .dataTables_wrapper .dataTables_filter input {
        width: 120px;
        font-size: 14px;
        padding: 0.375rem 0.5rem;
    }

    .dataTables_wrapper .dataTables_length select {
        font-size: 14px;
        padding: 0.375rem;
    }

    .dataTables_wrapper .dataTables_info {
        font-size: 0.6875rem;
    }

    /* Pagination butonları küçült — 375px'de yer kazanımı */
    .dataTables_wrapper .dataTables_paginate .paginate_button {
        min-height: 32px;
        min-width: 32px;
        padding: 0.2rem 0.375rem;
        font-size: 0.6875rem !important;
        margin: 0 1px !important;
    }

    .list-page-table-responsive .dataTables_wrapper .dataTables_paginate .paginate_button {
        min-height: 32px;
        min-width: 32px;
        padding: 0.2rem 0.375rem;
        font-size: 0.6875rem !important;
        margin: 1px !important;
    }

    .dataTables_wrapper .dataTables_paginate {
        display: flex;
        flex-wrap: wrap;
        justify-content: center;
        gap: 2px;
        margin-top: 0.375rem;
    }

    .list-page-table-responsive .dataTables_wrapper .dataTables_paginate {
        margin-top: 0.375rem;
    }

    /* DataTable length + filter yan yana kompakt */
    .dataTables_wrapper .dataTables_length,
    .dataTables_wrapper .dataTables_filter {
        font-size: 0.75rem;
        margin-bottom: 0.375rem;
    }

    .dataTables_wrapper .dataTables_length select {
        min-height: 32px;
    }

    .dataTables_wrapper .dataTables_filter input {
        min-height: 32px;
    }

    /* Liste sayfası başlık */
    .list-page-container h3 {
        font-size: 1rem;
    }

    /* Form düzenleri */
    .form-control,
    .form-select {
        font-size: 14px;
        padding: 0.375rem 0.5rem;
    }

    .form-label {
        font-size: 0.8125rem;
        margin-bottom: 0.25rem;
    }

    /* Buton minimum touch target */
    .btn {
        min-height: 44px;
    }

    /* Modal kompakt */
    .modal-body {
        padding: 0.75rem;
    }

    .modal-header {
        padding: 0.625rem 0.75rem;
    }

    .modal-footer {
        padding: 0.5rem 0.75rem;
    }

    /* Alert kompakt */
    .alert {
        padding: 0.5rem 0.625rem;
        font-size: 0.75rem;
    }

    /* Badge kompakt */
    .badge {
        font-size: 0.625rem;
        padding: 0.2rem 0.375rem;
    }

    /* Sayfa tab'ları */
    .nav-tabs .nav-link {
        font-size: 0.75rem;
        padding: 0.5rem 0.625rem;
        min-height: 44px;
    }

    /* Raporlar */
    .reports-page-container {
        padding: 0.125rem;
    }

    .reports-card-body {
        padding: 0.5rem;
    }

    .reports-table-responsive th,
    .reports-table-responsive td {
        padding: 0.3rem 0.2rem;
        font-size: 0.6875rem;
    }

    /* Admin tabloları */
    .admin-table-responsive table {
        font-size: 0.6875rem;
        min-width: 500px;
    }
}

/* ============================================
   REDUCED MOTION
   ============================================ */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
}
