/* Design Direction: "Documento Oficial" — industrial utility with Tubo Oeste brand identity */
/* Differentiation: Large stamped step-numbers feel like a bureaucratic process form, not a generic SaaS UI */

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

:root {
    --primary:        #c00000;
    --primary-dark:   #a00000;
    --primary-light:  #fef2f2;
    --text:           #1e293b;
    --text-muted:     #475569;
    --bg:             #f8fafc;
    --white:          #ffffff;
    --border:         #e2e8f0;
    --success:        #16a34a;
    --success-light:  #f0fdf4;
    --warning:        #d97706;
    --warning-light:  #fffbeb;
    --danger:         #dc2626;
    --danger-light:   #fef2f2;
    --radius:         8px;
    --radius-sm:      4px;
    --shadow-sm:      0 1px 3px rgba(0,0,0,0.07), 0 1px 2px rgba(0,0,0,0.05);
    --shadow-md:      0 4px 20px rgba(0,0,0,0.09), 0 2px 8px rgba(0,0,0,0.05);
    --font-heading:   'Poppins', Arial, sans-serif;
    --font-body:      'Open Sans', Arial, sans-serif;
    --transition:     0.18s ease;
}

/* ─── Base ────────────────────────────────────────────────────────────────── */

body {
    font-family: var(--font-body);
    font-size: 16px;
    color: var(--text);
    background: var(--bg);
    line-height: 1.6;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

h1, h2, h3, h4 {
    font-family: var(--font-heading);
    font-weight: 700;
    line-height: 1.25;
    color: var(--text);
}

/* ─── Layout ──────────────────────────────────────────────────────────────── */

.container {
    width: 100%;
    max-width: 900px;
    margin: 0 auto;
    padding: 0 20px;
}

.container--wide {
    max-width: 1100px;
}

.main-content {
    flex: 1;
    padding: 40px 0 60px;
}

/* ─── Header ──────────────────────────────────────────────────────────────── */

.site-header {
    background: var(--white);
    border-bottom: 1px solid var(--border);
    box-shadow: var(--shadow-sm);
    position: sticky;
    top: 0;
    z-index: 100;
}

.header-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 64px;
    gap: 16px;
}

.logo {
    display: flex;
    align-items: center;
    gap: 10px;
    text-decoration: none;
}

.logo-img {
    height: 160px;
    width: auto;
    object-fit: contain;
    object-position: left center;
    display: block;
}

.header-nav {
    display: flex;
    align-items: center;
    gap: 8px;
}

.nav-link {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-muted);
    padding: 6px 12px;
    border-radius: var(--radius-sm);
    transition: color var(--transition), background var(--transition);
}

.nav-link:hover {
    color: var(--primary);
    background: var(--primary-light);
    text-decoration: none;
}

/* ─── Footer ──────────────────────────────────────────────────────────────── */

.site-footer {
    background: var(--white);
    border-top: 1px solid var(--border);
    padding: 16px 0;
}

.footer-inner {
    display: flex;
    justify-content: center;
}

.footer-inner p {
    font-size: 0.85rem;
    color: var(--text-muted);
}

/* ─── Buttons ─────────────────────────────────────────────────────────────── */

.btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-family: var(--font-body);
    font-size: 0.95rem;
    font-weight: 600;
    padding: 10px 22px;
    border-radius: var(--radius);
    border: 2px solid transparent;
    cursor: pointer;
    transition: background var(--transition), box-shadow var(--transition), border-color var(--transition), color var(--transition);
    text-decoration: none;
    white-space: nowrap;
}

.btn:hover { text-decoration: none; }

.btn-sm { padding: 6px 14px; font-size: 0.875rem; }
.btn-lg { padding: 13px 28px; font-size: 1rem; }

.btn-primary {
    background: var(--primary);
    color: var(--white);
    border-color: var(--primary);
}
.btn-primary:hover {
    background: var(--primary-dark);
    border-color: var(--primary-dark);
    box-shadow: 0 4px 16px rgba(192,0,0,0.3);
}

.btn-outline {
    background: var(--primary-light);
    color: var(--primary);
    border-color: var(--primary);
}
.btn-outline:hover {
    background: #fde8e8;
    border-color: var(--primary-dark);
}

.btn-ghost {
    background: #e2e8f0;
    color: var(--text);
    border-color: #94a3b8;
}
.btn-ghost:hover {
    background: #cbd5e1;
    color: var(--text);
    border-color: #64748b;
}

