@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');

:root {
    --primary-color: #2563eb;
    --primary-hover: #1d4ed8;
    --bg-color: #f8fafc;
    --card-bg: #ffffff;
    --text-color: #1e293b;
    --text-muted: #64748b;
    --border-color: #e2e8f0;
    --input-focus: #3b82f6;
    --error-color: #ef4444;
    --success-color: #10b981;
    --max-width: 1200px;
}

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

body {
    font-family: 'Inter', sans-serif;
    background-color: var(--bg-color);
    color: var(--text-color);
    line-height: 1.5;
}

/* Container */
.main-container {
    max-width: var(--max-width);
    margin: 0 auto;
    padding: 2rem;
    position: relative;
    z-index: 1;
}

/* --- Global Navbar Design 2026 --- */
:root {
    --nav-height: 56px;
}

body {
    padding-top: var(--nav-height);
    /* Offset for fixed top navbar */
}

.main-container {
    max-width: var(--max-width);
    margin: 0 auto;
    padding: 2rem;
    position: relative;
    z-index: 1;
}

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

.login-card {
    background: var(--card-bg);
    padding: 2.5rem;
    border-radius: 1rem;
    box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.1), 0 8px 10px -6px rgba(0, 0, 0, 0.1);
    width: 100%;
    max-width: 400px;
}

.login-card h2 {
    margin-bottom: 1.5rem;
    text-align: center;
    font-weight: 500;
    color: var(--text-color);
}

.login-form {
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
}

.login-form input {
    padding: 0.75rem 1rem;
    border: 1px solid var(--border-color);
    border-radius: 0.5rem;
    outline: none;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.login-form input:focus {
    border-color: var(--input-focus);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.login-form button {
    padding: 0.75rem;
    background-color: var(--primary-color);
    color: white;
    border: none;
    border-radius: 0.5rem;
    font-weight: 600;
    cursor: pointer;
    transition: background-color 0.2s;
}

.login-form button:hover {
    background-color: var(--primary-hover);
}

/* Global Elements */
h1 {
    font-size: 1.875rem;
    font-weight: 700;
    margin-bottom: 1.5rem;
}

h2 {
    font-size: 1rem;
    font-weight: 500;
    margin-bottom: 1rem;
}

hr {
    border: 0;
    border-top: 1px solid var(--border-color);
    margin: 2rem 0;
}

.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    /* margin-bottom: 1.5rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--border-color); */
}

.page-header h1 {
    margin: 0;
    font-size: 1.5rem;
    color: var(--text-color);
}

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

a {
    color: var(--primary-color);
    text-decoration: none;
}

a:hover {
    text-decoration: underline;
}

/* Table Styles */
table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    margin: 1.5rem 0;
}

th,
td {
    padding: 0.5rem 0.75rem;
    border-bottom: 1px solid var(--border-color);
    text-align: left;
    font-size: 0.8rem;
}

th {
    background-color: #f1f5f9;
    font-weight: 600;
    text-transform: uppercase;
    font-size: 0.7rem;
    letter-spacing: 0.05em;
    white-space: nowrap;
    position: sticky;
    top: 0;
    z-index: 10;
}

.table-container {
    width: 100%;
    overflow-x: auto;
    background: var(--card-bg);
    border-radius: 0.5rem;
    border: 1px solid var(--border-color);
    margin-bottom: 1.5rem;
}

.table-fixed-height {
    max-height: 250px;
    /* Aproximadamente 5-6 filas */
    overflow-y: auto;
}

.table-container table {
    margin: 0;
}

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

/* Search Form */
#searchForm {
    margin-bottom: 1rem;
}

/* Form Elements in Content */
input[type="text"],
input[type="number"],
input[type="password"],
input[type="email"],
input[type="date"],
select,
textarea {
    width: 100%;
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--border-color);
    border-radius: 0.375rem;
    font-size: 0.875rem;
    font-family: inherit;
    color: var(--text-color);
    background-color: #ffffff;
    transition: all 0.2s;
    outline: none;
}

