/* RESET E BASE */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background-color: #f8f9fa;
    color: #2c3e50;
    line-height: 1.6;
}

/* CONTAINER PRINCIPAL */
.document-container {
    max-width: 1200px;
    margin: 0 auto;
    background: white;
    min-height: 100vh;
    box-shadow: 0 0 20px rgba(0, 0, 0, 0.1);
}

/* CABEÇALHO DO DOCUMENTO */
.document-header {
    background: linear-gradient(135deg, #34495e 0%, #2c3e50 100%);
    color: white;
    padding: 2rem;
    border-bottom: 4px solid #3498db;
}

.header-content h1 {
    font-size: 2.5rem;
    font-weight: 300;
    letter-spacing: 2px;
    margin-bottom: 1.5rem;
    text-align: center;
}

.header-details {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 1rem;
    max-width: 800px;
    margin: 0 auto;
}

.detail-row {
    display: flex;
    justify-content: space-between;
    padding: 0.5rem 1rem;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 5px;
}

.detail-row .label {
    font-weight: 600;
    opacity: 0.9;
}

.detail-row .value {
    font-weight: 300;
}

/* RESUMO FINANCEIRO */
.financial-summary {
    padding: 2rem;
    background: #ecf0f1;
    border-bottom: 1px solid #bdc3c7;
}

.summary-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 1.5rem;
}

.summary-card {
    background: white;
    padding: 1.5rem;
    border-radius: 8px;
    text-align: center;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    border-top: 4px solid #3498db;
}

.summary-card.total {
    border-top-color: #2c3e50;
}

.summary-card.purchased {
    border-top-color: #27ae60;
}

.summary-card.remaining {
    border-top-color: #e74c3c;
}

.summary-card h3 {
    font-size: 0.9rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: #7f8c8d;
    margin-bottom: 0.5rem;
}

.summary-card .amount {
    font-size: 1.8rem;
    font-weight: 600;
    color: #2c3e50;
}

/* CONTROLES */
.controls {
    padding: 1.5rem 2rem;
    background: white;
    border-bottom: 1px solid #ecf0f1;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 1.5rem;
}

