:root {
    --bg-color: #f5f5f7;
    --card-bg: #ffffff;
    --text-primary: #1d1d1f;
    --text-secondary: #86868b;
    --accent: #000000;
    --accent-hover: #333333;
    --sidebar-bg: #fff;
    --border-color: #d2d2d7;
    --success: #28cd41;
    --warning: #ff9f0a;
    --danger: #ff3b30;
    --radius: 18px;
    --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05), 0 2px 4px -1px rgba(0, 0, 0, 0.03);
    --sidebar-width: 260px;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

body {
    background-color: var(--bg-color);
    color: var(--text-primary);
    overflow: hidden;
    height: 100vh;
}

/* Layout */
.main-layout {
    display: flex;
    height: 100vh;
    transition: all 0.3s ease;
}

/* Sidebar Responsive */
.sidebar {
    width: var(--sidebar-width);
    background: var(--sidebar-bg);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    padding: 20px;
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    z-index: 100;
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    transform: translateX(0);
}

.sidebar.collapsed {
    transform: translateX(-100%);
}

.sidebar-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 40px;
    padding-left: 10px;
}

.logo h1 {
    font-size: 1.5rem;
    font-weight: 700;
}

.close-menu-btn {
    display: none;
    font-size: 1.5rem;
    cursor: pointer;
    background: none;
    border: none;
}

.nav-links {
    list-style: none;
    flex: 1;
}

.nav-links li {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    margin-bottom: 5px;
    border-radius: 12px;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.2s;
    font-weight: 500;
}

.nav-links li:hover {
    background: #f5f5f7;
    color: var(--text-primary);
}

.nav-links li.active {
    background: var(--accent);
    color: #fff;
}

.nav-links li ion-icon {
    font-size: 1.2rem;
}

.user-profile {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px;
    border-top: 1px solid var(--border-color);
    margin-top: 20px;
}

.avatar {
    width: 32px;
    height: 32px;
    background: #e5e5ea;
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    font-weight: 700;
    font-size: 0.8rem;
}

/* Content Area */
.content-area {
    flex: 1;
    margin-left: var(--sidebar-width);
    overflow-y: auto;
    padding: 30px;
    position: relative;
    width: calc(100% - var(--sidebar-width));
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Header */
header {
    margin-bottom: 30px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 15px;
}

.menu-toggle-btn {
    font-size: 1.8rem;
    cursor: pointer;
    background: none;
    border: none;
    display: flex;
    align-items: center;
    color: var(--text-primary);
    margin-right: 5px;
    visibility: hidden;
}

h2 {
    font-size: 1.8rem;
    font-weight: 600;
    margin: 0;
}

.header-action-btn {
    background: var(--accent);
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 20px;
    cursor: pointer;
    font-weight: 500;
    transition: transform 0.2s;
}

.header-action-btn:active {
    transform: scale(0.95);
}

/* Responsive */
@media (max-width: 900px) {
    .menu-toggle-btn {
        visibility: visible;
    }

    .sidebar {
        transform: translateX(-100%);
        box-shadow: 2px 0 10px rgba(0, 0, 0, 0.1);
    }

    .sidebar.open {
        transform: translateX(0);
    }

    .content-area {
        margin-left: 0;
        width: 100%;
        padding: 20px;
    }

    .close-menu-btn {
        display: block;
    }

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

    header h2 {
        font-size: 1.4rem;
    }
}

/* Dashboard Grid */
.dashboard-grid-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 25px;
    margin-bottom: 35px;
}

.stat-card {
    background: #fff;
    padding: 25px;
    border-radius: 24px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.04);
    border: 1px solid rgba(0, 0, 0, 0.03);
    position: relative;
    overflow: hidden;
    transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.3s;
    display: flex;
    flex-direction: column;
    justify-content: center;
    min-height: 160px;
}

.stat-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 15px 35px rgba(0, 0, 0, 0.08);
}

.stat-icon {
    width: 50px;
    height: 50px;
    border-radius: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    margin-bottom: 15px;
}

.stat-info h3 {
    font-size: 0.9rem;
    color: var(--text-secondary);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    margin-bottom: 5px;
}

.stat-info p {
    font-size: 2.5rem;
    font-weight: 800;
    color: var(--text-primary);
    letter-spacing: -1px;
}

.close-register-btn {
    /* removed absolute positioning for flex container usage */
    position: relative;
    top: auto;
    right: auto;
    background: var(--text-primary);
    color: #fff;
    border: none;
    padding: 8px;
    /* Square icon button */
    border-radius: 12px;
    font-weight: 600;
    font-size: 1.2rem;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: 0.2s;
    width: 40px;
    height: 40px;
}

.close-register-btn:hover {
    transform: scale(1.1);
}

.dashboard-charts .card {
    background: #fff;
    border-radius: 24px;
    padding: 30px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.04);
    border: 1px solid rgba(0, 0, 0, 0.03);
}

/* Sales Table refinement */
.sales-table th {
    background: #f9f9f9;
    padding: 18px;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    border-bottom: none;
}

.sales-table th:first-child {
    border-radius: 10px 0 0 10px;
}

.sales-table th:last-child {
    border-radius: 0 10px 10px 0;
}

.sales-table td {
    padding: 20px 18px;
    border-bottom: 1px solid #f5f5f7;
    color: var(--text-primary);
    font-weight: 500;
}

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


/* Forms */
.form-group {
    margin-bottom: 15px;
}

label {
    display: block;
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-bottom: 5px;
    font-weight: 500;
}

input,
select {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid var(--border-color);
    border-radius: 10px;
    font-size: 0.95rem;
    outline: none;
    background: #fff;
}

