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

:root {
    --primary-color: #4f46e5;
    --secondary-color: #64748b;
    --success-color: #10b981;
    --danger-color: #ef4444;
    --warning-color: #f59e0b;
    --bg-color: #f8fafc;
    --sidebar-bg: #1e293b;
    --text-color: #1e293b;
    --text-light: #64748b;
    --border-color: #e2e8f0;
    --card-bg: #ffffff;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background-color: var(--bg-color);
    color: var(--text-color);
    line-height: 1.6;
}

/* Login Page */
.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

.login-container {
    width: 100%;
    max-width: 420px;
    padding: 2rem;
}

.login-card {
    background: var(--card-bg);
    border-radius: 12px;
    padding: 2.5rem;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.2);
}

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

.login-header i {
    font-size: 3rem;
    color: var(--primary-color);
    margin-bottom: 1rem;
}

.login-header h1 {
    font-size: 1.75rem;
    color: var(--text-color);
    margin-bottom: 0.5rem;
}

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

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

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

.login-form label i {
    margin-right: 0.5rem;
    color: var(--primary-color);
}

.login-form input {
    width: 100%;
    padding: 0.75rem 1rem;
    border: 2px solid var(--border-color);
    border-radius: 8px;
    font-size: 1rem;
    transition: border-color 0.3s;
}

.login-form input:focus {
    outline: none;
    border-color: var(--primary-color);
}

.error-message {
    background: #fee2e2;
    color: #dc2626;
    padding: 0.75rem;
    border-radius: 8px;
    margin-bottom: 1rem;
    text-align: center;
    font-size: 0.9rem;
}

.container {
    display: flex;
    min-height: 100vh;
}

/* Sidebar Toggle Button */
.sidebar-toggle {
    position: fixed;
    top: 1rem;
    left: 1rem;
    z-index: 1001;
    background: var(--primary-color);
    color: white;
    border: none;
    padding: 0.75rem;
    border-radius: 8px;
    cursor: pointer;
    font-size: 1.25rem;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
    transition: all 0.3s;
    display: block; /* Always visible */
}

.sidebar-toggle:hover {
    background: var(--primary-hover);
    transform: scale(1.05);
}

.sidebar.collapsed {
    transform: translateX(-100%);
    transition: transform 0.3s ease;
}

.sidebar.collapsed ~ .main-content,
.container:has(.sidebar.collapsed) .main-content {
    margin-left: 0;
    transition: margin-left 0.3s ease;
}

.sidebar {
    width: 260px;
    background-color: var(--sidebar-bg);
    color: white;
    position: fixed;
    height: 100vh;
    overflow-y: auto;
    transition: transform 0.3s ease;
    z-index: 1000;
}

