/* Arquivo: style.css */
:root {
    --primary: #2563eb;
    --primary-hover: #1d4ed8;
    --secondary: #64748b;
    --dark: #0f172a;
    --light: #f8fafc;
    --white: #ffffff;
    --border: #e2e8f0;
    --success: #10b981;
    --danger: #ef4444;
    --shadow: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
    --font-sans: 'Inter', system-ui, -apple-system, sans-serif;
}

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

body {
    font-family: var(--font-sans);
    background-color: var(--light);
    color: var(--dark);
    line-height: 1.5;
}

/* Utilities */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 1rem;
}

.hidden {
    display: none !important;
}

.text-center { text-align: center; }
.text-right { text-align: right; }
.font-bold { font-weight: bold; }
.text-primary { color: var(--primary); }
.text-success { color: var(--success); }
.clickable { cursor: pointer; }

.btn {
    display: inline-block;
    padding: 0.5rem 1rem;
    border-radius: 0.375rem;
    border: none;
    cursor: pointer;
    font-weight: 500;
    transition: background-color 0.2s, transform 0.1s;
    text-align: center;
}

.btn:active {
    transform: scale(0.98);
}

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

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

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

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

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

.input-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
}

.input-group input, .input-group textarea, .input-group select {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid var(--border);
    border-radius: 0.375rem;
    outline: none;
    font-family: inherit;
    transition: border-color 0.2s;
    background-color: var(--white);
}

.input-group input:focus, .input-group textarea:focus, .input-group select:focus {
    border-color: var(--primary);
}

/* Layout */
header {
    background-color: var(--white);
    box-shadow: var(--shadow);
    position: sticky;
    top: 0;
    z-index: 10;
}

.header-inner {
    display: flex;
    justify-content: space-between;
    align-items: center;
    height: 4rem;
}

.brand {
    font-size: 1.25rem;
    font-weight: bold;
    color: var(--primary);
    text-decoration: none;
}

.nav-links {
    display: flex;
    gap: 1.5rem;
    align-items: center;
}

.nav-links a {
    color: var(--dark);
    text-decoration: none;
    font-weight: 500;
    cursor: pointer;
    transition: color 0.2s;
}

.nav-links a:hover {
    color: var(--primary);
}

.cart-badge {
    background-color: var(--danger);
    color: var(--white);
    border-radius: 9999px;
    padding: 0.125rem 0.375rem;
    font-size: 0.75rem;
    margin-left: 0.25rem;
}

main {
    padding: 2rem 0;
}

/* Login Screen */
.login-container {
    max-width: 400px;
    margin: 4rem auto;
    background: var(--white);
    padding: 2rem;
    border-radius: 0.5rem;
    box-shadow: var(--shadow);
}

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

.error-msg {
    color: var(--danger);
    background: #fee2e2;
    padding: 0.75rem;
    border-radius: 0.25rem;
    margin-bottom: 1rem;
    font-size: 0.875rem;
}

/* Products Grid */
.search-bar {
    display: flex;
    gap: 0.75rem;
    margin-bottom: 2rem;
    align-items: stretch;
    flex-wrap: wrap;
}

.search-bar select {
    padding: 0.75rem 1rem;
    border: 1px solid var(--border);
    border-radius: 0.375rem;
    font-size: 1rem;
    background-color: var(--white);
    outline: none;
    min-width: 180px;
}

.search-bar input {
    flex: 1;
    min-width: 180px;
    padding: 0.75rem 1rem;
    border: 1px solid var(--border);
    border-radius: 0.375rem;
    font-size: 1rem;
}

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

.product-card {
    background: var(--white);
    border-radius: 0.5rem;
    overflow: hidden;
    box-shadow: var(--shadow);
    transition: transform 0.2s, box-shadow 0.2s;
    display: flex;
    flex-direction: column;
}

.product-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 10px 15px -3px rgb(0 0 0 / 0.1);
}

.product-image {
    width: 100%;
    height: 200px;
    object-fit: cover;
}

.product-image-placeholder {
    width: 100%;
    height: 200px;
    background-color: #f1f5f9;
    color: #94a3b8;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    font-size: 0.875rem;
    font-weight: 500;
    gap: 0.5rem;
    border-bottom: 1px solid var(--border);
}

.product-image-placeholder svg {
    color: #cbd5e1;
}

.modal-content .product-image-placeholder {
    border: 1px solid var(--border);
    border-radius: 0.5rem;
    margin-bottom: 1rem;
    height: 250px;
}

.product-info {
    padding: 1.5rem;
    flex: 1;
    display: flex;
    flex-direction: column;
}

.product-sku {
    font-size: 0.75rem;
    color: var(--secondary);
    margin-bottom: 0.25rem;
}

