/* Admin Dashboard Styles */

/* Search Controls */
/* --- ELITE SEARCH BARS --- */
.control-search {
    flex: 1;
    display: flex;
    align-items: center;
    position: relative;
    background: white;
    border: 1px solid #f1f5f9;
    border-radius: 50px;
    /* Pill style */
    padding: 0 18px;
    height: 42px;
    transition: all 0.3s cubic-bezier(0.165, 0.84, 0.44, 1);
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.02);
}

.control-search:focus-within {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.control-search i {
    color: #94a3b8;
    font-size: 1.1rem;
    margin-right: 10px;
}

.control-search input {
    border: none;
    outline: none;
    width: 100%;
    font-size: 0.9rem;
    color: #1e293b;
    background: transparent;
}

/* User Dashboard */
.btn-new-user {
    height: 42px;
    padding: 0 24px;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 8px;
    border-radius: 50px;
}

/* Settings Tab */
.settings-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 30px;
    padding-bottom: 20px;
    border-bottom: 1px solid #f1f5f9;
}

.currency-toggle-wrapper {
    display: flex;
    background: rgba(0, 0, 0, 0.05);
    border-radius: 30px;
    border: 1px solid rgba(0, 0, 0, 0.1);
    padding: 3px;
}

.currency-toggle-btn {
    border: none;
    background: transparent;
    color: #64748b;
    font-size: 0.8rem;
    font-weight: 700;
    padding: 5px 12px;
    border-radius: 20px;
    cursor: pointer;
    transition: all 0.2s;
}

.currency-toggle-btn.active {
    background: white;
    color: #0f172a;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

/* App Footer */
.app-footer {
    text-align: center;
    padding: 30px 20px;
    border-top: 1px solid #e2e8f0;
    margin-top: 50px;
    background: white;
}

.app-footer-brand {
    font-size: 0.9rem;
    color: #64748b;
    font-weight: 600;
    margin-bottom: 5px;
}

.app-footer-love {
    font-size: 0.8rem;
    color: #94a3b8;
}

.app-footer-copy {
    font-size: 0.7rem;
    color: #cbd5e1;
    margin-top: 10px;
    text-transform: uppercase;
    letter-spacing: 1px;
}

/* Table Column Widths */
.th-name {
    width: 18%;
}

.th-company {
    width: 13%;
}

.th-phone {
    width: 13%;
    text-align: center;
}

.th-email {
    width: 16%;
    text-align: center;
}

.th-role {
    width: 15%;
    text-align: center;
}

.th-status {
    width: 10%;
    text-align: center;
}

.th-actions {
    width: 15%;
    text-align: center;
}

/* RMA Table Columns */
.th-rma-date {
    width: 15%;
    text-align: center;
}

.th-rma-type {
    width: 10%;
    text-align: center;
}

.th-rma-ref {
    width: 15%;
}

.th-rma-client {
    width: 20%;
}

.th-rma-prod {
    width: 25%;
}

.th-rma-action {
    width: 15%;
    text-align: center;
}

/* Sales Table Columns */
.th-sales-date {
    width: 15%;
    text-align: center;
}

.th-sales-ref {
    width: 10%;
    text-align: center;
}

.th-sales-client {
    width: 25%;
}

.th-sales-total {
    width: 10%;
    text-align: right;
}

.th-sales-profit {
    width: 10%;
    text-align: right;
}

.th-sales-status {
    width: 15%;
    text-align: center;
}

.th-sales-action {
    width: 15%;
    text-align: center;
}

/* Global Button Icons */
.btn-icon {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    border: 1px solid #e2e8f0;
    background: white;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
    color: #64748b;
}

.btn-icon:hover {
    background: #f8fafc;
    border-color: #cbd5e1;
    color: #1e293b;
    transform: translateY(-1px);
}

.btn-icon.btn-delete:hover {
    background: #fef2f2;
    border-color: #fecaca;
    color: #ef4444;
}

/* Modal Drawers & Alignment */
.drawer-lg {
    width: 90%;
    max-width: 900px;
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.drawer-lg:not(.active) {
    transform: translateX(100%);
}

.drawer-lg.active {
    transform: translateX(0);
}

/* Cart View Container Fixes (Ensures visibility on PC) */
#view-cart {
    padding: 20px;
    min-height: 80vh;
}

#cart-container {
    flex: 1;
    display: block;
    width: 100%;
    margin: 0 auto;
    max-width: 1200px;
}