.btn-success {
    background: var(--success);
    color: var(--white);
    border-color: var(--success);
}
.btn-success:hover {
    background: #15803d;
    border-color: #15803d;
    box-shadow: 0 4px 16px rgba(22,163,74,0.3);
}

.btn-danger {
    background: var(--danger);
    color: var(--white);
    border-color: var(--danger);
}
.btn-danger:hover { background: #b91c1c; border-color: #b91c1c; }

.btn[disabled], .btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    pointer-events: none;
}

/* ─── Alerts ──────────────────────────────────────────────────────────────── */

.alert {
    padding: 14px 18px;
    border-radius: var(--radius);
    font-size: 0.9rem;
    margin-bottom: 20px;
    border-left: 4px solid;
}

.alert-success { background: var(--success-light); border-color: var(--success); color: #166534; }
.alert-danger   { background: var(--danger-light);  border-color: var(--danger);  color: #991b1b; }
.alert-warning  { background: var(--warning-light); border-color: var(--warning); color: #92400e; }

/* ─── Cards ───────────────────────────────────────────────────────────────── */

.card {
    background: var(--white);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
}

.card-body { padding: 28px; }
.card-header {
    padding: 20px 28px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}
.card-header h2, .card-header h3 {
    font-size: 1.1rem;
    margin: 0;
}

/* ─── Forms ───────────────────────────────────────────────────────────────── */

.form-group {
    margin-bottom: 20px;
}

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

label {
    display: block;
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 6px;
}

label .required { color: var(--primary); margin-left: 2px; }

input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
select,
textarea {
    width: 100%;
    padding: 10px 14px;
    font-family: var(--font-body);
    font-size: 0.95rem;
    color: var(--text);
    background: var(--white);
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    transition: border-color var(--transition), box-shadow var(--transition);
    outline: none;
    appearance: none;
}

input:focus, select:focus, textarea:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(192,0,0,0.1);
}

input::placeholder, textarea::placeholder { color: var(--text-muted); opacity: 0.7; }

textarea { resize: vertical; min-height: 100px; }

select {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%23475569' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 14px center;
    padding-right: 36px;
}

.form-hint {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-top: 4px;
}

/* ─── Login ───────────────────────────────────────────────────────────────── */

.login-wrap {
    min-height: calc(100vh - 130px);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 40px 20px;
}

.login-card {
    width: 100%;
    max-width: 420px;
    background: var(--white);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-md);
    overflow: hidden;
}

.login-header {
    background: var(--primary);
    padding: 32px 36px 28px;
    text-align: center;
}

.login-logo-img {
    height: 90px;
    width: auto;
    display: block;
    margin: 0 auto 8px;
    filter: brightness(0) invert(1);
}

.login-header p {
    font-size: 0.875rem;
    color: rgba(255,255,255,0.85);
    margin-top: 4px;
}

.login-body { padding: 32px 36px; }

.login-body .btn { width: 100%; justify-content: center; margin-top: 8px; }

/* ─── Wizard ──────────────────────────────────────────────────────────────── */

.wizard-wrap { max-width: 760px; margin: 0 auto; }

/* Step indicator — the "stamp" design anchor */
.step-indicator {
    display: flex;
    align-items: center;
    margin-bottom: 36px;
}

.step-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    flex: 1;
}

.step-num {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    border: 2px solid var(--border);
    background: var(--white);
    color: var(--text-muted);
    font-family: var(--font-heading);
    font-size: 1.05rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition);
    position: relative;
    z-index: 1;
}

.step-label {
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--text-muted);
    text-align: center;
    transition: color var(--transition);
}

.step-connector {
    flex: 1;
    height: 2px;
    background: var(--border);
    margin-bottom: 24px;
    transition: background var(--transition);
}

.step-item.active .step-num {
    background: var(--primary);
    border-color: var(--primary);
    color: var(--white);
    box-shadow: 0 0 0 4px var(--primary-light);
}

.step-item.active .step-label { color: var(--primary); }

.step-item.done .step-num {
    background: var(--success);
    border-color: var(--success);
    color: var(--white);
}

.step-item.done .step-label { color: var(--success); }

.step-connector.done { background: var(--success); }

/* Step content */
.step-content { display: none; }
.step-content.active { display: block; }

.step-card {
    background: var(--white);
    border: 1px solid var(--border);
    border-left: 4px solid var(--primary);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
}

.step-card-header {
    padding: 22px 28px 18px;
    border-bottom: 1px solid var(--border);
}

