/* Reset e Estilos Globais */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    color: #333;
    line-height: 1.6;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 20px;
}

/* Header */
header {
    background: rgba(255, 255, 255, 0.95);
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    padding: 20px 0;
    position: sticky;
    top: 0;
    z-index: 100;
}

header .container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
}

header h1 {
    color: #667eea;
    font-size: 1.8rem;
    display: flex;
    align-items: center;
    gap: 10px;
}

.user-controls {
    display: flex;
    gap: 10px;
}

#modeSwitch {
    display: flex;
    gap: 10px;
}

.mode-btn {
    padding: 10px 20px;
    border: 2px solid #667eea;
    background: white;
    color: #667eea;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 600;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 8px;
}

.mode-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(102, 126, 234, 0.3);
}

.mode-btn.active {
    background: #667eea;
    color: white;
}

/* Main Content */
main {
    padding: 30px 0;
}

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

.modal.active {
    display: flex;
    justify-content: center;
    align-items: center;
}

.modal-content {
    background: white;
    padding: 30px;
    border-radius: 15px;
    max-width: 500px;
    width: 90%;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
    animation: modalSlideIn 0.3s ease;
}

@keyframes modalSlideIn {
    from {
        transform: translateY(-50px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.modal-content h2 {
    color: #667eea;
    margin-bottom: 20px;
}

.modal-content input {
    width: 100%;
    padding: 12px;
    margin: 15px 0;
    border: 2px solid #ddd;
    border-radius: 8px;
    font-size: 1rem;
}

.modal-content input:focus {
    outline: none;
    border-color: #667eea;
}

.modal-actions {
    display: flex;
    gap: 10px;
    margin-top: 20px;
}

.help-text {
    margin-top: 15px;
    font-size: 0.9rem;
    color: #666;
    font-style: italic;
}

/* Sections */
section {
    background: white;
    border-radius: 15px;
    padding: 25px;
    margin-bottom: 30px;
    box-shadow: 0 5px 20px rgba(0, 0, 0, 0.1);
}

section h2 {
    color: #667eea;
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 1.5rem;
}

/* Admin Section */
.admin-section {
    border: 3px solid #667eea;
    background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
}

/* Form Styles */
.form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 20px;
}

.form-simple {
    display: flex;
    flex-direction: column;
    gap: 20px;
    max-width: 900px;
}

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

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

.form-group-full {
    grid-column: 1 / -1;
}

.form-group label {
    font-weight: 600;
    margin-bottom: 8px;
    color: #555;
}

.form-group input,
.form-group select,
.form-group textarea {
    padding: 12px;
    border: 2px solid #ddd;
    border-radius: 8px;
    font-size: 1rem;
    transition: border-color 0.3s ease;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

.form-group textarea {
    resize: vertical;
    min-height: 80px;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: #667eea;
}

.form-actions {
    grid-column: 1 / -1;
    display: flex;
    gap: 10px;
    margin-top: 10px;
}

/* Buttons */
.btn {
    padding: 12px 24px;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.2);
}

.btn-primary {
    background: #667eea;
    color: white;
}

.btn-primary:hover {
    background: #5568d3;
}

.btn-success {
    background: #28a745;
    color: white;
}

.btn-success:hover {
    background: #218838;
}

.btn-secondary {
    background: #6c757d;
    color: white;
}

.btn-secondary:hover {
    background: #5a6268;
}

.btn-danger {
    background: #dc3545;
    color: white;
}

.btn-danger:hover {
    background: #c82333;
}

.btn-warning {
    background: #ffc107;
    color: #333;
}

.btn-warning:hover {
    background: #e0a800;
}

/* Filters */
.filters {
    display: flex;
    flex-wrap: wrap;
    gap: 20px;
    align-items: flex-end;
}

.filter-group {
    flex: 1;
    min-width: 200px;
    display: flex;
    flex-direction: column;
}

.filter-group label {
    font-weight: 600;
    margin-bottom: 8px;
    color: #555;
}

.filter-group input,
.filter-group select {
    padding: 12px;
    border: 2px solid #ddd;
    border-radius: 8px;
    font-size: 1rem;
}

/* Compras Table */
.table-wrapper {
    margin-top: 20px;
    overflow-x: auto;
    border-radius: 10px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.08);
    -webkit-overflow-scrolling: touch;
}

.compras-table {
    width: 100%;
    border-collapse: collapse;
    background: white;
    font-size: 1rem;
    min-width: 100%;
}

.compras-table thead {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    position: sticky;
    top: 0;
    z-index: 10;
}

.compras-table th {
    padding: 18px 15px;
    text-align: left;
    font-weight: 700;
    text-transform: uppercase;
    font-size: 0.9rem;
    letter-spacing: 0.5px;
    white-space: nowrap;
}

.compras-table th:first-child {
    width: 130px;
}

.compras-table th:nth-child(2) {
    width: auto;
}

.compras-table th:nth-child(3) {
    width: 140px;
}

.compras-table tbody tr {
    border-bottom: 1px solid #e0e0e0;
    transition: all 0.2s ease;
}

.compras-table tbody tr:hover {
    background: #f8f9fa;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.compras-table tbody tr:last-child {
    border-bottom: none;
}

.compras-table td {
    padding: 18px 15px;
    vertical-align: middle;
}

.compra-status {
    padding: 8px 14px;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    display: inline-block;
    white-space: nowrap;
}

/* Status Colors with Pulsing Animation */
.status-pendente {
    background: #fff3cd;
    color: #856404;
    border: 2px solid #ffc107;
    animation: pulse-pendente 2s infinite;
}

@keyframes pulse-pendente {
    0%, 100% {
        box-shadow: 0 0 0 0 rgba(255, 193, 7, 0.7);
    }
    50% {
        box-shadow: 0 0 0 10px rgba(255, 193, 7, 0);
    }
}

.status-comprado {
    background: #d1ecf1;
    color: #0c5460;
    border: 2px solid #17a2b8;
    animation: pulse-comprado 2s infinite;
}

@keyframes pulse-comprado {
    0%, 100% {
        box-shadow: 0 0 0 0 rgba(23, 162, 184, 0.7);
    }
    50% {
        box-shadow: 0 0 0 10px rgba(23, 162, 184, 0);
    }
}

.status-entregue {
    background: #d4edda;
    color: #155724;
    border: 2px solid #28a745;
    animation: pulse-entregue 2s infinite;
}

@keyframes pulse-entregue {
    0%, 100% {
        box-shadow: 0 0 0 0 rgba(40, 167, 69, 0.7);
    }
    50% {
        box-shadow: 0 0 0 10px rgba(40, 167, 69, 0);
    }
}

.compra-actions {
    display: flex;
    gap: 8px;
    justify-content: center;
}

.compra-actions button {
    padding: 8px 12px;
    font-size: 0.8rem;
    white-space: nowrap;
}

.compra-actions button i {
    font-size: 0.85rem;
}

.table-cell-pedido {
    font-size: 0.95rem;
    color: #333;
    line-height: 1.6;
    max-width: 600px;
}

.pedido-description {
    white-space: pre-wrap;
    word-wrap: break-word;
    margin-bottom: 8px;
}

.pedido-solicitante {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.85rem;
    color: #667eea;
    font-weight: 600;
    margin-top: 8px;
}

.pedido-solicitante i {
    font-size: 0.8rem;
}

.table-cell-previsao {
    font-size: 0.95rem;
    color: #555;
    white-space: nowrap;
}

.loading-cell {
    text-align: center;
    padding: 40px !important;
    font-size: 1.1rem;
    color: #667eea;
}

.loading-cell i {
    font-size: 1.5rem;
    margin-right: 10px;
}

.empty-row td {
    text-align: center;
    padding: 60px 20px !important;
    color: #999;
}

.empty-row i {
    font-size: 3rem;
    display: block;
    margin-bottom: 15px;
    color: #ddd;
}

.empty-row h3 {
    font-size: 1.3rem;
    color: #666;
    margin-bottom: 10px;
}

.empty-row p {
    color: #999;
}

/* Mobile Optimization */
@media (max-width: 480px) {
    .compras-table th,
    .compras-table td {
        padding: 12px 8px;
    }

    .compras-table th:first-child {
        width: 95px;
    }

    .compras-table th:nth-child(3) {
        width: 90px;
    }

    .compra-status {
        padding: 6px 10px;
        font-size: 0.7rem;
    }

    .table-cell-pedido {
        font-size: 0.85rem;
        max-width: none;
    }

    .table-cell-previsao {
        font-size: 0.8rem;
    }

    .compra-actions {
        flex-direction: row;
        gap: 5px;
    }

    .compra-actions button {
        padding: 8px 10px;
        font-size: 0.75rem;
    }

    .compra-actions button span {
        display: none;
    }
}

/* Relatórios */
.relatorios-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 20px;
    margin-top: 20px;
}