/* Modal Paper Layout (Receipt Style) */
.modal-paper-wrapper {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 90%;
    max-width: 900px;
    height: auto;
    max-height: 90vh;
    z-index: 30000;
    /* Above overlay */
    background: transparent;
    display: none;
    justify-content: center;
    align-items: center;
}

.modal-paper-wrapper.active {
    display: flex;
}

.modal-paper-card {
    background: white;
    width: 100%;
    height: 100%;
    max-height: 85vh;
    border-radius: 24px;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    animation: slideUp 0.3s ease-out;
}

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

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

/* Invoice Table */
.invoice-table th {
    font-size: 0.75rem;
    color: #64748b;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.invoice-table td {
    vertical-align: middle;
}

/* ==========================================================================
   MOBILE RESPONSIVE OVERRIDES (ADMIN & DASHBOARD)
   Target: Phones & Vertical Tablets (< 768px)
   Safe to edit: Does NOT affect Desktop
   ========================================================================== */
/* ==========================================================================
   ELITE TABLE SYSTEM (MODERN CARDS)
   ========================================================================== */
.table-wrap {
    background: white;
    border-radius: 24px;
    border: 1px solid #f1f5f9;
    box-shadow: 0 10px 30px -5px rgba(0, 0, 0, 0.04);
    overflow: hidden;
    margin-top: 20px;
}

.table-fixed-layout,
.table-full-width {
    width: 100%;
    border-collapse: collapse;
}

.table-fixed-layout thead,
.table-full-width thead {
    background: #f8fafc;
    border-bottom: 1px solid #f1f5f9;
}

.table-fixed-layout th,
.table-full-width th {
    padding: 15px 20px;
    text-align: left;
    font-size: 0.75rem;
    font-weight: 850;
    color: #475569;
    text-transform: uppercase;
    letter-spacing: 0.8px;
}

.table-fixed-layout td,
.table-full-width td {
    padding: 12px 20px;
    border-bottom: 1px solid #f1f5f9;
    color: #334155;
    font-size: 0.9rem;
    vertical-align: middle;
}

.table-fixed-layout tr:last-child td,
.table-full-width tr:last-child td {
    border-bottom: none;
}

.table-fixed-layout tr:hover,
.table-full-width tr:hover {
    background-color: #f8fafc;
}

.crm-table-row {
    cursor: pointer;
    transition: all 0.2s ease;
}

.crm-table-row:hover {
    background-color: #f1f5f9 !important;
}

.table-full-width th.text-center,
.table-full-width td.text-center {
    text-align: center;
}

.table-full-width th.text-right,
.table-full-width td.text-right {
    text-align: right;
}

/* --- ACTION BUTTONS (CIRCULAR ELITE) --- */
.action-btn-circle {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: none;
    cursor: pointer;
    transition: all 0.3s;
    font-size: 1rem;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05);
}

.btn-edit-light {
    background: #eff6ff;
    color: #3b82f6;
}

.btn-edit-light:hover {
    background: #dbeafe;
    transform: translateY(-2px);
}

.btn-delete-light {
    background: #fff1f2;
    color: #ef4444;
}

.btn-delete-light:hover {
    background: #fee2e2;
    transform: translateY(-2px);
}

.btn-view-light {
    background: #f0fdf4;
    color: #10b981;
}

.btn-view-light:hover {
    background: #dcfce7;
    transform: translateY(-2px);
}

/* --- STATUS PILLS EXTREME --- */
.pill-elite {
    padding: 6px 14px;
    border-radius: 50px;
    font-size: 0.7rem;
    font-weight: 850;
    text-transform: uppercase;
    display: inline-flex;
    align-items: center;
    gap: 5px;
}

.pill-success {
    background: #dcfce7;
    color: #166534;
}

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

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

.pill-info {
    background: #e0f2fe;
    color: #075985;
}

/* --- CRM AVATARS --- */
.user-avatar,
.avatar-crm {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    background: var(--primary);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 850;
    font-size: 0.9rem;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.1);
    border: 2px solid white;
    flex-shrink: 0;
    text-transform: uppercase;
    transition: transform 0.2s;
}

.user-avatar:hover,
.avatar-crm:hover {
    transform: scale(1.05);
}