input[type="date"]::-webkit-calendar-picker-indicator {
    cursor: pointer;
    opacity: 0.6;
    transition: opacity 0.2s;
    filter: invert(35%) sepia(85%) saturate(1682%) hue-rotate(205deg) brightness(97%) contrast(92%);
    /* Primary Blue tint */
}

input[type="date"]::-webkit-calendar-picker-indicator:hover {
    opacity: 1;
}

input:focus,
select:focus,
textarea:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

td input[type="text"],
td input[type="number"],
td select {
    padding: 0.25rem 0.5rem;
    font-size: 0.8rem;
}

button {
    padding: 0.5rem 1rem;
    border-radius: 0.375rem;
    cursor: pointer;
    font-weight: 500;
    border: 1px solid var(--border-color);
    background: #fff;
}

button[type="submit"] {
    background-color: var(--primary-color);
    color: white;
    border: none;
}

button[type="submit"]:hover {
    background-color: var(--primary-hover);
}

/* Notifications */
#notificationContainer {
    position: fixed;
    top: 1rem;
    right: 1rem;
    z-index: 1000;
    width: 320px;
}

/* Modal */
.modal {
    display: none;
    position: fixed;
    z-index: 2000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    opacity: 0;
    transition: opacity 0.3s ease;
    justify-content: center;
    align-items: center;
}

.modal.flex {
    display: flex;
}

.modal.show {
    opacity: 1;
}

.modal-content {
    background-color: var(--card-bg);
    padding: 2rem;
    border-radius: 1rem;
    width: 90%;
    max-width: 600px;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1);
    transform: translateY(20px);
    transition: transform 0.3s ease;
    position: relative;
}

.modal.show .modal-content {
    transform: translateY(0);
}

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

.modal-header h3 {
    margin: 0;
    font-size: 1.25rem;
}

.close {
    font-size: 1.5rem;
    font-weight: bold;
    cursor: pointer;
    color: var(--text-muted);
}

.modal-form {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.modal-footer {
    margin-top: 1.5rem;
    display: flex;
    justify-content: flex-end;
    gap: 0.75rem;
}

/* Action Buttons Styles */
.actionBtns {
    display: flex;
    gap: 0.25rem;
}

.action-btn-container {
    display: flex;
}

.btn-icon-text {
    display: inline-flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 0.25rem 0.5rem;
    font-size: 0.75rem;
    font-weight: 500;
    color: #374151;
    cursor: pointer;
    background: transparent;
    border: none !important;
    outline: none !important;
    box-shadow: none !important;
    transition: background-color 0.2s;
    border-radius: 0.375rem;
    min-width: 50px;
}

.btn-icon-text:hover {
    background-color: #f3f4f6;
}

.btn-icon-text .icon {
    font-size: 1rem;
    margin-bottom: 2px;
}

.text-xs {
    font-size: 0.75rem;
    line-height: 1;
}

.text-blue-500 {
    color: #3b82f6;
}

.text-orange-500 {
    color: #f97316;
}

/* Expandable Row Styles */
.dropdown-cell {
    width: 40px;
    text-align: center;
    cursor: pointer;
    color: var(--text-muted);
}

.dropdown-cell i {
    transition: transform 0.2s ease;
}

.expanded .dropdown-cell i {
    transform: rotate(180deg);
}

.details-row {
    display: none;
    background-color: #f8fafc;
}

.details-row.show {
    display: table-row;
}

.details-container {
    padding: 1rem;
    border-top: 1px inset var(--border-color);
}

.movements-table {
    width: 100%;
    font-size: 0.75rem;
    border: 1px solid var(--border-color);
    border-collapse: collapse;
    background: white;
}

.movements-table th {
    background: #f1f5f9;
    padding: 6px 10px;
}

.movements-table td {
    padding: 6px 10px;
    border-bottom: 1px solid var(--border-color);
}

.text-success {
    color: #10b981;
}

.text-danger {
    color: #ef4444;
}

/* Filters Styles */
.search-filters-container {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.search-bar-row {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

#searchForm {
    flex: 1;
    margin-bottom: 0;
}

.btn-filters {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    background: white;
    border: 1px solid var(--border-color);
    border-radius: 0.375rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-filters:hover {
    background: #f1f5f9;
}

.btn-filters.active {
    background: #eff6ff;
    border-color: var(--primary-color);
    color: var(--primary-color);
}

.filter-chips-container {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.chip {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.25rem 0.75rem;
    background: #f1f5f9;
    border-radius: 1rem;
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--text-color);
    border: 1px solid var(--border-color);
}

.chip .btn-remove-chip {
    cursor: pointer;
    color: var(--text-muted);
    font-size: 0.875rem;
}

.chip .btn-remove-chip:hover {
    color: var(--error-color);
}

.filters-panel {
    display: none;
    background: white;
    border: 1px solid var(--border-color);
    border-radius: 0.5rem;
    padding: 1.25rem;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    margin-bottom: 1.5rem;
}

.filters-panel.show {
    display: block;
}

.filters-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 1rem;
}

.filter-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.filter-group label {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-muted);
}

.filters-footer {
    display: flex;
    justify-content: flex-end;
    gap: 0.75rem;
    margin-top: 1.25rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border-color);
}