.step-card-header h2 {
    font-size: 1.15rem;
    margin: 0;
    display: flex;
    align-items: center;
    gap: 10px;
}

.step-card-header p {
    font-size: 0.875rem;
    color: var(--text-muted);
    margin-top: 4px;
}

.step-card-body { padding: 24px 28px; }

/* Wizard nav */
.wizard-nav {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-top: 28px;
    gap: 12px;
}

.wizard-nav-right { display: flex; gap: 12px; }

/* Auto-save indicator */
.save-indicator {
    font-size: 0.8rem;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    gap: 6px;
    transition: color var(--transition);
}

.save-indicator.saving { color: var(--warning); }
.save-indicator.saved  { color: var(--success); }

.save-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: currentColor;
}

/* Rascunho toolbar */
.rascunho-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 28px;
    gap: 12px;
    flex-wrap: wrap;
}

.rascunho-toolbar h1 { font-size: 1.5rem; }

/* ─── Produtos table ──────────────────────────────────────────────────────── */

.produtos-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}

.produtos-table th {
    text-align: left;
    font-size: 0.78rem;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    padding: 8px 10px;
    border-bottom: 2px solid #cbd5e1;
    border-right: 1px solid var(--border);
    background: #edf2f7;
}
.produtos-table th:last-child { border-right: none; }

.produtos-table td {
    padding: 8px 6px;
    border-bottom: 1px solid var(--border);
    border-right: 1px solid var(--border);
    vertical-align: middle;
    background: var(--white);
}
.produtos-table td:last-child { border-right: none; }
.produtos-table tbody tr:hover td { background: #fafbfc; }

.produtos-table input {
    padding: 7px 10px;
    font-size: 0.875rem;
}

.produtos-table .col-codigo { width: 90px; }
.produtos-table .col-ncm    { width: 90px; }
.produtos-table .col-qtd    { width: 80px; }
.produtos-table .col-valor  { width: 110px; }
.produtos-table .col-remove { width: 40px; text-align: center; }

.btn-remove-produto {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text-muted);
    font-size: 1.1rem;
    padding: 4px;
    border-radius: var(--radius-sm);
    transition: color var(--transition), background var(--transition);
    line-height: 1;
}

.btn-remove-produto:hover { color: var(--danger); background: var(--danger-light); }

.btn-add-produto {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--primary);
    background: none;
    border: 1.5px dashed var(--primary);
    border-radius: var(--radius-sm);
    padding: 8px 14px;
    cursor: pointer;
    margin-top: 12px;
    transition: background var(--transition);
}

.btn-add-produto:hover { background: var(--primary-light); }

/* ─── Rascunhos list ──────────────────────────────────────────────────────── */

.rascunhos-list { display: flex; flex-direction: column; gap: 12px; }

.rascunho-item {
    background: var(--white);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 18px 22px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    box-shadow: var(--shadow-sm);
    transition: border-color var(--transition), box-shadow var(--transition);
}

.rascunho-item:hover {
    border-color: var(--primary);
    box-shadow: var(--shadow-md);
}

.rascunho-info h3 { font-size: 1rem; margin-bottom: 4px; }
.rascunho-info p  { font-size: 0.85rem; color: var(--text-muted); }

.rascunho-actions { display: flex; gap: 8px; flex-shrink: 0; }

/* ─── Status badges ───────────────────────────────────────────────────────── */

.badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    font-size: 0.78rem;
    font-weight: 700;
    padding: 3px 10px;
    border-radius: 999px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.badge-rascunho { background: #f1f5f9; color: #475569; }
.badge-enviado  { background: var(--warning-light); color: #92400e; }
.badge-concluido{ background: var(--success-light); color: #166534; }

/* ─── Admin ───────────────────────────────────────────────────────────────── */

.page-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 28px;
    flex-wrap: wrap;
}

.page-header h1 { font-size: 1.6rem; }
.page-header p   { font-size: 0.9rem; color: var(--text-muted); margin-top: 4px; }

/* Admin table */
.admin-table-wrap {
    background: var(--white);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    overflow-x: auto;
}

.admin-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}

.admin-table th {
    text-align: left;
    font-size: 0.78rem;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    padding: 12px 20px;
    border-bottom: 2px solid #cbd5e1;
    background: #edf2f7;
    white-space: nowrap;
}

.admin-table td {
    padding: 14px 20px;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}

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

.admin-table tr:hover td { background: #fafafa; }

.admin-table td .pedido-num { font-family: var(--font-heading); font-weight: 700; color: var(--text-muted); }

/* Admin pedido detail */
.pedido-section {
    background: var(--white);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    margin-bottom: 20px;
    box-shadow: var(--shadow-sm);
}

.pedido-section-header {
    background: var(--bg);
    border-bottom: 1px solid var(--border);
    padding: 14px 22px;
    font-family: var(--font-heading);
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

.pedido-field {
    display: flex;
    align-items: center;
    padding: 13px 22px;
    border-bottom: 1px solid var(--border);
    gap: 12px;
}

.pedido-field:last-child { border-bottom: none; }

.pedido-field-label {
    width: 200px;
    flex-shrink: 0;
    font-size: 0.85rem;
    color: var(--text-muted);
    font-weight: 600;
}

.pedido-field-value {
    flex: 1;
    font-size: 0.95rem;
    color: var(--text);
    word-break: break-word;
}

.pedido-field-value.empty { color: var(--text-muted); font-style: italic; }

/* Copy button */
.btn-copy {
    background: none;
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    cursor: pointer;
    color: var(--text-muted);
    padding: 4px 8px;
    font-size: 0.78rem;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    transition: all var(--transition);
    flex-shrink: 0;
    white-space: nowrap;
}

.btn-copy:hover { color: var(--primary); border-color: var(--primary); background: var(--primary-light); }
.btn-copy.copied { color: var(--success); border-color: var(--success); background: var(--success-light); }

.cell-copy {
    cursor: pointer;
    position: relative;
    transition: background 0.15s;
}
.cell-copy:hover { background: var(--primary-light); }
.cell-copy.copied { background: var(--success-light); color: var(--success); font-weight: 600; }

/* Produtos table (admin view) */
.produtos-view {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}

.produtos-view th {
    text-align: left;
    font-size: 0.78rem;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    padding: 10px 14px;
    background: #edf2f7;
    border-bottom: 2px solid #cbd5e1;
}

.produtos-view td {
    padding: 11px 14px;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}

.produtos-view tr:last-child td { border-bottom: none; }

.pedido-actions {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    margin-top: 24px;
}

/* Filters */
.filters {
    display: flex;
    gap: 8px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.filter-btn {
    font-size: 0.85rem;
    font-weight: 600;
    padding: 7px 16px;
    border-radius: 999px;
    border: 1.5px solid var(--border);
    background: var(--white);
    color: var(--text-muted);
    cursor: pointer;
    transition: all var(--transition);
}

.filter-btn:hover, .filter-btn.active {
    border-color: var(--primary);
    color: var(--primary);
    background: var(--primary-light);
}

/* Empty state */
.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-muted);
}

.empty-state svg { margin-bottom: 16px; opacity: 0.4; }
.empty-state h3  { font-size: 1.1rem; margin-bottom: 8px; color: var(--text); }
.empty-state p   { font-size: 0.9rem; }

/* Success page */
.success-wrap {
    text-align: center;
    max-width: 500px;
    margin: 80px auto;
    padding: 0 20px;
}

.success-icon {
    width: 72px;
    height: 72px;
    background: var(--success-light);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 24px;
    font-size: 2rem;
}

.success-wrap h1 { font-size: 1.6rem; margin-bottom: 12px; }
.success-wrap p  { color: var(--text-muted); margin-bottom: 28px; }

/* ─── Responsive ──────────────────────────────────────────────────────────── */

@media (max-width: 600px) {
    .header-inner { height: 56px; }
    .logo-text    { font-size: 1rem; }
    .main-content { padding: 24px 0 40px; }
    .card-body    { padding: 20px; }
    .step-card-body, .step-card-header { padding: 18px 20px; }
    .step-label   { display: none; }
    .form-row     { grid-template-columns: 1fr; }

    .pedido-field { flex-wrap: wrap; }
    .pedido-field-label { width: 100%; margin-bottom: 2px; }

    .wizard-nav   { flex-direction: column-reverse; }
    .wizard-nav-right { width: 100%; }
    .wizard-nav-right .btn { flex: 1; justify-content: center; }

    .produtos-table { font-size: 0.82rem; }
    .produtos-table .col-ncm { display: none; }

    .page-header  { flex-direction: column; }
    .rascunho-item { flex-direction: column; align-items: flex-start; }
    .rascunho-actions { width: 100%; }
    .rascunho-actions .btn { flex: 1; justify-content: center; }
}

@media (max-width: 400px) {
    .step-num { width: 36px; height: 36px; font-size: 0.9rem; }
    .btn-add-produto { font-size: 0.8rem; }
}