.relatorio-card {
    background: white;
    border-radius: 15px;
    padding: 25px;
    display: flex;
    align-items: center;
    gap: 20px;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
    transition: all 0.3s ease;
    border-left: 5px solid;
}

.relatorio-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.15);
}

.relatorio-card.pendente {
    border-left-color: #ffc107;
    background: linear-gradient(135deg, #fff9e6 0%, #ffffff 100%);
}

.relatorio-card.comprado {
    border-left-color: #17a2b8;
    background: linear-gradient(135deg, #e6f7f9 0%, #ffffff 100%);
}

.relatorio-card.entregue {
    border-left-color: #28a745;
    background: linear-gradient(135deg, #e6f7ed 0%, #ffffff 100%);
}

.relatorio-icon {
    font-size: 3rem;
}

.relatorio-card.pendente .relatorio-icon {
    color: #ffc107;
}

.relatorio-card.comprado .relatorio-icon {
    color: #17a2b8;
}

.relatorio-card.entregue .relatorio-icon {
    color: #28a745;
}

.relatorio-info {
    flex: 1;
}

.relatorio-info h3 {
    font-size: 1.2rem;
    color: #555;
    margin-bottom: 10px;
}

.relatorio-count {
    font-size: 2.5rem;
    font-weight: 700;
    color: #333;
    margin-bottom: 10px;
}

.btn-relatorio {
    padding: 8px 16px;
    background: #667eea;
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 600;
    transition: all 0.3s ease;
}

.btn-relatorio:hover {
    background: #5568d3;
    transform: scale(1.05);
}

/* Modal de Relatório */
.relatorio-modal-content {
    max-width: 900px;
    max-height: 80vh;
    overflow-y: auto;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding-bottom: 15px;
    border-bottom: 2px solid #e0e0e0;
}

.modal-header h2 {
    margin: 0;
}

.close-modal {
    background: #dc3545;
    color: white;
    border: none;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    font-size: 1.5rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
}

.close-modal:hover {
    background: #c82333;
    transform: rotate(90deg);
}

.relatorio-content {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.relatorio-item {
    padding: 15px;
    background: #f8f9fa;
    border-radius: 8px;
    border-left: 4px solid #667eea;
}

.relatorio-item h4 {
    color: #667eea;
    margin-bottom: 10px;
}

.relatorio-item-details {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 10px;
}

.relatorio-item-detail {
    display: flex;
    align-items: center;
    gap: 8px;
}

.relatorio-item-detail i {
    color: #667eea;
}

.relatorio-item-detail strong {
    color: #555;
}

/* Loading */
.loading {
    text-align: center;
    padding: 40px;
    font-size: 1.2rem;
    color: #667eea;
}

.loading i {
    font-size: 2rem;
    margin-bottom: 10px;
}

.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: #999;
}

.empty-state i {
    font-size: 4rem;
    margin-bottom: 20px;
    color: #ddd;
}

.empty-state h3 {
    font-size: 1.5rem;
    color: #666;
    margin-bottom: 10px;
}

.empty-state p {
    color: #999;
}

/* Footer */
footer {
    background: rgba(255, 255, 255, 0.95);
    padding: 20px 0;
    margin-top: 40px;
    text-align: center;
    color: #666;
}

/* Responsive */
@media (max-width: 768px) {
    header .container {
        flex-direction: column;
        gap: 15px;
    }

    header h1 {
        font-size: 1.4rem;
    }

    .table-wrapper {
        border-radius: 8px;
        margin: 15px -10px;
    }

    .compras-table {
        font-size: 0.9rem;
    }

    .compras-table th,
    .compras-table td {
        padding: 12px 8px;
    }

    .compras-table th {
        font-size: 0.8rem;
        padding: 15px 8px;
    }

    .pedido-title {
        font-size: 0.95rem;
    }

    .pedido-details {
        font-size: 0.85rem;
    }

    .form-grid {
        grid-template-columns: 1fr;
    }

    .filters {
        flex-direction: column;
        align-items: stretch;
    }

    .filter-group {
        width: 100%;
    }

    .relatorios-grid {
        grid-template-columns: 1fr;
    }

    section {
        padding: 20px 15px;
        margin-bottom: 20px;
    }

    .btn {
        width: 100%;
        justify-content: center;
    }

    #clearFilters {
        width: 100%;
        margin-top: 10px;
    }
}