.product-alt-sku {
    font-size: 0.75rem;
    color: var(--secondary);
    margin-bottom: 0.5rem;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.35rem;
    line-height: 1.3;
}

.alt-label {
    font-weight: 500;
    color: #64748b;
}

.alt-badge {
    display: inline-block;
    background-color: #f1f5f9;
    color: #1e293b;
    border: 1px solid var(--border);
    padding: 0.1rem 0.45rem;
    border-radius: 0.25rem;
    font-size: 0.72rem;
    font-weight: 600;
    letter-spacing: 0.02em;
}

.product-title {
    font-size: 1.125rem;
    font-weight: bold;
    margin-bottom: 0.5rem;
}

.product-desc {
    font-size: 0.875rem;
    color: var(--secondary);
    margin-bottom: 1rem;
    flex: 1;
}

.product-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: auto;
}

.product-price {
    font-size: 1.25rem;
    font-weight: bold;
    color: var(--primary);
}

/* Cart & Table Styles */
.table-container {
    background: var(--white);
    border-radius: 0.5rem;
    box-shadow: var(--shadow);
    overflow-x: auto;
}

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

th, td {
    padding: 1rem;
    text-align: left;
    border-bottom: 1px solid var(--border);
}

th {
    background-color: #f1f5f9;
    font-weight: 600;
    color: var(--secondary);
}

.cart-summary {
    margin-top: 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--white);
    padding: 1.5rem;
    border-radius: 0.5rem;
    box-shadow: var(--shadow);
}

.qty-input {
    width: 60px;
    padding: 0.25rem;
    text-align: center;
    border: 1px solid var(--border);
    border-radius: 0.25rem;
}

/* Bloqueio de rolagem do fundo com modal aberto */
body.modal-open {
    overflow: hidden !important;
}

/* Modal / Details */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 1rem;
    backdrop-filter: blur(2px);
    overflow: hidden;
}

.modal-content {
    background: var(--white);
    padding: 1.5rem;
    border-radius: 0.75rem;
    max-width: 580px;
    width: 100%;
    max-height: calc(100vh - 2rem);
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.35);
    position: relative;
    display: flex;
    flex-direction: column;
    box-sizing: border-box;
    animation: modalFadeIn 0.2s ease-out;
}

@keyframes modalFadeIn {
    from {
        opacity: 0;
        transform: scale(0.96);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

.modal-close {
    position: absolute;
    top: 1rem;
    right: 1rem;
    background: #f1f5f9;
    border: none;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    font-size: 1.25rem;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: var(--secondary);
    transition: background 0.2s, color 0.2s;
    z-index: 10;
}

.modal-close:hover {
    background: #e2e8f0;
    color: var(--dark);
}

#modal-body {
    display: flex;
    flex-direction: column;
    min-height: 0;
    flex: 1 1 auto;
    overflow: hidden;
}

.modal-header {
    padding-right: 2.25rem;
    margin-bottom: 0.75rem;
    flex-shrink: 0;
}

.modal-header h2 {
    font-size: 1.25rem;
    line-height: 1.3;
    margin-bottom: 0.25rem;
    word-break: break-word;
}

.modal-scrollable {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    overscroll-behavior: contain;
    padding-right: 0.5rem;
    margin-bottom: 0.5rem;
}

/* Scrollbar personalizada para a área interna */
.modal-scrollable::-webkit-scrollbar {
    width: 6px;
}
.modal-scrollable::-webkit-scrollbar-track {
    background: #f1f5f9;
    border-radius: 4px;
}
.modal-scrollable::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 4px;
}
.modal-scrollable::-webkit-scrollbar-thumb:hover {
    background: #94a3b8;
}

.product-details-desc {
    font-size: 0.95rem;
    line-height: 1.6;
    color: #334155;
    word-break: break-word;
    margin-top: 0.5rem;
}

.modal-footer {
    flex-shrink: 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-top: 1rem;
    border-top: 1px solid var(--border);
    background: var(--white);
}

/* Order History */
.order-status {
    padding: 0.25rem 0.5rem;
    border-radius: 9999px;
    font-size: 0.75rem;
    font-weight: 500;
    background: #e0f2fe;
    color: #0284c7;
}

/* Loading */
.loader {
    border: 4px solid #f3f3f3;
    border-top: 4px solid var(--primary);
    border-radius: 50%;
    width: 30px;
    height: 30px;
    animation: spin 1s linear infinite;
    margin: 2rem auto;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.price-col {
    display: none !important;
}

.pagination-container {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 1.5rem;
    margin-top: 3rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--border);
}

.pagination-container span {
    font-weight: 600;
    color: var(--secondary);
    font-size: 0.95rem;
}

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