.sidebar-header {
    padding: 1.5rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.sidebar-header h2 {
    font-size: 1.25rem;
    font-weight: 600;
}

.sidebar-nav {
    padding: 1rem 0;
}

.nav-item {
    display: flex;
    align-items: center;
    padding: 0.75rem 1.5rem;
    color: rgba(255, 255, 255, 0.7);
    text-decoration: none;
    transition: all 0.2s;
}

.nav-item:hover {
    background-color: rgba(255, 255, 255, 0.1);
    color: white;
}

.nav-item.active {
    background-color: var(--primary-color);
    color: white;
}

.nav-item i {
    margin-right: 0.75rem;
    width: 20px;
}

/* Main Content */
.main-content {
    margin-left: 260px;
    flex: 1;
    padding: 2rem;
    transition: margin-left 0.3s ease;
}

.page {
    display: none;
}

.page.active {
    display: block;
}

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

.page-header h1 {
    font-size: 2rem;
    font-weight: 600;
}

.page-actions {
    display: flex;
    gap: 0.5rem;
}

/* Buttons */
.btn {
    padding: 0.5rem 1rem;
    border: none;
    border-radius: 0.375rem;
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
}

.btn-primary {
    background-color: var(--primary-color);
    color: white;
}

.btn-primary:hover {
    background-color: #4338ca;
}

.btn-secondary {
    background-color: var(--secondary-color);
    color: white;
}

.btn-secondary:hover {
    background-color: #475569;
}

.btn-danger {
    background-color: var(--danger-color);
    color: white;
}

.btn-danger:hover {
    background-color: #dc2626;
}

.btn-success {
    background-color: var(--success-color);
    color: white;
}

/* Stats Grid */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.stat-card {
    background: var(--card-bg);
    padding: 1.5rem;
    border-radius: 0.5rem;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    display: flex;
    align-items: center;
    gap: 1rem;
}

.stat-icon {
    width: 60px;
    height: 60px;
    border-radius: 0.5rem;
    background: linear-gradient(135deg, var(--primary-color), #6366f1);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 1.5rem;
}

.stat-info h3 {
    font-size: none;
    font-weight: 700;
    margin-bottom: 0.25rem;
}

.stat-info p {
    color: var(--text-light);
    font-size: 0.875rem;
}

/* Table */
.table-container {
    background: var(--card-bg);
    border-radius: 0.5rem;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    overflow-x: auto;
}

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

thead {
    background-color: var(--bg-color);
}

th {
    padding: 1rem;
    text-align: left;
    font-weight: 600;
    color: var(--text-color);
    border-bottom: 2px solid var(--border-color);
}

td {
    padding: 1rem;
    border-bottom: 1px solid var(--border-color);
}

tbody tr:hover {
    background-color: var(--bg-color);
}

/* Filters */
.filters {
    display: flex;
    gap: 1rem;
    margin-bottom: 1rem;
    flex-wrap: wrap;
    align-items: center;
}

.filters select,
.filters .filter-input,
.filters .filter-select {
    padding: 0.5rem 1rem;
    border: 1px solid var(--border-color);
    border-radius: 0.375rem;
    font-size: 0.875rem;
    background-color: white;
}

.filters .filter-input {
    min-width: 150px;
}

.filters .search-input {
    flex: 1;
    min-width: 200px;
}

/* Responsive layout adjustments */
@media (max-width: 1024px) {
    .main-content {
        padding: 1rem;
    }

    .page-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.75rem;
    }
}

@media (max-width: 900px) {
    /* Inventory count main grid stacks vertically */
    #inventory-count .page-header {
        align-items: flex-start;
    }

    #inventory-count .page-header h1 {
        font-size: 1.5rem;
    }
}

@media (max-width: 768px) {
    .container {
        flex-direction: column;
    }

    .main-content {
        margin-left: 0;
        padding: 1rem;
    }

    /* Sidebar toggle already exists; ensure content is full-width on mobile */
    .sidebar {
        width: 240px;
    }

    /* Inventory sessions + items + summary stacked */
    #inventory-count .page-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.75rem;
    }

    #inventory-count .page-header .btn {
        width: 100%;
        justify-content: center;
    }

    #inventory-count > div[style*="grid-template-columns"] {
        /* Sessions + items grid */
        display: block !important;
    }

    #inventory-count .card {
        margin-bottom: 1rem;
    }

    #inventory-count .table-container {
        max-height: none !important;
    }

    /* Summary and export cards stacked */
    #inventory-count .card + .card {
        margin-top: 1rem;
    }
}

/* Badges */
.badge {
    display: inline-block;
    padding: 0.25rem 0.75rem;
    border-radius: 9999px;
    font-size: 0.75rem;
    font-weight: 500;
}

.badge-success {
    background-color: #d1fae5;
    color: #065f46;
}

.badge-warning {
    background-color: #fef3c7;
    color: #92400e;
}

.badge-danger {
    background-color: #fee2e2;
    color: #991b1b;
}

.badge-info {
    background-color: #dbeafe;
    color: #1e40af;
}

/* Modal */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    overflow-y: auto;
    padding: 1rem;
}

.modal-content {
    background-color: var(--card-bg);
    margin: 2rem auto;
    padding: 2rem;
    border-radius: 0.5rem;
    max-width: 600px;
    position: relative;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
}

/* Conversation modal specific styles */
#conversation-modal .modal-content {
    max-width: 900px;
    display: flex;
    flex-direction: column;
    max-height: 90vh;
}

