/* ==========================================================================
   Design System — Acompanhamento de Pedidos & Devoluções
   ========================================================================== */

/* ---------- Custom Properties ---------- */
:root {
    /* Brand */
    --color-primary: #2B71CA;
    --color-primary-dark: #1e5ba8;
    --color-primary-light: #e3f0fc;
    --color-header-bg: #3D5A80;
    --color-header-hover: #2B4A6E;

    /* Surface */
    --color-bg: #2B71CA;
    --color-surface: #ffffff;
    --color-surface-hover: #f0f4ff;
    --color-border: #e0e0e0;
    --color-border-light: #f0f0f0;

    /* Text */
    --color-text: #333333;
    --color-text-secondary: #666666;
    --color-text-muted: #999999;
    --color-text-inverse: #ffffff;

    /* Status — Pedidos */
    --color-status-confirmado-bg: #fff3cd;
    --color-status-confirmado-text: #856404;
    --color-status-faturado-bg: #cce5ff;
    --color-status-faturado-text: #004085;
    --color-status-expedido-bg: #d1ecf1;
    --color-status-expedido-text: #0c5460;
    --color-status-entregue-bg: #d4edda;
    --color-status-entregue-text: #155724;
    --color-status-bloqueado-bg: #ffebee;
    --color-status-bloqueado-text: #c62828;
    --color-status-reemitido-bg: #f5f5f5;
    --color-status-reemitido-text: #616161;

    /* Status — Devoluções */
    --color-status-analise-bg: #fff3cd;
    --color-status-analise-text: #856404;
    --color-status-faturamento-bg: #cce5ff;
    --color-status-faturamento-text: #004085;
    --color-status-coleta-bg: #d1ecf1;
    --color-status-coleta-text: #0c5460;
    --color-status-conferencia-bg: #e8eaf6;
    --color-status-conferencia-text: #283593;
    --color-status-concluida-bg: #d4edda;
    --color-status-concluida-text: #155724;
    --color-status-recusada-bg: #ffebee;
    --color-status-recusada-text: #c62828;

    /* Feedback */
    --color-error: #e53935;
    --color-error-bg: #ff5252;
    --color-success: #43a047;
    --color-success-bg: #e8f5e9;
    --color-warning: #f57f17;
    --color-warning-bg: #fff8e1;
    --color-info: #1565c0;
    --color-info-bg: #e3f2fd;

    /* Spacing */
    --spacing-xs: 4px;
    --spacing-sm: 8px;
    --spacing-md: 16px;
    --spacing-lg: 24px;
    --spacing-xl: 32px;
    --spacing-2xl: 40px;

    /* Radius */
    --radius-sm: 6px;
    --radius-md: 8px;
    --radius-lg: 12px;
    --radius-xl: 16px;
    --radius-pill: 999px;

    /* Shadow */
    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.1);
    --shadow-md: 0 8px 20px rgba(0, 0, 0, 0.15);
    --shadow-lg: 0 10px 30px rgba(0, 0, 0, 0.2);

    /* Font */
    --font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
}

/* ---------- Reset ---------- */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: var(--font-family);
    background: var(--color-bg);
    color: var(--color-text);
    min-height: 100vh;
    padding: 20px;
    line-height: 1.5;
}

/* ---------- Layout ---------- */
.container {
    max-width: 1200px;
    margin: 0 auto;
}

/* ---------- Page Header ---------- */
.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--spacing-2xl);
    color: var(--color-text-inverse);
}

.page-header h1 {
    font-size: 32px;
    font-weight: 600;
}

.page-header .logo {
    height: 40px;
}

.page-header .logo img {
    height: 100%;
    width: auto;
}

/* ---------- Cards ---------- */
.card {
    background: var(--color-surface);
    border-radius: var(--radius-xl);
    padding: 30px;
    box-shadow: var(--shadow-lg);
}

.card--flat {
    box-shadow: var(--shadow-sm);
}

