/* ===== ERP Ferragista - Design System (tema claro inspirado no print) ===== */
:root {
    --brand-primary: #4b4ded;           /* Roxo/azul principal */
    --brand-secondary: #22c55e;        /* Verde de destaque */
    --brand-background: #f5f6fb;       /* Fundo geral claro */
    --sidebar-bg: #ffffff;             /* Sidebar branca */
    --sidebar-border: #e5e7eb;
    --sidebar-text: #4b5563;
    --sidebar-muted: #9ca3af;
    --card-bg: #ffffff;
    --card-radius: 18px;
    --card-shadow: 0 8px 24px rgba(15, 23, 42, 0.06);
    --card-shadow-hover: 0 14px 32px rgba(15, 23, 42, 0.10);
}

* {
    -webkit-font-smoothing: antialiased;
}

body {
    background: var(--brand-background);
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
    color: #334155;
}

/* ----- Navbar ----- */
.navbar-brand {
    font-weight: 700;
    letter-spacing: 0.03em;
    font-size: 1.15rem;
}

/* Para o tema atual não usamos navbar superior fixa para logados,
   então estes estilos afetam apenas possíveis usos futuros. */
.navbar, .bg-dark {
    background: linear-gradient(135deg, var(--brand-primary), #6366f1) !important;
    box-shadow: 0 4px 16px rgba(15, 23, 42, 0.20);
}

/* ----- Sidebar ----- (escura, encostada no topo e na lateral esquerda) */
.sidebar-col {
    flex: 0 0 260px;
    max-width: 260px;
    transition: flex 0.25s ease, max-width 0.25s ease;
}

#layout-row.sidebar-collapsed .sidebar-col {
    flex: 0 0 72px;
    max-width: 72px;
}

.sidebar {
    min-height: 100vh;
    background: linear-gradient(180deg, #1e293b 0%, #0f172a 100%);
    color: rgba(255, 255, 255, 0.9);
    border-radius: 0 28px 28px 0;
    box-shadow: 4px 0 24px rgba(0, 0, 0, 0.2);
    padding: 1.25rem 0.75rem 1.5rem;
    display: flex;
    flex-direction: column;
    overflow: visible;
    margin: 0;
    transition: padding 0.25s ease;
}

#layout-row.sidebar-collapsed .sidebar {
    padding-left: 0.5rem;
    padding-right: 0.5rem;
}

.sidebar-toggle:hover {
    opacity: 1 !important;
}

#layout-row.sidebar-collapsed .sidebar .sidebar-brand a {
    justify-content: center;
}

#layout-row.sidebar-collapsed .sidebar .sidebar-brand .sidebar-logo {
    max-height: 40px;
    max-width: 40px;
}

#layout-row.sidebar-collapsed .sidebar .nav-link span.sidebar-label,
#layout-row.sidebar-collapsed .sidebar .nav-link span:not(.sidebar-label),
#layout-row.sidebar-collapsed .sidebar h6,
#layout-row.sidebar-collapsed .sidebar .sidebar-footer .sidebar-label,
#layout-row.sidebar-collapsed .sidebar .sidebar-footer span:not(.sidebar-label) {
    display: none !important;
}

#layout-row.sidebar-collapsed .sidebar .nav-link {
    justify-content: center;
    padding: 0.55rem;
}

#layout-row.sidebar-collapsed .sidebar .sidebar-footer .btn-xs {
    width: 100%;
    justify-content: center;
}

#layout-row.sidebar-collapsed .sidebar .sidebar-footer .fw-semibold,
#layout-row.sidebar-collapsed .sidebar .sidebar-footer .user-role {
    display: none !important;
}

.sidebar .nav-link span {
    white-space: nowrap;
}

.sidebar-brand {
    padding-bottom: 0.75rem;
    margin-bottom: 1rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.12);
}

.sidebar-brand a {
    color: #fff;
}

.sidebar-brand .extra-small {
    font-size: 0.7rem;
}

.sidebar-brand .sidebar-logo {
    max-height: 88px;
    max-width: 280px;
    width: auto;
    height: auto;
    object-fit: contain;
    vertical-align: middle;
}