/* Chat/Conversations */
#conversation-modal h2 {
    margin: 0 0 1rem 0;
    padding-right: 2.5rem;
    color: var(--text-color);
    font-size: 1.5rem;
    font-weight: 600;
}

.conversation-meta {
    display: flex;
    gap: 1.5rem;
    flex-wrap: wrap;
    margin-bottom: 1.5rem;
    padding: 1rem;
    background: #f8fafc;
    border-radius: 8px;
    border: 1px solid var(--border-color);
    color: var(--text-color);
    font-size: 0.9rem;
}

.conversation-meta > div {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.conversation-meta strong {
    color: var(--text-color);
    font-weight: 600;
}

.chat-messages {
    flex: 1;
    min-height: 300px;
    max-height: 500px;
    overflow-y: auto;
    padding: 1rem;
    background: #f8fafc;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    margin-bottom: 1rem;
}

.chat-messages::-webkit-scrollbar {
    width: 8px;
}

.chat-messages::-webkit-scrollbar-track {
    background: #f1f5f9;
    border-radius: 4px;
}

.chat-messages::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 4px;
}

.chat-messages::-webkit-scrollbar-thumb:hover {
    background: #94a3b8;
}

.chat-message {
    display: flex;
    margin-bottom: 0.75rem;
}

.chat-message.admin {
    justify-content: flex-end;
}

.chat-message.customer {
    justify-content: flex-start;
}

.chat-bubble {
    max-width: 75%;
    padding: 0.75rem 1rem;
    border-radius: 12px;
    background: #ffffff;
    color: var(--text-color);
    position: relative;
    white-space: pre-wrap;
    word-break: break-word;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
    border: 1px solid var(--border-color);
}

.chat-message.admin .chat-bubble {
    background: #4f46e5;
    color: white;
    border-color: #4f46e5;
}

.chat-bubble strong {
    display: block;
    margin-bottom: 0.25rem;
    font-size: 0.875rem;
    font-weight: 600;
}

.chat-message.admin .chat-bubble strong {
    color: rgba(255, 255, 255, 0.9);
}

.chat-meta {
    font-size: 0.75rem;
    margin-top: 0.5rem;
    color: var(--text-light);
    opacity: 0.7;
}

.chat-message.admin .chat-meta {
    color: rgba(255, 255, 255, 0.8);
}

.chat-input {
    margin-top: auto;
    padding-top: 1rem;
    border-top: 1px solid var(--border-color);
}

.chat-input textarea {
    width: 100%;
    padding: 0.75rem;
    border-radius: 8px;
    border: 1px solid var(--border-color);
    resize: vertical;
    margin-bottom: 0.75rem;
    font-family: inherit;
    font-size: 0.875rem;
    line-height: 1.5;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.chat-input textarea:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
}

.chat-actions {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
}

.chat-actions select {
    padding: 0.5rem 0.75rem;
    border-radius: 0.375rem;
    border: 1px solid var(--border-color);
    background: white;
    font-size: 0.875rem;
    cursor: pointer;
    transition: border-color 0.2s;
}

.chat-actions select:focus {
    outline: none;
    border-color: var(--primary-color);
}

.chat-actions .btn {
    white-space: nowrap;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.close {
    position: absolute;
    right: 1rem;
    top: 1rem;
    font-size: 2rem;
    font-weight: bold;
    color: var(--text-light);
    cursor: pointer;
    width: 2rem;
    height: 2rem;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: all 0.2s;
    z-index: 10;
}

.close:hover {
    color: var(--text-color);
    background-color: #f1f5f9;
}

/* Form */
.form-group {
    margin-bottom: 1.5rem;
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

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

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--border-color);
    border-radius: 0.375rem;
    font-size: 0.875rem;
}

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

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