.card--no-padding {
    padding: 0;
}

/* ---------- Tabs ---------- */
.tab-group {
    display: inline-flex;
    background: #f0f0f0;
    border-radius: var(--radius-md);
    padding: 4px;
    margin-bottom: var(--spacing-md);
}

.tab-item {
    padding: 10px 24px;
    border: none;
    background: transparent;
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-weight: 600;
    color: var(--color-text-secondary);
    cursor: pointer;
    transition: all 0.2s;
}

.tab-item:hover {
    color: var(--color-text);
}

.tab-item.active {
    background: var(--color-surface);
    color: var(--color-primary);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

/* ---------- Buttons ---------- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--spacing-sm);
    padding: 12px 24px;
    border: none;
    border-radius: var(--radius-md);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    text-decoration: none;
    line-height: 1;
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn-primary {
    background: var(--color-header-bg);
    color: var(--color-text-inverse);
}

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

.btn-outline {
    background: transparent;
    color: var(--color-header-bg);
    border: 2px solid var(--color-header-bg);
}

.btn-outline:hover:not(:disabled) {
    background: var(--color-header-bg);
    color: var(--color-text-inverse);
}

.btn-success {
    background: var(--color-success);
    color: var(--color-text-inverse);
}

.btn-success:hover:not(:disabled) {
    background: #388e3c;
}

.btn.disabled, .btn[aria-disabled="true"] {
    opacity: 0.45;
    cursor: not-allowed;
    pointer-events: none;
}

.btn-sm {
    padding: 8px 16px;
    font-size: 13px;
}

.btn-lg {
    padding: 14px 32px;
    font-size: 16px;
}

/* ---------- Status Badges ---------- */
.badge {
    display: inline-block;
    padding: 4px 12px;
    border-radius: var(--radius-pill);
    font-size: 12px;
    font-weight: 600;
}

.status-badge {
    display: inline-block;
    padding: 6px 14px;
    border-radius: var(--radius-pill);
    font-size: 13px;
    font-weight: 600;
}

/* Pedidos */
.status-badge.confirmado { background: var(--color-status-confirmado-bg); color: var(--color-status-confirmado-text); }
.status-badge.faturado { background: var(--color-status-faturado-bg); color: var(--color-status-faturado-text); }
.status-badge.expedido { background: var(--color-status-expedido-bg); color: var(--color-status-expedido-text); }
.status-badge.entregue { background: var(--color-status-entregue-bg); color: var(--color-status-entregue-text); }
.status-badge.bloqueado { background: var(--color-status-bloqueado-bg); color: var(--color-status-bloqueado-text); }
.status-badge.reemitido { background: var(--color-status-reemitido-bg); color: var(--color-status-reemitido-text); }

/* Devoluções */
.status-badge.analise { background: var(--color-status-analise-bg); color: var(--color-status-analise-text); }
.status-badge.faturamento { background: var(--color-status-faturamento-bg); color: var(--color-status-faturamento-text); }
.status-badge.coleta { background: var(--color-status-coleta-bg); color: var(--color-status-coleta-text); }
.status-badge.conferencia { background: var(--color-status-conferencia-bg); color: var(--color-status-conferencia-text); }
.status-badge.concluida { background: var(--color-status-concluida-bg); color: var(--color-status-concluida-text); }
.status-badge.recusada { background: var(--color-status-recusada-bg); color: var(--color-status-recusada-text); }

.brand-badge {
    display: inline-block;
    padding: 4px 12px;
    border-radius: var(--radius-pill);
    font-size: 12px;
    font-weight: 600;
    background: var(--color-primary-light);
    color: var(--color-primary);
}

/* ---------- Data Tables ---------- */
.data-table-wrapper {
    background: var(--color-surface);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-md);
    overflow: hidden;
}

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

.data-table thead {
    background: var(--color-header-bg);
    color: var(--color-text-inverse);
}