/* Red buttons matching screenshot */
.btn-citycell-red {
    background: #d31628;
    color: white;
    border: none;
    padding: 10px 24px;
    border-radius: 50px;
    font-weight: 850;
    display: inline-flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    box-shadow: 0 6px 20px rgba(211, 22, 40, 0.15);
    transition: all 0.3s;
    text-transform: uppercase;
    font-size: 0.85rem;
}

.btn-citycell-red:hover {
    background: #b91c1c;
    box-shadow: 0 8px 25px rgba(211, 22, 40, 0.25);
    transform: translateY(-2px);
}

@media screen and (max-width: 768px) {

    /* --- 1. DASHBOARD HEADER & CONTROLS --- */
    .dashboard-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 15px;
    }

    .dashboard-title {
        font-size: 1.5rem;
    }

    .action-groups-container {
        width: 100%;
        overflow-x: auto;
        padding-bottom: 10px;
        justify-content: flex-start;
        /* Enable horizontal scroll for action buttons */
        -webkit-overflow-scrolling: touch;
    }

    .dashboard-controls {
        flex-direction: column;
        gap: 12px;
    }

    .control-search {
        width: 100%;
        min-width: 100%;
    }

    .controls-right-group {
        width: 100%;
        display: flex;
        justify-content: space-between;
        gap: 10px;
    }

    .control-presets {
        flex: 1;
        justify-content: center;
    }

    /* --- 2. TAB NAVIGATION (scrollable on mobile) --- */
    .grid-staggered-tabs {
        flex-wrap: nowrap;
        overflow-x: auto;
        white-space: nowrap;
        padding-bottom: 8px;
        margin-bottom: 20px;
        scrollbar-width: none;
    }

    .grid-staggered-tabs::-webkit-scrollbar {
        display: none;
    }

    .tab-btn {
        flex: 0 0 auto;
        padding: 10px 14px;
        font-size: 0.85rem;
    }

    /* --- 3. SMART CARDS (TABLE TRANSFORMATION) --- */
    /* Hide Table Headers */
    .table-full-width thead {
        display: none;
    }

    /* Make Rows into Cards */
    .table-full-width tbody tr {
        display: block;
        background: white;
        border-radius: 16px;
        box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05);
        margin-bottom: 20px;
        padding: 15px;
        border: 1px solid #f1f5f9;
        position: relative;
    }

    /* Make Cells into Flex Rows - Use data-label */
    .table-full-width td {
        display: flex;
        justify-content: space-between;
        align-items: center;
        padding: 10px 0;
        border-bottom: 1px dashed #f1f5f9;
        text-align: right;
        font-size: 0.9rem;
    }

    /* Inject Labels ONLY if data-label exists */
    .table-full-width td[data-label]::before {
        content: attr(data-label);
        font-weight: 700;
        color: #94a3b8;
        font-size: 0.8rem;
        text-transform: uppercase;
        text-align: left;
        margin-right: 15px;
    }

    .table-full-width td:last-child {
        border-bottom: none;
        padding-top: 15px;
        justify-content: flex-end;
        gap: 10px;
    }

    /* Special Case: Product Info Cell */
    .table-full-width td[data-label="Producto"] {
        flex-direction: column;
        align-items: flex-start;
        text-align: left;
        border-bottom: 2px solid #f1f5f9;
        padding-bottom: 15px;
        margin-bottom: 5px;
    }

    .table-full-width td[data-label="Producto"]::before {
        display: none;
        /* Hide label for the main product info */
    }

    /* Adjust Action Buttons in Mobile */
    .table-cell-center .btn-icon {
        width: 36px;
        height: 36px;
        font-size: 1.1rem;
    }

    /* --- 4. MODALS & DRAWERS --- */
    .drawer-lg {
        width: 100% !important;
        height: 100% !important;
        max-width: 100% !important;
        max-height: 100% !important;
        border-radius: 0 !important;
        top: 0 !important;
        left: 0 !important;
        transform: none !important;
        overflow-y: auto !important;
    }

    /* Header & Navigation Fixes */
    .nav-btn-icon {
        position: relative;
        background: #f1f5f9;
        border: none;
        width: 40px;
        height: 40px;
        border-radius: 10px;
        display: flex;
        align-items: center;
        justify-content: center;
        color: #475569;
        cursor: pointer;
        transition: all 0.2s;
    }

    .nav-btn-icon:hover {
        background: #e2e8f0;
        color: var(--primary);
        transform: translateY(-1px);
    }

    /* CRM Table Fixed Strategy */
    .table-wrap table {
        table-layout: fixed;
        width: 100%;
    }

    .table-wrap th,
    .table-wrap td {
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .table-wrap td:first-child {
        white-space: normal;
        /* Allow name to wrap if needed */
    }

    .swal-premium-popup {
        width: 95% !important;
        padding: 20px !important;
    }

    /* --- 5. STATS & METRICS --- */
    .audit-stats-card {
        min-width: 100%;
        margin-bottom: 10px;
    }

    .flex-gap-15 {
        flex-direction: column;
        gap: 10px;
    }

    /* --- 6. FORMS & GRID STACKING --- */
    .input-row,
    .form-row,
    .grid-2-cols,
    .grid-3-cols,
    .grid-4-cols,
    .purchase-grid-inputs,
    .dashboard-grid-stats {
        display: flex !important;
        flex-direction: column !important;
        gap: 15px !important;
    }

    .form-group {
        width: 100% !important;
    }

    /* Fix for SweetAlert2 forms */
    .swal2-html-container .input-row,
    .swal2-html-container .form-group {
        text-align: left !important;
    }

    /* Ensure specific inputs don't stretch too much or overflow */
    input[type="text"],
    input[type="number"],
    input[type="email"],
    input[type="password"],
    select,
    textarea {
        font-size: 16px !important;
        /* Prevents auto-zoom on iOS */
    }

    #quick-sale-wrapper {
        min-width: 100% !important;
    }

    #quick-sale-container,
    .quick-sale-grid {
        display: flex !important;
        flex-direction: column !important;
        gap: 15px !important;
    }

    .settings-main-content>div[style*="grid"] {
        display: flex !important;
        flex-direction: column !important;
        grid-template-columns: 1fr !important;
        gap: 15px !important;
    }

    .settings-hub-layout {
        flex-direction: column !important;
        min-height: auto !important;
    }

    .settings-sidebar {
        width: 100% !important;
        flex-direction: row !important;
        overflow-x: auto !important;
        padding: 10px !important;
        border-right: none !important;
        border-bottom: 1px solid #e2e8f0 !important;
        -webkit-overflow-scrolling: touch;
    }

    .settings-nav-item {
        padding: 10px 15px !important;
        white-space: nowrap !important;
    }

    .settings-nav-item span {
        display: none !important;
    }

    .settings-main-content {
        padding: 20px !important;
    }
}