.sidebar-user .btn-xs {
    font-size: 0.7rem;
    border-radius: 999px;
}

.sidebar .btn-outline-secondary,
.sidebar .btn-xs {
    border-color: rgba(255, 255, 255, 0.35);
    color: rgba(255, 255, 255, 0.9);
}

.sidebar .btn-outline-secondary:hover,
.sidebar .btn-xs:hover {
    background: rgba(255, 255, 255, 0.15);
    border-color: rgba(255, 255, 255, 0.5);
    color: #fff;
}

.sidebar-footer {
    margin-top: auto;
    border-top: 1px solid rgba(255, 255, 255, 0.12);
    padding-top: 0.75rem;
    color: rgba(255, 255, 255, 0.85);
    background: transparent;
}

.sidebar-footer .user-role {
    color: rgba(255, 255, 255, 0.6);
}

.sidebar h6 {
    font-size: 0.7rem;
    letter-spacing: 0.15em;
    color: rgba(255, 255, 255, 0.5);
    padding-left: 0.75rem;
    margin-bottom: 0.75rem;
}

.sidebar .nav-link {
    border-radius: 999px;
    padding: 0.55rem 0.95rem;
    margin: 0 0.35rem 0.35rem;
    color: rgba(255, 255, 255, 0.85);
    transition: all 0.18s ease;
    font-size: 0.9rem;
}

.sidebar .nav-link:hover {
    color: #fff;
    background: rgba(255, 255, 255, 0.1);
}

.sidebar .nav-link.active {
    color: #fff;
    background: linear-gradient(135deg, #3b82f6, #22c55e);
    box-shadow: 0 4px 14px rgba(34, 197, 94, 0.35);
    transform: translateX(2px);
}

.sidebar .nav-link i {
    font-size: 1rem;
    opacity: 0.9;
    width: 28px;
    height: 28px;
    border-radius: 999px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.08);
    box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.12);
}

.sidebar .nav-link span {
    white-space: nowrap;
}

.sidebar-menu {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    padding-right: 0.2rem;
}

.sidebar-menu::-webkit-scrollbar {
    width: 6px;
}

.sidebar-menu::-webkit-scrollbar-thumb {
    background: #d1d5db;
    border-radius: 999px;
}

/* ----- Main content ----- */
.layout-with-sidebar #layout-row main {
    flex: 1 1 0;
    min-width: 0;
}

main {
    padding: 0.75rem 1.25rem 2rem;
}

.layout-main {
    padding-top: 0.25rem;
}

/* ----- Topbar (alinhada com sidebar) ----- */
.topbar-main {
    margin: 0.75rem 0 1rem;
    padding: 0.75rem 1rem;
    border-radius: 14px;
    border: 1px solid #e5e7eb;
    background: #fff;
    box-shadow: 0 6px 20px rgba(15, 23, 42, 0.05);
}

.topbar-title {
    font-weight: 700;
    color: #1f2937;
    line-height: 1;
}

.topbar-badge {
    width: 34px;
    height: 34px;
    border-radius: 10px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: #eef2ff;
    color: var(--brand-primary);
    border: 1px solid #dbe3ff;
}

.page-header {
    margin-bottom: 1.5rem;
}

.page-header h1, .page-header h4 {
    font-weight: 700;
    color: var(--brand-primary);
    margin-bottom: 0.25rem;
}

.page-header .text-muted {
    font-size: 0.9rem;
}

/* ----- Cards (global) ----- */
.card {
    border: none;
    border-radius: var(--card-radius);
    box-shadow: var(--card-shadow);
    transition: box-shadow 0.2s ease, transform 0.2s ease;
    overflow: hidden;
}

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

.card-header {
    background: var(--card-bg);
    border-bottom: 1px solid #e2e8f0;
    font-weight: 600;
    color: var(--brand-primary);
    padding: 1rem 1.25rem;
    font-size: 0.95rem;
}

.card-header .bi {
    margin-right: 0.5rem;
    opacity: 0.8;
}

.card-body {
    padding: 1.25rem;
}

/* ----- Dashboard metric cards ----- */
.card-metric {
    border: none;
    border-radius: var(--card-radius);
    box-shadow: var(--card-shadow);
    transition: all 0.25s ease;
    overflow: hidden;
    position: relative;
}