.data-table th {
    padding: 18px 20px;
    text-align: left;
    font-weight: 600;
    font-size: 14px;
}

.data-table tbody tr {
    border-bottom: 1px solid var(--color-border);
    transition: background 0.2s;
    cursor: pointer;
}

.data-table tbody tr:hover {
    background: var(--color-surface-hover);
}

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

.data-table td {
    padding: 18px 20px;
    font-size: 14px;
    color: var(--color-text);
}

.data-table .cell-id {
    font-weight: 600;
    color: var(--color-primary);
}

.data-table .cell-action {
    font-size: 13px;
    color: var(--color-text-secondary);
}

/* ---------- Forms ---------- */
.form-label {
    display: block;
    margin-bottom: var(--spacing-sm);
    font-size: 14px;
    font-weight: 600;
    color: var(--color-text);
}

.form-input {
    width: 100%;
    padding: 14px 18px;
    border: 2px solid var(--color-border);
    border-radius: var(--radius-md);
    font-size: 16px;
    font-family: var(--font-family);
    transition: border-color 0.3s;
}

.form-input:focus {
    outline: none;
    border-color: var(--color-primary);
}

.form-input.invalid {
    border-color: var(--color-error);
    background-color: #ffebee;
}

.form-input.invalid:focus {
    border-color: var(--color-error);
}

.input-group {
    flex: 1;
    display: flex;
    flex-direction: column;
}

.input-wrapper {
    position: relative;
}

.tooltip {
    display: none;
    position: absolute;
    bottom: calc(100% + 8px);
    left: 0;
    background: var(--color-error);
    color: var(--color-text-inverse);
    padding: 8px 12px;
    border-radius: var(--radius-sm);
    font-size: 13px;
    white-space: nowrap;
    z-index: 10;
    box-shadow: var(--shadow-sm);
}

.tooltip::after {
    content: '';
    position: absolute;
    top: 100%;
    left: 20px;
    border: 6px solid transparent;
    border-top-color: var(--color-error);
}

.form-input.invalid + .tooltip,
input.invalid + .tooltip {
    display: block;
}

/* ---------- File Input ---------- */
.file-input-wrapper {
    position: relative;
    border: 2px dashed var(--color-border);
    border-radius: var(--radius-md);
    padding: 20px;
    text-align: center;
    cursor: pointer;
    transition: border-color 0.2s, background 0.2s;
}

.file-input-wrapper:hover {
    border-color: var(--color-primary);
    background: var(--color-primary-light);
}

.file-input-wrapper input[type="file"] {
    position: absolute;
    inset: 0;
    opacity: 0;
    cursor: pointer;
}

.file-input-wrapper .file-label {
    font-size: 14px;
    color: var(--color-text-secondary);
}

.file-input-wrapper .file-name {
    font-weight: 600;
    color: var(--color-primary);
}

/* ---------- Timeline (Horizontal) ---------- */
.timeline {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    margin: var(--spacing-lg) 0;
    position: relative;
}

.timeline::before {
    content: '';
    position: absolute;
    top: 16px;
    left: 24px;
    right: 24px;
    height: 3px;
    background: var(--color-border);
    z-index: 0;
}

.timeline-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    position: relative;
    z-index: 1;
    flex: 1;
    text-align: center;
}

.timeline-dot {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    border: 3px solid var(--color-border);
    background: var(--color-surface);
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: var(--spacing-sm);
    transition: all 0.3s;
    font-size: 14px;
    font-weight: 700;
    color: var(--color-text-muted);
}

.timeline-item.completed .timeline-dot {
    background: var(--color-success);
    border-color: var(--color-success);
    color: var(--color-text-inverse);
}

.timeline-item.current .timeline-dot {
    background: var(--color-primary);
    border-color: var(--color-primary);
    color: var(--color-text-inverse);
    box-shadow: 0 0 0 4px rgba(43, 113, 202, 0.2);
}

