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

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

body {
    font-family: 'Inter', sans-serif;
    background: #0F172A;
    color: #E2E8F0;
    min-height: 100vh;
}

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

/* ============================================
   HEADER
============================================ */
.admin-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 32px;
    padding-bottom: 24px;
    border-bottom: 1px solid #1E293B;
    flex-wrap: wrap;
    gap: 16px;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 16px;
}

.header-left h1 {
    font-size: clamp(20px, 4vw, 26px);
    font-weight: 700;
    color: #F8FAFC;
    display: flex;
    align-items: center;
    gap: 12px;
}

.header-left h1 i { 
    color: #8B5CF6; 
}

.btn-back {
    width: 40px;
    height: 40px;
    border-radius: 8px;
    background: #1E293B;
    color: #CBD5E1;
    display: flex;
    align-items: center;
    justify-content: center;
    text-decoration: none;
    transition: all 0.2s;
}

.btn-back:hover { 
    background: #334155; 
    color: #F1F5F9; 
}

.header-actions {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
}

.btn-primary {
    padding: 10px 18px;
    border-radius: 8px;
    font-weight: 500;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    transition: all 0.2s;
    border: none;
    cursor: pointer;
    font-size: 14px;
    background: #8B5CF6;
    color: white;
}

.btn-primary:hover { 
    background: #7C3AED; 
    transform: translateY(-1px);
}

.btn-primary:disabled {
    background: #475569;
    cursor: not-allowed;
    transform: none;
}

.btn-secondary {
    padding: 10px 18px;
    border-radius: 8px;
    font-weight: 500;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    transition: all 0.2s;
    border: 1px solid #334155;
    cursor: pointer;
    font-size: 14px;
    background: #1E293B;
    color: #F8FAFC;
}

.btn-secondary:hover { 
    background: #334155; 
}

.filter-select {
    padding: 10px 16px;
    background: #1E293B;
    border: 1px solid #334155;
    border-radius: 8px;
    color: #F8FAFC;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s;
}

.filter-select:hover {
    border-color: #475569;
}

.filter-select:focus { 
    outline: none; 
    border-color: #8B5CF6; 
}

/* ============================================
   TABS
============================================ */
.tabs-container {
    display: flex;
    gap: 4px;
    background: #1E293B;
    padding: 4px;
    border-radius: 10px;
    margin-bottom: 24px;
    border: 1px solid #334155;
    overflow-x: auto;
}

.tab-btn {
    padding: 10px 20px;
    border-radius: 8px;
    border: none;
    background: transparent;
    color: #94A3B8;
    font-weight: 500;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    gap: 8px;
    white-space: nowrap;
    flex: 1;
    justify-content: center;
}

.tab-btn:hover {
    color: #F8FAFC;
    background: #334155;
}

.tab-btn.ativo {
    background: #8B5CF6;
    color: white;
    box-shadow: 0 2px 8px rgba(139, 92, 246, 0.3);
}

.tab-btn i {
    font-size: 14px;
}

/* ============================================
   STATS GRID (CARDS PRINCIPAIS)
============================================ */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 20px;
    margin-bottom: 24px;
}

.stat-card {
    background: #1E293B;
    border: 1px solid #334155;
    border-radius: 12px;
    padding: 20px;
    display: flex;
    gap: 16px;
    transition: all 0.2s;
}

.stat-card:hover {
    border-color: #475569;
    transform: translateY(-2px);
}

.stat-icon {
    width: 56px;
    height: 56px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    flex-shrink: 0;
}

.stat-info {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.stat-label {
    font-size: 13px;
    color: #94A3B8;
    font-weight: 500;
}

.stat-value {
    font-size: 24px;
    font-weight: 700;
    color: #F8FAFC;
}

.stat-change {
    font-size: 12px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 4px;
}

.stat-change.positive { 
    color: #10B981; 
}

.stat-change.negative { 
    color: #EF4444; 
}

.stat-change.neutral {
    color: #94A3B8;
}

/* ============================================
   STATS SECUNDÁRIAS (ORÇAMENTOS vs PRODUTOS)
============================================ */
.stats-secundarias {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 20px;
    margin-bottom: 24px;
}

.stat-mini {
    background: #1E293B;
    border: 1px solid #334155;
    border-radius: 12px;
    padding: 20px;
    transition: all 0.2s;
}

.stat-mini:hover {
    border-color: #475569;
    transform: translateY(-2px);
}

.stat-mini-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 12px;
    font-size: 14px;
    color: #94A3B8;
    font-weight: 500;
}