/* Banner mahsulot qidiruv dropdown */
.banner-product-dropdown {
    position: absolute;
    z-index: 1000;
    width: 100%;
    max-height: 220px;
    overflow-y: auto;
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    margin-top: 4px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}
.banner-product-result-item {
    padding: 10px 12px;
    cursor: pointer;
    border-bottom: 1px solid var(--border-color);
    transition: background 0.15s;
}
.banner-product-result-item:last-child {
    border-bottom: none;
}
.banner-product-result-item:hover {
    background: #f1f5f9;
}
.banner-product-result-name {
    display: block;
    font-weight: 500;
    color: var(--text-color);
}
.banner-product-result-sub {
    display: block;
    font-size: 0.8rem;
    color: var(--text-light);
    margin-top: 2px;
}
.form-group:has(#banner-product-search) {
    position: relative;
}

/* Chart */
.chart-container {
    background: var(--card-bg);
    padding: 1.5rem;
    border-radius: 0.5rem;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    margin-top: 2rem;
}

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

.action-btn {
    padding: 0.25rem 0.5rem;
    border: none;
    border-radius: 0.25rem;
    cursor: pointer;
    font-size: 0.875rem;
}

.action-btn-edit {
    background-color: #dbeafe;
    color: #1e40af;
}

.action-btn-delete {
    background-color: #fee2e2;
    color: #991b1b;
}

.action-btn-view {
    background-color: #d1fae5;
    color: #065f46;
}

.action-btn-print {
    background-color: #e0e7ff;
    color: #3730a3;
}

/* Map */
#map {
    background: var(--card-bg);
    border-radius: 0.5rem;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

/* Search input */
.search-input {
    padding: 0.5rem 1rem;
    border: 1px solid var(--border-color);
    border-radius: 0.375rem;
    font-size: 0.875rem;
    min-width: 250px;
}

/* Pagination */
.pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 0.5rem;
    margin: 1rem 0;
}

.pagination button {
    padding: 0.5rem 1rem;
    border: 1px solid var(--border-color);
    background: var(--card-bg);
    border-radius: 0.375rem;
    cursor: pointer;
}

.pagination button:hover:not(:disabled) {
    background: var(--bg-color);
}

.pagination button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.pagination .page-info {
    padding: 0 1rem;
    color: var(--text-light);
}

/* Alert/Notification */
.alert {
    padding: 1rem;
    border-radius: 0.375rem;
    margin-bottom: 1rem;
}

.alert-warning {
    background-color: #fef3c7;
    border-left: 4px solid var(--warning-color);
    color: #92400e;
}

.alert-danger {
    background-color: #fee2e2;
    border-left: 4px solid var(--danger-color);
    color: #991b1b;
}

/* Responsive */
@media (max-width: 768px) {
    .sidebar {
        width: 100%;
        max-width: 280px;
        transform: translateX(-100%);
        position: fixed;
        height: 100vh;
        z-index: 1000;
        transition: transform 0.3s ease;
    }

    .sidebar:not(.collapsed) {
        transform: translateX(0);
    }

    .main-content {
        margin-left: 0 !important;
        padding: 1rem;
        width: 100%;
    }

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

    /* Overlay when sidebar is open on mobile */
    body.sidebar-open::after {
        content: '';
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background: rgba(0, 0, 0, 0.5);
        z-index: 999;
        pointer-events: none;
    }

    .page-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 1rem;
    }

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

    .page-actions {
        width: 100%;
        flex-wrap: wrap;
    }

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

    .form-row {
        grid-template-columns: 1fr;
    }

    .table-container {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    table {
        min-width: 600px;
    }

    .login-container {
        padding: 1rem;
    }

    .login-card {
        padding: 1.5rem;
    }

    .login-header h1 {
        font-size: 1.5rem;
    }

    .login-header i {
        font-size: 2.5rem;
    }
}

@media (max-width: 468px) {
    .sidebar {
        width: 100%;
        max-width: 100%;
    }

    .main-content {
        padding: 0.75rem;
    }

    .page-header h1 {
        font-size: 1.25rem;
    }

    .btn {
        padding: 0.5rem 0.75rem;
        font-size: 0.8rem;
    }

    .stat-card {
        padding: 1rem;
        flex-direction: column;
        text-align: center;
    }

    .stat-icon {
        width: 50px;
        height: 50px;
        font-size: 1.25rem;
    }

    .login-card {
        padding: 1.25rem;
    }

    .login-header h1 {
        font-size: 1.25rem;
    }

    .login-header i {
        font-size: 2rem;
    }

    .form-group {
        margin-bottom: 1rem;
    }

    .filters {
        flex-direction: column;
        gap: 0.5rem;
    }

    .filters > * {
        width: 100%;
    }
}