/* --- ADMIN NAV ELITE (STAGGERED 2-ROW) --- */
.admin-nav-elite {
    background: #f3f6f9;
    padding: 10px;
    width: 100%;
    margin-bottom: 25px;
}

.nav-pill-container {
    background: white;
    border-radius: 40px;
    padding: 25px 40px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.04);
    display: flex;
    flex-direction: column;
    gap: 12px;
    width: 100%;
    margin: 0 auto 10px auto;
}

.nav-elite-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    gap: 10px;
}

.nav-elite-row.staggered {
    padding: 0 4%;
    /* Horizontal offset for staggering */
}

.admin-tab-item {
    display: flex;
    align-items: center;
    gap: 8px;
    background: transparent;
    border: none;
    color: #64748b;
    font-weight: 850;
    font-size: 0.88rem;
    padding: 10px 16px;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    white-space: nowrap;
    position: relative;
    border-radius: 20px;
}

.admin-tab-item i {
    font-size: 1.15rem;
    color: #94a3b8;
    transition: color 0.2s;
}

.admin-tab-item:hover {
    color: #1e293b;
    background: rgba(0, 0, 0, 0.02);
}

.admin-tab-item:active {
    transform: scale(0.98);
}

.admin-tab-item.active {
    color: #2563eb;
    background: #eff6ff;
    border: 2px solid #2563eb;
    border-radius: 25px;
    padding: 8px 18px;
}

.admin-tab-item.active i {
    color: #2563eb;
}

.admin-tab-item.danger-tab {
    color: #64748b;
}

.admin-tab-item.danger-tab:hover {
    color: #ef4444;
}

.admin-tab-item.active.danger-tab {
    color: #ef4444;
    border-color: #ef4444;
    background: #fef2f2;
}

/* Dashboard Header Styles */
.dashboard-elite-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    margin-bottom: 35px;
    border-bottom: 2px solid #f1f5f9;
    padding-bottom: 20px;
}