.stat-mini-header i {
    font-size: 18px;
}

.stat-mini-body {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    margin-bottom: 12px;
}

.stat-mini-valor {
    font-size: 22px;
    font-weight: 700;
    color: #F8FAFC;
}

.stat-mini-qtd {
    font-size: 13px;
    color: #94A3B8;
    font-weight: 500;
}

.stat-mini-bar {
    height: 6px;
    background: #0F172A;
    border-radius: 3px;
    overflow: hidden;
}

.bar-fill {
    height: 100%;
    border-radius: 3px;
    transition: width 0.5s ease;
}

/* ============================================
   CHARTS
============================================ */
.charts-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(400px, 1fr));
    gap: 20px;
    margin-bottom: 24px;
}

.chart-card {
    background: #1E293B;
    border: 1px solid #334155;
    border-radius: 12px;
    padding: 24px;
}

.chart-header { 
    margin-bottom: 20px; 
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.chart-header h3 { 
    font-size: 16px; 
    font-weight: 600; 
    color: #F8FAFC; 
    display: flex;
    align-items: center;
    gap: 8px;
}

.chart-header h3 i {
    color: #8B5CF6;
}

.chart-container {
    position: relative;
    height: 300px;
    width: 100%;
}

.chart-container-small {
    position: relative;
    height: 220px;
    width: 100%;
}

/* ============================================
   TOP GRID (TOP ITENS + FORMAS DE PAGAMENTO)
============================================ */
.top-grid {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 20px;
    margin-bottom: 24px;
}

/* ============================================
   TOP LIST (ITENS MAIS VENDIDOS)
============================================ */
.top-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
    max-height: 320px;
    overflow-y: auto;
    padding-right: 8px;
}

.top-list::-webkit-scrollbar {
    width: 6px;
}

.top-list::-webkit-scrollbar-track {
    background: #0F172A;
    border-radius: 3px;
}

.top-list::-webkit-scrollbar-thumb {
    background: #334155;
    border-radius: 3px;
}

.top-list::-webkit-scrollbar-thumb:hover {
    background: #475569;
}

.top-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    background: #0F172A;
    border-radius: 8px;
    border: 1px solid #334155;
    transition: all 0.2s;
}

.top-item:hover {
    border-color: #475569;
    background: #1E293B;
}

.top-posicao {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: #334155;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 14px;
    color: #F8FAFC;
    flex-shrink: 0;
}