.btn-primary {
    background-color: var(--primary-color);
    color: white;
    border: none;
    padding: 0.5rem 1rem;
    border-radius: 0.375rem;
    cursor: pointer;
    font-weight: 500;
}

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

.filter-highlight {
    background-color: #fef9c3 !important;
    transition: background-color 0.3s ease;
}

th.filter-highlight {
    background-color: #fef08a !important;
}

/* Pagination Styles */
.table-header-actions {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.pagination {
    display: flex;
    gap: 0.25rem;
}

.p-btn {
    min-width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--border-color);
    background: white;
    border-radius: 0.25rem;
    font-size: 0.875rem;
    cursor: pointer;
    transition: all 0.2s;
}

.p-btn:hover {
    background: #f1f5f9;
    border-color: var(--primary-color);
    color: var(--primary-color);
}

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

.p-btn.disabled {
    opacity: 0.5;
    cursor: not-allowed;
    pointer-events: none;
}

.p-dots {
    display: flex;
    align-items: flex-end;
    padding: 0 0.25rem;
    color: var(--text-muted);
}

/* Sorting Styles */
th.sortable {
    cursor: pointer;
    position: relative;
    padding-right: 25px !important;
    transition: background 0.2s;
}

th.sortable:hover {
    background-color: #f1f5f9 !important;
}

th.sortable::after {
    content: "\f0dc";
    font-family: "Font Awesome 6 Free";
    font-weight: 900;
    position: absolute;
    right: 8px;
    color: #cbd5e1;
    font-size: 0.75rem;
    top: 50%;
    transform: translateY(-50%);
}

th.sortable.asc::after {
    content: "\f0de";
    color: var(--primary-color);
}

th.sortable.desc::after {
    content: "\f0dd";
    color: var(--primary-color);
}

/* --- Badge System 2026 --- */
.badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.25rem 0.625rem;
    font-size: 0.75rem;
    font-weight: 600;
    border-radius: 9999px;
    line-height: 1;
    white-space: nowrap;
    border: 1px solid transparent;
}

.badge-success {
    background-color: #dcfce7;
    color: #166534;
    border-color: #bbf7d0;
}

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

.badge-warning {
    background-color: #fef9c3;
    color: #854d0e;
    border-color: #fef08a;
}

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

.badge-neutral {
    background-color: #f1f5f9;
    color: #475569;
    border-color: #e2e8f0;
}

/* --- Action Badges (Tiny buttons styled as badges) --- */
.action-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.35rem 0.75rem;
    font-size: 0.7rem;
    font-weight: 500;
    border-radius: 0.375rem;
    cursor: pointer;
    transition: all 0.2s;
    border: 1px solid transparent;
}