.dashboard-title {
    font-size: 2.2rem;
    font-weight: 900;
    color: #0f172a;
    margin: 0;
    letter-spacing: -1.5px;
    line-height: 1;
}

.dashboard-subtitle {
    margin: 8px 0 0 0;
    color: #64748b;
    font-weight: 600;
    font-size: 0.95rem;
}

@media screen and (max-width: 768px) {
    .dashboard-elite-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 15px;
        margin-bottom: 25px;
        padding-bottom: 15px;
    }

    .dashboard-title {
        font-size: 1.6rem;
    }

    .dashboard-subtitle {
        font-size: 0.85rem;
    }
}

/* Badge Elite Positioning */
.badge-elite {
    position: absolute;
    top: -5px;
    right: -5px;
    background: #f59e0b;
    color: white;
    font-size: 0.65rem;
    font-weight: 900;
    padding: 2px 6px;
    border-radius: 20px;
    border: 2px solid white;
    min-width: 18px;
    text-align: center;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.badge-elite.badge-blue {
    background: #3b82f6;
}

/* Responsive Scaling for low-res screens */
@media screen and (max-width: 1400px) {
    .admin-tab-item {
        font-size: 0.8rem;
        padding: 8px 12px;
        gap: 6px;
    }
}

@media screen and (max-width: 1100px) {
    .nav-pill-container {
        padding: 15px 20px;
    }

    .admin-tab-item {
        font-size: 0.75rem;
        padding: 6px 8px;
    }

    .admin-tab-item i {
        font-size: 1rem;
    }
}

@media screen and (max-width: 768px) {
    /* Hamburger Header Header */
    .admin-mobile-header {
        display: flex !important;
        justify-content: space-between;
        align-items: center;
        background: white;
        padding: 12px 20px;
        border-radius: 20px;
        box-shadow: 0 4px 15px rgba(0, 0, 0, 0.05);
        margin-bottom: 10px;
        cursor: pointer;
        border: 1.5px solid #e2e8f0;
        transition: all 0.2s;
    }

    .admin-mobile-header:active {
        transform: scale(0.98);
        background: #f8fafc;
    }

    .admin-info-pill {
        display: flex;
        align-items: center;
        gap: 12px;
        font-weight: 850;
        color: #1e293b;
        font-size: 0.9rem;
    }

    .admin-info-pill i {
        font-size: 1.3rem;
        color: #2563eb;
    }

    .admin-chevron {
        transition: transform 0.3s ease;
        color: #94a3b8;
    }

    .admin-nav-elite.open .admin-chevron {
        transform: rotate(180deg);
    }

    /* The Menu (Drawer/Dropdown) */
    .nav-pill-container {
        display: flex !important;
        flex-direction: column !important;
        gap: 5px !important;
        padding: 10px !important;
        border-radius: 20px !important;
        background: white !important;
        box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1) !important;
        position: absolute;
        top: 60px;
        left: 0;
        right: 0;
        z-index: 100;
        opacity: 0;
        visibility: hidden;
        transform: translateY(-10px);
        transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
        border: 1px solid #e2e8f0;
    }

    .admin-nav-elite.open .nav-pill-container {
        opacity: 1;
        visibility: visible;
        transform: translateY(0);
    }

    .admin-nav-elite {
        position: relative;
        z-index: 2000;
    }

    .nav-elite-row {
        display: flex !important;
        flex-direction: column !important;
        width: 100% !important;
        gap: 2px !important;
    }

    .nav-elite-row.staggered {
        padding: 0 !important;
    }

    .admin-tab-item {
        width: 100% !important;
        justify-content: flex-start !important;
        padding: 12px 18px !important;
        font-size: 0.9rem !important;
        border-radius: 14px !important;
        background: transparent !important;
        border: 2px solid transparent !important;
    }

    .admin-tab-item i {
        font-size: 1.3rem !important;
        width: 24px;
        text-align: center;
    }

    .admin-tab-item.active {
        background: #eff6ff !important;
        border-color: #2563eb !important;
        color: #2563eb !important;
    }

    .badge-elite {
        position: relative !important;
        top: 0 !important;
        right: 0 !important;
        margin-left: auto;
    }
}

/* Hide hamburger on desktop */
@media screen and (min-width: 769px) {
    .admin-mobile-header {
        display: none !important;
    }
}