.top-posicao.gold {
    background: linear-gradient(135deg, #F59E0B, #D97706);
    color: white;
    box-shadow: 0 2px 8px rgba(245, 158, 11, 0.3);
}

.top-posicao.silver {
    background: linear-gradient(135deg, #94A3B8, #64748B);
    color: white;
}

.top-posicao.bronze {
    background: linear-gradient(135deg, #D97706, #92400E);
    color: white;
}

.top-info {
    flex: 1;
    min-width: 0;
}

.top-nome {
    font-size: 14px;
    font-weight: 600;
    color: #F8FAFC;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-bottom: 2px;
}

.top-meta {
    font-size: 12px;
    color: #94A3B8;
    display: flex;
    gap: 8px;
    align-items: center;
}

.top-meta .tipo {
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
}

.tipo.orcamento {
    background: rgba(59, 130, 246, 0.2);
    color: #3B82F6;
}

.tipo.produto {
    background: rgba(139, 92, 246, 0.2);
    color: #8B5CF6;
}

.top-valor {
    font-size: 15px;
    font-weight: 700;
    color: #10B981;
    flex-shrink: 0;
}

/* ============================================
   TABLE
============================================ */
.table-card {
    background: #1E293B;
    border: 1px solid #334155;
    border-radius: 12px;
    overflow: hidden;
}

.table-header {
    padding: 20px 24px;
    border-bottom: 1px solid #334155;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 12px;
}

.table-header h3 { 
    font-size: 16px; 
    font-weight: 600; 
    color: #F8FAFC;
    display: flex;
    align-items: center;
    gap: 8px;
}

.table-header h3 i {
    color: #8B5CF6;
}

.table-count {
    font-size: 13px;
    color: #94A3B8;
    background: #0F172A;
    padding: 4px 12px;
    border-radius: 12px;
    font-weight: 500;
}

.table-wrapper { 
    overflow-x: auto; 
}

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

.data-table th {
    background: #0F172A;
    padding: 14px 16px;
    text-align: left;
    font-weight: 600;
    font-size: 12px;
    color: #94A3B8;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.data-table td {
    padding: 14px 16px;
    border-top: 1px solid #334155;
    font-size: 14px;
    color: #F8FAFC;
}

.data-table tr {
    transition: all 0.2s;
    cursor: pointer;
}

.data-table tr:hover { 
    background: #334155; 
}

.tipo-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
}

.tipo-badge.orcamento {
    background: rgba(59, 130, 246, 0.2);
    color: #3B82F6;
}

.tipo-badge.produto {
    background: rgba(139, 92, 246, 0.2);
    color: #8B5CF6;
}

.descricao-text {
    max-width: 250px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    color: #CBD5E1;
}

.valor-text {
    font-weight: 700;
    color: #10B981;
    font-size: 15px;
}

.data-text {
    color: #94A3B8;
    font-size: 13px;
}

.cliente-text {
    color: #F8FAFC;
    font-weight: 500;
}

.pagamento-text {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 8px;
    background: #0F172A;
    border-radius: 6px;
    font-size: 12px;
    color: #CBD5E1;
}

.pagamento-text i {
    color: #8B5CF6;
    font-size: 12px;
}

/* ============================================
   BADGES
============================================ */
.badge {
    padding: 4px 12px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 500;
    display: inline-block;
}

.badge.pago { 
    background: rgba(16, 185, 129, 0.2); 
    color: #10B981; 
}

.badge.pendente { 
    background: rgba(245, 158, 11, 0.2); 
    color: #F59E0B; 
}

.badge.cancelado { 
    background: rgba(239, 68, 68, 0.2); 
    color: #EF4444; 
}

/* ============================================
   LOADING STATE
============================================ */
.loading-state {
    text-align: center;
    padding: 40px 20px;
    color: #94A3B8;
}

.loading-state i {
    font-size: 32px;
    margin-bottom: 12px;
    color: #8B5CF6;
}

.loading-state p {
    font-size: 14px;
}

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

.empty-state i {
    font-size: 48px;
    margin-bottom: 16px;
    color: #475569;
}

.empty-state p {
    font-size: 14px;
    margin-bottom: 4px;
}

.empty-state small {
    font-size: 12px;
    color: #64748B;
}

/* ============================================
   MODAL
============================================ */
.modal {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.75);
    backdrop-filter: blur(4px);
    z-index: 1000;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.modal.active {
    display: flex;
    animation: fadeIn 0.2s;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.modal-overlay {
    position: absolute;
    inset: 0;
    cursor: pointer;
}

.modal-content {
    position: relative;
    background: #1E293B;
    border: 1px solid #334155;
    border-radius: 12px;
    width: 100%;
    max-width: 600px;
    max-height: 90vh;
    overflow-y: auto;
    z-index: 1001;
    animation: slideUp 0.3s;
}

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

.modal-header {
    padding: 20px 24px;
    border-bottom: 1px solid #334155;
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: sticky;
    top: 0;
    background: #1E293B;
    z-index: 10;
}

.modal-header h3 {
    font-size: 18px;
    color: #F8FAFC;
    display: flex;
    align-items: center;
    gap: 10px;
}

.modal-header h3 i {
    color: #8B5CF6;
}

.btn-close {
    background: transparent;
    border: none;
    color: #94A3B8;
    font-size: 18px;
    cursor: pointer;
    width: 36px;
    height: 36px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.btn-close:hover {
    background: #334155;
    color: #F8FAFC;
}

.modal-body {
    padding: 24px;
}

.modal-footer {
    padding: 16px 24px;
    border-top: 1px solid #334155;
    display: flex;
    gap: 12px;
    justify-content: flex-end;
    position: sticky;
    bottom: 0;
    background: #1E293B;
    z-index: 10;
}

/* Modal detalhes conteúdo */
.detalhe-section {
    margin-bottom: 20px;
    padding-bottom: 20px;
    border-bottom: 1px solid #334155;
}

.detalhe-section:last-child {
    border-bottom: none;
    margin-bottom: 0;
    padding-bottom: 0;
}

.detalhe-title {
    font-size: 13px;
    color: #94A3B8;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 8px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 6px;
}

.detalhe-title i {
    color: #8B5CF6;
    font-size: 12px;
}

.detalhe-valor {
    font-size: 15px;
    color: #F8FAFC;
    font-weight: 500;
}

.detalhe-valor.destaque {
    font-size: 24px;
    font-weight: 700;
    color: #10B981;
}

.itens-list-modal {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 8px;
}

.item-modal {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 12px;
    background: #0F172A;
    border-radius: 6px;
    border: 1px solid #334155;
}

.item-modal-info {
    flex: 1;
}

.item-modal-nome {
    font-size: 14px;
    color: #F8FAFC;
    font-weight: 500;
    margin-bottom: 2px;
}

.item-modal-qtd {
    font-size: 12px;
    color: #94A3B8;
}

.item-modal-valor {
    font-size: 14px;
    color: #10B981;
    font-weight: 600;
}

/* ============================================
   TOAST NOTIFICATION
============================================ */
.toast-notif {
    position: fixed;
    top: 24px;
    right: 24px;
    background: #1E293B;
    border: 1px solid #334155;
    border-radius: 12px;
    padding: 16px 20px;
    display: flex;
    align-items: center;
    gap: 12px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
    transform: translateX(400px);
    transition: transform 0.3s ease;
    z-index: 9999;
    max-width: 400px;
}

.toast-notif.show {
    transform: translateX(0);
}

.toast-success { border-color: #10B981; }
.toast-error { border-color: #EF4444; }
.toast-info { border-color: #3B82F6; }

.toast-notif i {
    font-size: 20px;
    flex-shrink: 0;
}

.toast-success i { color: #10B981; }
.toast-error i { color: #EF4444; }
.toast-info i { color: #3B82F6; }

.toast-notif span {
    color: #F8FAFC;
    font-size: 14px;
    font-weight: 500;
}

/* ============================================
   RESPONSIVO
============================================ */
@media (max-width: 768px) {
    .admin-container { 
        padding: 16px; 
    }
    
    .admin-header {
        flex-direction: column;
        align-items: stretch;
    }
    
    .header-actions {
        width: 100%;
        flex-direction: column;
    }
    
    .header-actions .filter-select,
    .header-actions .btn-primary {
        width: 100%;
        justify-content: center;
    }
    
    .tabs-container {
        overflow-x: auto;
    }
    
    .tab-btn {
        font-size: 13px;
        padding: 8px 12px;
    }
    
    .stats-grid { 
        grid-template-columns: 1fr; 
    }
    
    .stats-secundarias {
        grid-template-columns: 1fr;
    }
    
    .charts-grid { 
        grid-template-columns: 1fr; 
    }
    
    .top-grid {
        grid-template-columns: 1fr;
    }
    
    .data-table { 
        font-size: 13px; 
    }
    
    .hide-mobile { 
        display: none; 
    }
    
    .descricao-text {
        max-width: 150px;
    }
    
    .modal-content {
        max-height: 100vh;
        border-radius: 0;
    }
    
    .modal-footer {
        flex-direction: column;
    }
    
    .modal-footer .btn-secondary {
        width: 100%;
        justify-content: center;
    }
    
    .toast-notif {
        left: 16px;
        right: 16px;
        max-width: none;
    }
    
    .stat-card {
        padding: 16px;
    }
    
    .stat-icon {
        width: 48px;
        height: 48px;
        font-size: 20px;
    }
    
    .stat-value {
        font-size: 20px;
    }
    
    .table-header {
        padding: 16px;
    }
    
    .chart-container {
        height: 250px;
    }
}

@media (max-width: 480px) {
    .admin-container {
        padding: 12px;
    }
    
    .stat-card {
        padding: 14px;
    }
    
    .chart-card {
        padding: 16px;
    }
    
    .stat-mini {
        padding: 16px;
    }
    
    .stat-mini-valor {
        font-size: 18px;
    }
    
    .top-item {
        padding: 10px;
    }
    
    .top-nome {
        font-size: 13px;
    }
    
    .top-valor {
        font-size: 13px;
    }
}