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

body {
    font-family: 'Segoe UI', Arial, sans-serif;
    background: #f0f2f5;
    color: #333;
    min-height: 100vh;
}

/* ==========================================
   SCREENS
========================================== */
.screen {
    display: none;
    min-height: 100vh;
}

.screen.active {
    display: block;
}

/* ==========================================
   LOGIN - Fundo com gradiente
========================================== */
.login-container {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    padding: 20px;
}

.login-box {
    background: white;
    border-radius: 20px;
    padding: 40px;
    max-width: 420px;
    width: 100%;
    box-shadow: 0 20px 60px rgba(0,0,0,0.3);
}

.login-box .logo {
    text-align: center;
    margin-bottom: 30px;
}

.login-box .logo h1 {
    font-size: 32px;
    color: #333;
}

.login-box .logo p {
    color: #666;
    font-size: 14px;
}

.login-box .logo .version {
    display: inline-block;
    background: #e0e0e0;
    padding: 2px 12px;
    border-radius: 10px;
    font-size: 11px;
    color: #666;
    margin-top: 5px;
}

/* ==========================================
   CARDS
========================================== */
.card {
    background: white;
    border-radius: 12px;
    padding: 25px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.08);
}

.card h2 {
    font-size: 18px;
    margin-bottom: 20px;
    color: #333;
}

/* ==========================================
   FORMULÁRIOS
========================================== */
.form-group {
    margin-bottom: 15px;
}

.form-group label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: #555;
    margin-bottom: 5px;
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 10px 14px;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    font-size: 14px;
    transition: border-color 0.3s;
    background: #fafafa;
}

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

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

.form-row {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    margin: 10px 0;
    align-items: center;
}

.form-row input,
.form-row select {
    flex: 1;
    min-width: 120px;
    padding: 8px 12px;
    border: 2px solid #e0e0e0;
    border-radius: 6px;
    font-size: 13px;
}

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

/* ==========================================
   BOTÕES
========================================== */
button {
    padding: 10px 20px;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
}

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

.btn-primary:hover {
    background: #5a6fd6;
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.4);
}

.btn-success {
    background: #27ae60;
    color: white;
}

.btn-success:hover {
    background: #219a52;
}

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

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

.btn-warning {
    background: #f39c12;
    color: white;
}

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

.btn-block {
    display: block;
    width: 100%;
}

.btn-sm {
    padding: 5px 12px;
    font-size: 12px;
}

/* ==========================================
   LINKS
========================================== */
.link {
    color: #667eea;
    cursor: pointer;
    margin-top: 15px;
    display: inline-block;
    font-size: 14px;
}

.link:hover {
    text-decoration: underline;
}

/* ==========================================
   TOPBAR
========================================== */
.topbar {
    background: white;
    padding: 12px 30px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 2px 8px rgba(0,0,0,0.06);
    position: sticky;
    top: 0;
    z-index: 100;
}

.topbar-left {
    display: flex;
    align-items: center;
    gap: 15px;
}

.topbar-left h1 {
    font-size: 18px;
    color: #333;
}

.topbar-right {
    display: flex;
    align-items: center;
    gap: 15px;
}

.badge {
    padding: 4px 14px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
}

.badge-loja {
    background: #3498db;
    color: white;
}

.badge-transporte {
    background: #2ecc71;
    color: white;
}

.badge-admin {
    background: #e74c3c;
    color: white;
}

.status-active {
    background: #2ecc71;
    color: white;
}

.status-inactive {
    background: #e74c3c;
    color: white;
}

.status-pending {
    background: #f39c12;
    color: white;
}

.api-key {
    font-size: 12px;
    color: #999;
    background: #f5f5f5;
    padding: 4px 12px;
    border-radius: 10px;
}

/* ==========================================
   NAVEGAÇÃO
========================================== */
.nav-tabs {
    background: white;
    padding: 0 30px;
    display: flex;
    gap: 5px;
    border-bottom: 2px solid #e0e0e0;
    overflow-x: auto;
}

.tab {
    padding: 14px 24px;
    background: none;
    border: none;
    border-bottom: 3px solid transparent;
    font-size: 14px;
    font-weight: 600;
    color: #666;
    cursor: pointer;
    transition: all 0.3s;
    white-space: nowrap;
}

.tab:hover {
    color: #667eea;
    background: #f8f9fa;
}

.tab.active {
    color: #667eea;
    border-bottom-color: #667eea;
}

.sub-tabs {
    display: flex;
    gap: 3px;
    padding: 10px 0;
    border-bottom: 1px solid #e0e0e0;
    flex-wrap: wrap;
}