.action-badge i {
    font-size: 0.85rem;
}

.action-badge-blue {
    background-color: #eff6ff;
    color: #1d4ed8;
    border-color: #dbeafe;
}

.action-badge-blue:hover {
    background-color: #dbeafe;
    color: #1e40af;
}

.action-badge-orange {
    background-color: #fff7ed;
    color: #c2410c;
    border-color: #ffedd5;
}

.action-badge-orange:hover {
    background-color: #ffedd5;
    color: #9a3412;
}

.action-badge-red {
    background-color: #fef2f2;
    color: #b91c1c;
    border-color: #fee2e2;
}

.action-badge-red:hover {
    background-color: #fee2e2;
    color: #991b1b;
}

.action-badge-gray {
    background-color: #f8fafc;
    color: #475569;
    border-color: #e2e8f0;
}

.action-badge-gray:hover {
    background-color: #f1f5f9;
    color: #1e293b;
}

.doc-link {
    display: inline-flex;
    align-items: center;
    padding: 2px 8px;
    background-color: #f1f5f9;
    color: var(--primary-color);
    border-radius: 4px;
    font-weight: 600;
    text-decoration: none !important;
    border: 1px solid #e2e8f0;
    transition: all 0.2s;
}

.doc-link:hover {
    background-color: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
}

/* Collapsible Content */
.collapsible-content {
    background: var(--card-bg);
    border-radius: 0.5rem;
    border: 1px solid var(--border-color);
    padding: 1.5rem;
    margin-bottom: 1.5rem;
    opacity: 1;
    overflow: visible;
}

.btn-toggle {
    display: none;
    /* Hide toggle button on desktop */
}

/* Form Grid System - Desktop (Single line) */
.form-grid {
    display: flex;
    flex-wrap: nowrap;
    gap: 0.5rem;
    align-items: flex-end;
}

.form-row-mobile-trio {
    display: contents;
}

.form-grid .form-group {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}