.filter-group {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.filter-group label {
    font-weight: 600;
    color: #7f8c8d;
    font-size: 0.9rem;
}

.filter-group select {
    padding: 0.5rem;
    border: 1px solid #bdc3c7;
    border-radius: 4px;
    background: white;
    color: #2c3e50;
    font-size: 0.9rem;
}

.print-btn {
    background: #3498db;
    color: white;
    border: none;
    padding: 0.75rem 1.5rem;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 600;
    transition: background 0.3s;
    margin-left: auto;
}

.print-btn:hover {
    background: #2980b9;
}

/* SEÇÃO DE ITENS */
.items-section {
    padding: 2rem;
}

.category-group {
    margin-bottom: 3rem;
}

.category-header {
    background: #34495e;
    color: white;
    padding: 1rem 1.5rem;
    border-radius: 6px 6px 0 0;
    font-size: 1.1rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.items-table {
    background: white;
    border: 1px solid #ecf0f1;
    border-radius: 0 0 6px 6px;
    overflow: hidden;
}

.table-header {
    background: #f8f9fa;
    padding: 1rem;
    border-bottom: 2px solid #ecf0f1;
    display: grid;
    grid-template-columns: 80px 1fr 2fr 80px 120px 120px 120px 60px;
    gap: 1rem;
    align-items: center;
    font-weight: 600;
    color: #7f8c8d;
    font-size: 0.85rem;
    text-transform: uppercase;
}

.item-row {
    padding: 1.5rem 1rem;
    border-bottom: 1px solid #ecf0f1;
    display: grid;
    grid-template-columns: 80px 1fr 2fr 80px 120px 120px 120px 60px;
    gap: 1rem;
    align-items: center;
    transition: background 0.2s;
}

.item-row:hover {
    background: #f8f9fa;
}

.item-row.purchased {
    background: rgba(39, 174, 96, 0.05);
    opacity: 0.8;
}

.item-image {
    width: 60px;
    height: 60px;
    object-fit: cover;
    border-radius: 4px;
    border: 1px solid #ecf0f1;
}

.item-name {
    font-weight: 600;
    color: #2c3e50;
    font-size: 0.95rem;
}

.item-spec {
    color: #7f8c8d;
    font-size: 0.85rem;
    line-height: 1.4;
}

.item-quantity {
    text-align: center;
    font-weight: 600;
    color: #2c3e50;
}

.item-price {
    text-align: right;
    font-weight: 600;
    color: #2c3e50;
}

.item-total {
    text-align: right;
    font-weight: 700;
    color: #2c3e50;
    font-size: 1.1rem;
}

.item-link {
    text-align: center;
}

.item-link a {
    color: #3498db;
    text-decoration: none;
    font-size: 0.8rem;
    padding: 0.25rem 0.5rem;
    border: 1px solid #3498db;
    border-radius: 3px;
    transition: all 0.2s;
}

.item-link a:hover {
    background: #3498db;
    color: white;
}

.item-checkbox {
    text-align: center;
}

.item-checkbox input[type="checkbox"] {
    width: 18px;
    height: 18px;
    cursor: pointer;
}

/* RESUMO POR CATEGORIA */
.category-summary {
    padding: 2rem;
    background: #f8f9fa;
    border-top: 1px solid #ecf0f1;
}

.category-summary h2 {
    text-align: center;
    margin-bottom: 2rem;
    color: #2c3e50;
    font-weight: 300;
    font-size: 1.8rem;
}

.category-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
}

.category-total {
    background: white;
    padding: 1.5rem;
    border-radius: 6px;
    text-align: center;
    border-left: 4px solid #3498db;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.category-total h4 {
    color: #7f8c8d;
    margin-bottom: 0.5rem;
    font-size: 0.9rem;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.category-total .total-amount {
    font-size: 1.4rem;
    font-weight: 600;
    color: #2c3e50;
}

/* LOADING E ESTADOS VAZIOS */
.loading {
    text-align: center;
    padding: 3rem;
    color: #7f8c8d;
}

.empty-state {
    text-align: center;
    padding: 3rem;
    color: #7f8c8d;
}

/* RESPONSIVIDADE */
@media (max-width: 1024px) {
    .table-header,
    .item-row {
        grid-template-columns: 60px 1fr 80px 100px 100px 50px;
    }
    
    .item-spec {
        display: none;
    }
    
    .item-link {
        display: none;
    }
}

@media (max-width: 768px) {
    .document-container {
        margin: 0;
        box-shadow: none;
    }
    
    .header-content h1 {
        font-size: 2rem;
    }
    
    .controls {
        flex-direction: column;
        align-items: stretch;
    }
    
    .print-btn {
        margin-left: 0;
    }
    
    .table-header,
    .item-row {
        grid-template-columns: 1fr 80px 100px 50px;
        font-size: 0.8rem;
    }
    
    .item-image {
        display: none;
    }
    
    .item-name {
        grid-column: 1;
    }
}

/* ESTILOS DE IMPRESSÃO */
@media print {
    body {
        background: white;
    }
    
    .document-container {
        box-shadow: none;
        max-width: none;
    }
    
    .controls {
        display: none;
    }
    
    .financial-summary {
        background: white;
        border: 1px solid #ddd;
    }
    
    .summary-card {
        box-shadow: none;
        border: 1px solid #ddd;
    }
    
    .item-row:hover {
        background: transparent;
    }
    
    .item-link a {
        color: #2c3e50 !important;
        border: none;
        text-decoration: underline;
    }
}

/* ANIMAÇÕES */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

.item-row {
    animation: fadeIn 0.3s ease-out;
}

.category-group {
    animation: fadeIn 0.5s ease-out;
}