.timeline-item.recusada .timeline-dot {
    background: var(--color-error);
    border-color: var(--color-error);
    color: var(--color-text-inverse);
}

.timeline-label {
    font-size: 12px;
    font-weight: 600;
    color: var(--color-text-muted);
    max-width: 110px;
}

.timeline-item.completed .timeline-label,
.timeline-item.current .timeline-label {
    color: var(--color-text);
}

/* ---------- Info Banners (Faixa Explicativa) ---------- */
.info-banner {
    border-radius: var(--radius-lg);
    padding: var(--spacing-lg);
    margin: var(--spacing-lg) 0;
}

.info-banner h3 {
    font-size: 16px;
    margin-bottom: var(--spacing-sm);
}

.info-banner p {
    font-size: 14px;
    line-height: 1.6;
    margin-bottom: var(--spacing-md);
}

.info-banner p:last-child {
    margin-bottom: 0;
}

.info-banner .banner-actions {
    display: flex;
    gap: var(--spacing-md);
    flex-wrap: wrap;
    margin-top: var(--spacing-md);
}

.info-banner--info {
    background: var(--color-info-bg);
    border-left: 4px solid var(--color-info);
}

.info-banner--info h3 { color: var(--color-info); }

.info-banner--success {
    background: var(--color-success-bg);
    border-left: 4px solid var(--color-success);
}

.info-banner--success h3 { color: var(--color-success); }

.info-banner--warning {
    background: var(--color-warning-bg);
    border-left: 4px solid var(--color-warning);
}

.info-banner--warning h3 { color: var(--color-warning); }

.info-banner--error {
    background: #ffebee;
    border-left: 4px solid var(--color-error);
}

.info-banner--error h3 { color: var(--color-error); }

/* Exception banners (pedidos) */
.exception-banner {
    border-radius: var(--radius-lg);
    padding: var(--spacing-lg);
    margin-bottom: var(--spacing-lg);
}

.exception-banner--bloqueio {
    background: #ffebee;
    border-left: 4px solid #c62828;
}

.exception-banner--incidente {
    background: #fff8e1;
    border-left: 4px solid #f57f17;
}

.exception-banner--dedicado {
    background: #e3f2fd;
    border-left: 4px solid #1565c0;
}

/* ---------- Feedback States ---------- */
.loading {
    text-align: center;
    padding: var(--spacing-2xl);
    color: var(--color-text-inverse);
    font-size: 18px;
}

.error {
    background: var(--color-error-bg);
    color: var(--color-text-inverse);
    padding: 20px;
    border-radius: var(--radius-lg);
    margin-bottom: 20px;
    text-align: center;
}

.no-results {
    background: var(--color-surface);
    padding: 60px 40px;
    border-radius: var(--radius-xl);
    text-align: center;
    box-shadow: var(--shadow-md);
}

.no-results h2 {
    color: var(--color-text-secondary);
    margin-bottom: 10px;
}

.no-results p {
    color: var(--color-text-muted);
    font-size: 14px;
}

.empty-state {
    text-align: center;
    padding: 60px 40px;
}

.empty-state-icon {
    font-size: 48px;
    margin-bottom: var(--spacing-md);
    opacity: 0.4;
}

.empty-state h3 {
    color: var(--color-text-secondary);
    margin-bottom: var(--spacing-sm);
}

.empty-state p {
    color: var(--color-text-muted);
    font-size: 14px;
    max-width: 400px;
    margin: 0 auto;
}

/* ---------- Back Button ---------- */
.back-button {
    display: inline-flex;
    align-items: center;
    gap: var(--spacing-sm);
    color: var(--color-text-inverse);
    text-decoration: none;
    font-size: 14px;
    font-weight: 500;
    margin-bottom: var(--spacing-lg);
    padding: 8px 0;
    transition: opacity 0.2s;
}

.back-button:hover {
    opacity: 0.8;
}