.card-metric::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 4px;
    background: var(--brand-secondary);
}

.card-metric:hover {
    box-shadow: var(--card-shadow-hover);
    transform: translateY(-2px);
}

.card-metric .card-body {
    padding: 1.25rem 1rem 1.25rem 1.25rem;
}

.card-metric .metric-icon {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.35rem;
    margin-bottom: 0.75rem;
}

.card-metric .metric-label {
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #64748b;
    margin-bottom: 0.35rem;
}

.card-metric .metric-value {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--brand-primary);
    letter-spacing: -0.02em;
}

.card-metric.card-metric-success::before { background: #10b981; }
.card-metric.card-metric-success .metric-icon { background: rgba(16, 185, 129, 0.15); color: #10b981; }

.card-metric.card-metric-warning::before { background: #f59e0b; }
.card-metric.card-metric-warning .metric-icon { background: rgba(245, 158, 11, 0.15); color: #f59e0b; }
.card-metric.card-metric-warning .metric-value { color: #b45309; }

.card-metric.card-metric-danger::before { background: #ef4444; }
.card-metric.card-metric-danger .metric-icon { background: rgba(239, 68, 68, 0.15); color: #ef4444; }
.card-metric.card-metric-danger .metric-value { color: #dc2626; }

.card-metric.card-metric-info::before { background: #0ea5e9; }
.card-metric.card-metric-info .metric-icon { background: rgba(14, 165, 233, 0.15); color: #0ea5e9; }

/* ----- Chart cards ----- */
.card-chart .card-header {
    display: flex;
    align-items: center;
}

.card-chart .card-body {
    min-height: 260px;
}

/* ----- Alertas / list groups ----- */
.list-group-item {
    border-radius: 10px !important;
    margin-bottom: 0.5rem;
    border: 1px solid #e2e8f0;
    padding: 0.85rem 1rem;
}

.list-group-item:last-child {
    margin-bottom: 0;
}

/* ----- Tables ----- */
.table {
    font-size: 0.9rem;
}

.table thead th {
    font-weight: 600;
    color: var(--brand-primary);
    text-transform: uppercase;
    font-size: 0.75rem;
    letter-spacing: 0.05em;
    border-bottom: 2px solid #e2e8f0;
    padding: 0.9rem 0.75rem;
}

.table tbody td {
    padding: 0.85rem 0.75rem;
    vertical-align: middle;
}

.table-hover tbody tr:hover {
    background: #f8fafc;
}

/* ----- Buttons ----- */
.btn {
    border-radius: 10px;
    font-weight: 600;
    padding: 0.5rem 1rem;
}

.btn-primary {
    background: linear-gradient(135deg, var(--brand-secondary), #0284c7);
    border: none;
    box-shadow: 0 2px 8px rgba(14, 165, 233, 0.35);
}

.btn-primary:hover {
    background: linear-gradient(135deg, #0284c7, var(--brand-secondary));
    box-shadow: 0 4px 12px rgba(14, 165, 233, 0.45);
}

/* ----- Forms ----- */
.form-control, .form-select {
    border-radius: 10px;
    border: 1px solid #cbd5e1;
    padding: 0.5rem 0.85rem;
}

.form-control:focus, .form-select:focus {
    border-color: var(--brand-secondary);
    box-shadow: 0 0 0 3px rgba(14, 165, 233, 0.2);
}

/* ----- Badges ----- */
.badge {
    font-weight: 600;
    padding: 0.35em 0.65em;
}

/* ----- Alerts (sistema) ----- */
.alert {
    border-radius: 12px;
    border: none;
}

/* ----- Login ----- */
.login-bg {
    background: #ffffff;
    border-top-left-radius: 18px !important;
    border-top-right-radius: 18px !important;
    border-bottom: 1px solid #e5e7eb;
}

.login-card {
    border-radius: 18px;
    overflow: hidden;
}

.login-logo {
    max-height: 72px;
    width: auto;
    height: auto;
    object-fit: contain;
}

/* ----- Utilities ----- */
.table-actions { white-space: nowrap; }
.badge-status { font-size: 0.75rem; }