.sub-tab {
    padding: 8px 16px;
    background: none;
    border: none;
    border-radius: 6px;
    font-size: 13px;
    color: #666;
    cursor: pointer;
    transition: all 0.3s;
}

.sub-tab:hover {
    background: #f0f0f0;
}

.sub-tab.active {
    background: #667eea;
    color: white;
}

/* ==========================================
   CONTEÚDO
========================================== */
.tab-content {
    display: none;
    padding: 20px 30px;
    max-width: 1400px;
    margin: 0 auto;
}

.tab-content.active {
    display: block;
}

.sub-tab-content {
    display: none;
    padding: 20px 0;
}

.sub-tab-content.active {
    display: block;
}

.fieldset-header {
    padding: 15px 0;
}

.fieldset-header h2 {
    font-size: 22px;
    color: #333;
}

.fieldset-header p {
    color: #666;
    font-size: 14px;
    margin-top: 5px;
}

/* ==========================================
   ESTATÍSTICAS
========================================== */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 15px;
    margin: 15px 0 25px;
}

.stat-card {
    background: white;
    padding: 20px;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.06);
    text-align: center;
    transition: transform 0.3s;
}

.stat-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 4px 15px rgba(0,0,0,0.1);
}

.stat-card h3 {
    font-size: 13px;
    color: #888;
    font-weight: 500;
}

.stat-card p {
    font-size: 28px;
    font-weight: 700;
    color: #333;
    margin-top: 8px;
}

.stat-card.highlight-success p {
    color: #27ae60;
}

.stat-card.highlight-warning p {
    color: #f39c12;
}

/* ==========================================
   LISTAS
========================================== */
.item-card {
    background: white;
    padding: 15px 20px;
    margin: 8px 0;
    border-radius: 10px;
    box-shadow: 0 1px 4px rgba(0,0,0,0.06);
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
    transition: background 0.2s;
}

.item-card:hover {
    background: #fafafa;
}

.item-card .info {
    flex: 1;
    min-width: 200px;
}

.item-card .info strong {
    font-size: 15px;
}

.item-card .info .detail {
    font-size: 13px;
    color: #666;
}

.item-card .actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

/* ==========================================
   STATUS BADGES
========================================== */
.badge-status {
    padding: 3px 12px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 600;
    display: inline-block;
}

.badge-pendente {
    background: #fff3cd;
    color: #856404;
}

.badge-confirmado,
.badge-pago {
    background: #d4edda;
    color: #155724;
}

.badge-recusado,
.badge-cancelado {
    background: #f8d7da;
    color: #721c24;
}

.badge-vencido {
    background: #f8d7da;
    color: #721c24;
}

.badge-entregue,
.badge-ativo {
    background: #d4edda;
    color: #155724;
}

.badge-inativo {
    background: #e2e3e5;
    color: #383d41;
}

/* ==========================================
   MENSAGENS
========================================== */
.error-message {
    background: #f8d7da;
    color: #721c24;
    padding: 10px 15px;
    border-radius: 6px;
    margin-bottom: 15px;
    border: 1px solid #f5c6cb;
}

.success-message {
    background: #d4edda;
    color: #155724;
    padding: 10px 15px;
    border-radius: 6px;
    margin-bottom: 15px;
    border: 1px solid #c3e6cb;
}

/* ==========================================
   LOADING
========================================== */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255,255,255,0.8);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 999;
}

.loading-spinner {
    width: 40px;
    height: 40px;
    border: 4px solid #e0e0e0;
    border-top-color: #667eea;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* ==========================================
   RESPONSIVIDADE
========================================== */
@media (max-width: 768px) {
    .topbar {
        flex-direction: column;
        gap: 10px;
        padding: 12px 15px;
    }
    
    .topbar-left {
        flex-wrap: wrap;
        justify-content: center;
    }
    
    .topbar-right {
        flex-wrap: wrap;
        justify-content: center;
    }
    
    .nav-tabs {
        padding: 0 10px;
    }
    
    .tab {
        padding: 10px 14px;
        font-size: 13px;
    }
    
    .tab-content {
        padding: 10px 15px;
    }
    
    .form-row {
        flex-direction: column;
    }
    
    .form-row input,
    .form-row select {
        min-width: 100%;
    }
    
    .stats-grid {
        grid-template-columns: 1fr 1fr;
    }
    
    .item-card {
        flex-direction: column;
        align-items: stretch;
    }
    
    .item-card .actions {
        justify-content: flex-start;
    }
    
    .login-box {
        padding: 25px 20px;
    }
}

@media (max-width: 480px) {
    .stats-grid {
        grid-template-columns: 1fr;
    }
    
    .sub-tabs {
        flex-wrap: nowrap;
        overflow-x: auto;
    }
}