input:focus,
select:focus {
    border-color: var(--accent);
}

button {
    width: 100%;
    padding: 12px;
    border-radius: 99px;
    border: none;
    background: var(--accent);
    color: #fff;
    font-weight: 600;
    cursor: pointer;
}

button:hover {
    background: var(--accent-hover);
}

/* Repairs List */
.repairs-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 20px;
}

.repair-item {
    background: #fff;
    border-radius: var(--radius);
    padding: 20px;
    border: 1px solid var(--border-color);
    cursor: pointer;
}

.status-badge {
    padding: 4px 10px;
    border-radius: 99px;
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
}

.status-Recibido {
    background: #e5e5ea;
    color: #1d1d1f;
}

.status-En_Proceso {
    background: #ffcc00;
    color: #fff;
}

.status-Listo {
    background: var(--success);
    color: #fff;
}

.status-Entregado {
    background: var(--text-primary);
    color: #fff;
}

/* POS Layout - Full Width for Products */
.pos-container {
    display: block;
    /* Removed grid to allow full width */
    height: auto;
    padding-bottom: 80px;
    /* Space for FAB */
}

.products-area {
    display: flex;
    flex-direction: column;
    gap: 20px;
    overflow-y: visible;
    padding-right: 0;
}

.category-filter {
    display: flex;
    gap: 10px;
    overflow-x: auto;
    padding-bottom: 15px;
}

/* More buffer */
.cat-btn {
    padding: 8px 16px;
    background: #fff;
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    border-radius: 99px;
    white-space: nowrap;
    width: auto;
    font-size: 0.9rem;
}

.cat-btn.active,
.cat-btn:hover {
    background: var(--text-primary);
    color: #fff;
    border-color: var(--text-primary);
}

.products-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
    gap: 15px;
}

.product-card {
    background: #fff;
    border-radius: 16px;
    padding: 15px;
    text-align: center;
    border: 1px solid var(--border-color);
    cursor: pointer;
    transition: 0.2s;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    height: 100%;
}

.product-card:hover {
    border-color: var(--accent);
    transform: translateY(-2px);
}

.prod-icon {
    font-size: 2rem;
    margin-bottom: 10px;
    display: block;
}

.prod-name {
    font-weight: 600;
    font-size: 0.9rem;
    margin-bottom: 5px;
    display: block;
}

.prod-price {
    color: var(--text-secondary);
    font-size: 0.85rem;
}

/* Floating Cart Button */
.floating-cart-btn {
    position: fixed;
    bottom: 30px;
    right: 30px;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: var(--accent);
    color: #fff;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 1.8rem;
    cursor: pointer;
    z-index: 900;
    transition: transform 0.2s;
}

.floating-cart-btn:hover {
    transform: scale(1.1);
}

.cart-count {
    position: absolute;
    top: -5px;
    right: -5px;
    background: var(--danger);
    color: white;
    font-size: 0.8rem;
    font-weight: 700;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
}

/* Modal Cart Styles (reusing modal structure but specific content) */
.cart-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
    padding-bottom: 12px;
    border-bottom: 1px solid #f5f5f7;
}

.remove-btn {
    background: none;
    border: none;
    color: #ff3b30;
    width: auto;
    padding: 5px;
    cursor: pointer;
    font-size: 1.2rem;
}

/* Sales Table */
.sales-table {
    width: 100%;
    border-collapse: collapse;
}

.sales-table th {
    text-align: left;
    padding: 15px;
    border-bottom: 1px solid #eee;
    color: #888;
    font-weight: 500;
    font-size: 0.85rem;
}

.sales-table td {
    padding: 15px;
    border-bottom: 1px solid #eee;
    font-size: 0.95rem;
}

/* RECEIPT STYLES */
.receipt-paper {
    background: #fff;
    padding: 10px;
}

.receipt-title {
    font-size: 2.5rem;
    font-weight: 800;
    margin-bottom: 5px;
    letter-spacing: -1px;
}

.receipt-divider {
    border-bottom: 2px dashed #eee;
    margin: 15px 0;
}

.receipt-item-row {
    display: flex;
    justify-content: space-between;
    margin-bottom: 8px;
    font-size: 0.9rem;
}

/* PRINT MEDIA */
@media print {
    body * {
        visibility: hidden;
    }

    #receiptModal,
    #receiptModal * {
        visibility: visible;
    }

    #receiptModal {
        position: absolute;
        left: 0;
        top: 0;
        width: 100%;
        height: 100%;
        background: #fff;
        display: block !important;
    }

    .close-btn,
    .checkout-btn {
        display: none !important;
    }

    .receipt-paper {
        padding: 0;
        width: 100%;
    }
}


/* Utils */
.tab-content {
    display: none;
    animation: fadeIn 0.3s ease;
}

.tab-content.active {
    display: block;
}

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

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

/* Modal */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(5px);
    z-index: 1000;
    justify-content: center;
    align-items: center;
}

.modal-content {
    background: #fff;
    padding: 30px;
    border-radius: var(--radius);
    max-width: 500px;
    width: 90%;
    max-height: 90vh;
    overflow-y: auto;
    position: relative;
    animation: slideUp 0.3s;
}

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

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

.close-btn {
    float: right;
    font-size: 1.5rem;
    cursor: pointer;
    line-height: 1;
}

.photo-gallery {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
    margin-top: 15px;
}

.photo-gallery img {
    width: 100%;
    aspect-ratio: 1;
    object-fit: cover;
    border-radius: 8px;
}

.photo-upload-btn {
    background: #f5f5f7;
    color: #000;
    border: 1px dashed #ccc;
    margin-top: 10px;
}

#fileInput {
    display: none;
}