.form-grid .form-group label {
    font-size: 0.65rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.form-actions {
    margin-top: 0;
    display: flex;
}

.form-actions button {
    white-space: nowrap;
    height: 34px;
    /* Slightly more compact for single line */
    padding: 0 1rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

/* Responsive Mobile */
@media (max-width: 768px) {
    .btn-toggle {
        display: flex;
    }

    .form-entry-header {
        cursor: pointer;
    }

    .collapsible-content {
        max-height: 0;
        opacity: 0;
        padding: 0;
        margin-bottom: 0px;
        border: none;
        overflow: hidden;
        transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    }

    .collapsible-content.show {
        max-height: 800px;
        /* Better value to avoid jumpy transition */
        opacity: 1;
        padding: 1.25rem;
        margin-bottom: 1.5rem;
        border: 1px solid var(--border-color);
    }

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

    .form-row-mobile-trio {
        display: flex;
        gap: 0.25rem;
    }

    .form-actions {
        width: 100%;
        margin-top: 0.5rem;
    }

    .form-actions button {
        width: 100%;
        height: 42px;
        justify-content: center;
    }

    .page-header h2 {
        font-size: 0.9rem;
    }
}
/* Product Table to Cards (Mobile) */
@media (max-width: 768px) {
    #productsTableBody tr[id^="row-"] {
        display: grid;
        grid-template-columns: 1fr 1fr auto;
        grid-template-areas: 
            "code code dropdown"
            "model model dropdown"
            "measures stock dropdown";
        background: white;
        border: 1px solid var(--border-color);
        border-radius: 0.75rem;
        margin-bottom: 1rem;
        padding: 1rem;
        gap: 0.5rem;
        box-shadow: 0 1px 3px rgba(0,0,0,0.05);
        position: relative;
    }

    #productsTableBody tr[id^="row-"] > td {
        display: block;
        border: none;
        padding: 0;
        height: auto;
    }

    #productsTableBody .dropdown-cell {
        grid-area: dropdown;
        display: flex !important;
        align-items: center;
        justify-content: center;
        padding-left: 1rem !important;
        border-left: 1px solid var(--border-color) !important;
    }

    #productsTableBody .cell-code {
        grid-area: code;
        font-weight: 700;
        color: var(--primary-color);
        font-size: 1rem;
    }

    #productsTableBody .cell-model {
        grid-area: model;
        font-weight: 500;
        color: var(--text-color);
    }

    #productsTableBody .cell-measurements {
        grid-area: measures;
        font-size: 0.85rem;
        color: var(--text-muted);
    }

    #productsTableBody .cell-stock {
        grid-area: stock;
        text-align: right;
        font-weight: 600;
    }
    
    #productsTableBody .cell-stock::before {
        content: "Stock: ";
        font-weight: 400;
        color: var(--text-muted);
        font-size: 0.75rem;
    }

    /* Hide detailed info on collapsed card */
    #productsTableBody .cell-cost,
    #productsTableBody .cell-sale,
    #productsTableBody .cell-actions {
        display: none !important;
    }

    /* Show detailed info when expanded */
    #productsTableBody tr.expanded .cell-cost,
    #productsTableBody tr.expanded .cell-sale,
    #productsTableBody tr.expanded .cell-actions {
        display: flex !important;
        grid-column: 1 / span 3;
        padding-top: 0.75rem;
        border-top: 1px dashed var(--border-color);
        justify-content: space-between;
        align-items: center;
    }

    #productsTableBody tr.expanded .cell-cost::before { content: "Costo: "; color: var(--text-muted); font-weight: 400; margin-right: 5px; }
    #productsTableBody tr.expanded .cell-sale::before { content: "Venta: "; color: var(--text-muted); font-weight: 400; margin-right: 5px; }

    #productsTableBody tr.expanded .cell-actions {
        justify-content: center;
    }

    #productsTableBody .actionBtns {
        width: 100%;
        gap: 0.5rem;
    }
    
    #productsTableBody .action-badge {
        flex: 1;
        justify-content: center;
        padding: 0.6rem;
    }

    /* Adjust movements table for mobile inside the card */
    .details-row td {
        padding: 0 !important;
    }
    
    .details-container {
        margin: -0.5rem 0.5rem 1rem 0.5rem;
        background: #f8fafc;
        border: 1px solid var(--border-color);
        border-top: none;
        border-radius: 0 0 0.75rem 0.75rem;
    }

    /* Hide table header in mobile */
    .table-container thead {
        display: none;
    }
    
    .table-container table {
        border: none;
        background: transparent;
    }
}

/* Fix for Desktop Table Alignment & Re-enable Mobile Card Measures */
@media (max-width: 768px) {
    /* Hide individual measurement cells in mobile */
    #productsTableBody .cell-width,
    #productsTableBody .cell-profile,
    #productsTableBody .cell-diameter {
        display: none !important;
    }

    /* Show the grouped measures helper in mobile */
    #productsTableBody .cell-measurements-mobile {
        display: block !important;
        grid-area: measures;
        font-size: 0.85rem;
        color: var(--text-muted);
    }
}

/* Ensure helper is truly hidden on desktop */
@media (min-width: 769px) {
    .cell-measurements-mobile {
        display: none !important;
    }
}

/* Remove table container border on mobile */
@media (max-width: 768px) {
    .table-container {
        border: none !important;
        background: transparent !important;
        box-shadow: none !important;
    }
}

/* Movements Button Mobile Logic */
@media (min-width: 769px) {
    .movements-btn-mobile {
        display: none !important;
    }
}

@media (max-width: 768px) {
    #productsTableBody .actionBtns {
        flex-wrap: wrap;
    }
    
    #productsTableBody .movements-btn-mobile {
        display: flex !important;
        width: 100%;
        justify-content: center;
    }
}