.back-button svg {
    width: 20px;
    height: 20px;
}

/* ---------- Detail Page Header ---------- */
.detail-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: var(--spacing-lg);
    padding-bottom: var(--spacing-lg);
    border-bottom: 1px solid var(--color-border);
}

.detail-header h2 {
    font-size: 20px;
    margin-bottom: var(--spacing-xs);
}

.detail-header .detail-meta {
    display: flex;
    gap: var(--spacing-md);
    align-items: center;
    margin-top: var(--spacing-sm);
    font-size: 14px;
    color: var(--color-text-secondary);
}

/* ---------- Items Table (Simple) ---------- */
.items-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: var(--spacing-md);
}

.items-table th {
    padding: 12px 16px;
    text-align: left;
    font-size: 13px;
    font-weight: 600;
    color: var(--color-text-secondary);
    border-bottom: 2px solid var(--color-border);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.items-table td {
    padding: 12px 16px;
    font-size: 14px;
    border-bottom: 1px solid var(--color-border-light);
}

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

/* ---------- Steps (Numbered Instructions) ---------- */
.steps {
    list-style: none;
    counter-reset: step;
}

.step-item {
    counter-increment: step;
    display: flex;
    gap: var(--spacing-md);
    padding: var(--spacing-md) 0;
    border-bottom: 1px solid var(--color-border-light);
}

.step-item:last-child {
    border-bottom: none;
}

.step-item::before {
    content: counter(step);
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    background: var(--color-primary);
    color: var(--color-text-inverse);
    border-radius: 50%;
    font-size: 14px;
    font-weight: 700;
    flex-shrink: 0;
}

.step-content h4 {
    font-size: 15px;
    margin-bottom: var(--spacing-xs);
}

.step-content p {
    font-size: 14px;
    color: var(--color-text-secondary);
    line-height: 1.5;
}

/* ---------- Success State ---------- */
.success-state {
    text-align: center;
    padding: 60px 40px;
}

.success-state .success-icon {
    width: 80px;
    height: 80px;
    background: var(--color-success-bg);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto var(--spacing-lg);
    font-size: 40px;
    color: var(--color-success);
}

.success-state h2 {
    color: var(--color-success);
    margin-bottom: var(--spacing-sm);
}

.success-state p {
    color: var(--color-text-secondary);
    font-size: 14px;
    max-width: 400px;
    margin: 0 auto var(--spacing-lg);
}

/* ---------- Utility ---------- */
.text-center { text-align: center; }
.text-inverse { color: var(--color-text-inverse); }
.mb-sm { margin-bottom: var(--spacing-sm); }
.mb-md { margin-bottom: var(--spacing-md); }
.mb-lg { margin-bottom: var(--spacing-lg); }
.mt-md { margin-top: var(--spacing-md); }
.mt-lg { margin-top: var(--spacing-lg); }

/* ---------- Responsive ---------- */
@media (max-width: 768px) {
    body {
        padding: 12px;
    }

    .page-header h1 {
        font-size: 22px;
    }

    .card {
        padding: 20px;
        border-radius: var(--radius-lg);
    }

    .tab-group {
        width: 100%;
    }

    .tab-item {
        flex: 1;
        text-align: center;
        padding: 10px 12px;
    }

    .data-table th,
    .data-table td {
        padding: 12px 10px;
        font-size: 13px;
    }

    .timeline {
        flex-direction: column;
        gap: var(--spacing-sm);
    }

    .timeline::before {
        top: 0;
        bottom: 0;
        left: 16px;
        right: auto;
        width: 3px;
        height: auto;
    }

    .timeline-item {
        flex-direction: row;
        gap: var(--spacing-md);
        text-align: left;
    }

    .timeline-label {
        max-width: none;
    }

    .info-banner .banner-actions {
        flex-direction: column;
    }

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

    .detail-header {
        flex-direction: column;
        gap: var(--spacing-md);
    }
}