/* Extra small devices (360px and below) */
@media (max-width: 360px) {
    .main-content {
        padding: 0.5rem;
    }

    .page-header h1 {
        font-size: 1.1rem;
    }

    .btn {
        padding: 0.4rem 0.6rem;
        font-size: 0.75rem;
    }

    .stat-card {
        padding: 0.75rem;
    }

    .stat-icon {
        width: 40px;
        height: 40px;
        font-size: 1rem;
    }

    .stat-info h3 {
        font-size: 1.1rem;
    }

    .stat-info p {
        font-size: 0.75rem;
    }

    .table-container {
        font-size: 0.75rem;
    }

    table {
        min-width: 500px;
    }

    th, td {
        padding: 0.5rem 0.25rem;
        font-size: 0.75rem;
    }

    .login-container {
        padding: 0.5rem;
    }

    .login-card {
        padding: 1rem;
    }

    .login-header h1 {
        font-size: 1.1rem;
    }

    .login-header i {
        font-size: 1.75rem;
    }

    .login-header p {
        font-size: 0.8rem;
    }

    .form-group label {
        font-size: 0.85rem;
    }

    .form-group input {
        font-size: 0.9rem;
        padding: 0.6rem;
    }

    .sidebar {
        max-width: 100%;
    }

    .sidebar-header h2 {
        font-size: 1rem;
    }

    .nav-item {
        padding: 0.5rem 1rem;
        font-size: 0.85rem;
    }

    .nav-item i {
        font-size: 0.9rem;
        margin-right: 0.5rem;
    }

    .page-actions {
        flex-direction: column;
        gap: 0.5rem;
    }

    .page-actions .btn {
        width: 100%;
    }

    .filters {
        gap: 0.25rem;
    }

    .search-input {
        min-width: 100%;
        font-size: 0.85rem;
    }

    .filter-input,
    .filter-select {
        font-size: 0.85rem;
        padding: 0.5rem;
    }

    .modal-content {
        margin: 1rem;
        padding: 1rem;
        max-width: calc(100% - 2rem);
    }

    .pagination {
        flex-wrap: wrap;
        gap: 0.25rem;
    }

    .pagination button {
        padding: 0.4rem 0.6rem;
        font-size: 0.75rem;
    }

    .action-buttons {
        flex-wrap: wrap;
        gap: 0.25rem;
    }

    .action-btn {
        padding: 0.4rem;
        font-size: 0.75rem;
    }
}

/* Settings Page Styles */
.settings-container {
    max-width: 900px;
}

.settings-section {
    background: white;
    padding: 1.5rem;
    margin-bottom: 1.5rem;
    border-radius: 8px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
    border: 1px solid var(--border-color);
}

.settings-section h2 {
    margin-bottom: 1.5rem;
    color: var(--primary-color);
    font-size: 1.25rem;
}

/* Reusable card style (customer app settings) */
.card {
    background: var(--card-bg);
    padding: 1.5rem;
    margin-bottom: 1.5rem;
    border-radius: 8px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
    border: 1px solid var(--border-color);
}

.card h2 {
    margin-bottom: 1rem;
    color: var(--primary-color);
    font-size: 1.2rem;
}

.card .form-group label input[type="checkbox"] {
    margin-right: 0.5rem;
}

.settings-form .form-group {
    margin-bottom: 1rem;
}

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

.logo-upload-section {
    margin-top: 1rem;
}

.logo-preview-container {
    margin-bottom: 1rem;
}

.logo-preview-container img {
    border: 1px solid var(--border-color);
    border-radius: 4px;
    padding: 0.5rem;
}

.settings-actions {
    margin-top: 2rem;
    text-align: right;
}

.btn-large {
    padding: 0.75rem 2rem;
    font-size: 1rem;
}
