/* ==================================================================================
   FRETEI - Sistema de Gestão de Fretes
   Arquivo CSS Principal
   ================================================================================== */

/* ==================================================================================
   VARIÁVEIS CSS (Tema Claro e Escuro)
   ================================================================================== */
:root {
    /* Cores Primárias */
    --primary-orange: #FF6D00;
    --primary-orange-dark: #E65100;
    --primary-orange-light: #FF9100;

    /* Tema Claro (Padrão) */
    --bg-body: #f0f2f5;
    --bg-card: #ffffff;
    --text-primary: #333333;
    --text-secondary: #555555;
    --text-muted: #777777;
    --border-color: #eeeeee;
    --hover-bg: #f5f5f5;
    --bg-secondary: #f8f9fa;
    --shadow-color: rgba(0, 0, 0, 0.1);

    /* Estados */
    --success-color: #4caf50;
    --warning-color: #ff9800;
    --danger-color: #ef5350;
    --info-color: #2196f3;

    /* Transições */
    --transition-speed: 0.3s;
}

/* Tema Escuro */
body.dark-theme {
    --bg-body: #1a1a1a;
    --bg-card: #2d2d2d;
    --text-primary: #e0e0e0;
    --text-secondary: #b0b0b0;
    --text-muted: #808080;
    --border-color: #404040;
    --hover-bg: #3a3a3a;
    --bg-secondary: #333333;
    --shadow-color: rgba(0, 0, 0, 0.3);
}

/* ==================================================================================
   RESET E BASE
   ================================================================================== */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}


body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background-color: var(--bg-body);
    color: var(--text-primary);
    line-height: 1.6;
    transition: background-color var(--transition-speed), color var(--transition-speed);
}

/* ==================================================================================
   TIPOGRAFIA
   ================================================================================== */
h1,
h2,
h3,
h4,
h5,
h6 {
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 1rem;
}

h1 {
    font-size: 2.5rem;
}

h2 {
    font-size: 2rem;
}

h3 {
    font-size: 1.75rem;
}

h4 {
    font-size: 1.5rem;
}

h5 {
    font-size: 1.25rem;
}

h6 {
    font-size: 1rem;
}

p {
    margin-bottom: 1rem;
    color: var(--text-secondary);
}

a {
    color: var(--primary-orange);
    text-decoration: none;
    transition: color var(--transition-speed);
}

a:hover {
    color: var(--primary-orange-dark);
}

/* ==================================================================================
   LAYOUT - CONTAINERS
   ================================================================================== */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
}

.container-fluid {
    width: 100%;
    padding: 0 20px;
}

/* ==================================================================================
   CARDS
   ================================================================================== */
.card {
    background: var(--bg-card);
    border-radius: 12px;
    padding: 25px;
    box-shadow: 0 2px 10px var(--shadow-color);
    transition: transform var(--transition-speed), box-shadow var(--transition-speed);
    margin-bottom: 20px;
}

.card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 20px var(--shadow-color);
}

.card-header {
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 15px;
    margin-bottom: 20px;
}

.card-title {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-primary);
    margin: 0;
}

.card-body {
    padding: 0;
}

.card-footer {
    border-top: 1px solid var(--border-color);
    padding-top: 15px;
    margin-top: 20px;
}

/* ==================================================================================
   FORMULÁRIOS
   ================================================================================== */
.form-group {
    margin-bottom: 20px;
}

.form-label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    color: var(--text-primary);
    font-size: 0.9rem;
}

.form-control {
    width: 100%;
    padding: 12px 15px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    background-color: var(--bg-card);
    color: var(--text-primary);
    font-size: 1rem;
    transition: border-color var(--transition-speed), box-shadow var(--transition-speed);
}

.form-control:focus {
    outline: none;
    border-color: var(--primary-orange);
    box-shadow: 0 0 0 3px rgba(255, 109, 0, 0.1);
}

.form-control::placeholder {
    color: var(--text-muted);
}

.form-control:disabled {
    background-color: var(--hover-bg);
    cursor: not-allowed;
    opacity: 0.6;
}

select.form-control {
    cursor: pointer;
}

textarea.form-control {
    min-height: 100px;
    resize: vertical;
}

.form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 20px;
}

.form-row {
    display: flex;
    gap: 20px;
}

.form-row>* {
    flex: 1;
}

/* ==================================================================================
   BOTÕES
   ================================================================================== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 24px;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition-speed);
    text-decoration: none;
    white-space: nowrap;
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn-primary {
    background: var(--primary-orange);
    color: white;
}

.btn-primary:hover:not(:disabled) {
    background: var(--primary-orange-dark);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(255, 109, 0, 0.3);
}

.btn-secondary {
    background: #6c757d;
    color: white;
}

.btn-secondary:hover:not(:disabled) {
    background: #5a6268;
}

.btn-success {
    background: var(--success-color);
    color: white;
}

.btn-success:hover:not(:disabled) {
    background: #45a049;
}

.btn-warning {
    background: var(--warning-color);
    color: white;
}

.btn-warning:hover:not(:disabled) {
    background: #f57c00;
}

.btn-danger {
    background: var(--danger-color);
    color: white;
}

.btn-danger:hover:not(:disabled) {
    background: #e53935;
}

.btn-outline {
    background: transparent;
    border: 2px solid var(--primary-orange);
    color: var(--primary-orange);
}

.btn-outline:hover:not(:disabled) {
    background: var(--primary-orange);
    color: white;
}

.btn-sm {
    padding: 8px 16px;
    font-size: 0.875rem;
}

.btn-lg {
    padding: 16px 32px;
    font-size: 1.125rem;
}

.btn-block {
    width: 100%;
}

/* ==================================================================================
   TABELAS
   ================================================================================== */
.table-container {
    overflow-x: auto;
    margin: 20px 0;
}

.table {
    width: 100%;
    border-collapse: collapse;
    background: var(--bg-card);
    border-radius: 8px;
    overflow: hidden;
}

.table thead {
    background: var(--hover-bg);
}

.table th {
    padding: 15px;
    text-align: left;
    font-weight: 700;
    color: var(--text-primary);
    border-bottom: 2px solid var(--border-color);
}

.table td {
    padding: 15px;
    border-bottom: 1px solid var(--border-color);
    color: var(--text-secondary);
}

.table tbody tr {
    transition: background-color var(--transition-speed);
}

.table tbody tr:hover {
    background-color: var(--hover-bg);
}

.table tbody tr:last-child td {
    border-bottom: none;
}

/* ==================================================================================
   RESPONSIVE TABLE ENHANCEMENTS
   ================================================================================== */
/* Responsive Table Cells */
.table td,
.table th {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 200px;
}

.table td.col-actions,
.table th[style*="width:200px"],
.table th[style*="width:150px"],
.table th[style*="width:120px"] {
    width: 120px !important;
    min-width: 120px;
    max-width: 120px;
}

.table td.col-name,
.table td.col-company {
    max-width: 150px;
}

.table td.col-contact {
    max-width: 180px;
}

.table td.col-status,
.table td.col-origin {
    max-width: 120px;
}

/* Ensure table container respects viewport */
.table-container {
    max-width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

/* Prevent body overflow */
body,
.main-content {
    overflow-x: hidden;
    max-width: 100vw;
}

/* ==================================================================================
   BADGES E STATUS
   ================================================================================== */
.badge {
    display: inline-block;
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.badge-success {
    background: var(--success-color);
    color: white;
}

.badge-warning {
    background: var(--warning-color);
    color: white;
}

.badge-danger {
    background: var(--danger-color);
    color: white;
}

.badge-info {
    background: var(--info-color);
    color: white;
}

.badge-secondary {
    background: #6c757d;
    color: white;
}

.status-online {
    background-color: var(--success-color);
    box-shadow: 0 0 5px var(--success-color);
}

.status-pending {
    background-color: var(--warning-color);
}

.status-offline {
    background-color: #9e9e9e;
}

/* ==================================================================================
   MODAIS
   ================================================================================== */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    opacity: 0;
    visibility: hidden;
    transition: opacity var(--transition-speed), visibility var(--transition-speed);
}

.modal-overlay.active {
    opacity: 1;
    visibility: visible;
}

.modal {
    background: var(--bg-card);
    border-radius: 12px;
    padding: 30px;
    max-width: 600px;
    width: 90%;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
    transform: scale(0.9);
    transition: transform var(--transition-speed);
}

.modal-overlay.active .modal {
    transform: scale(1);
}

/* Modais standalone (sem overlay) - usados via JavaScript */
.modal[style*="display: flex"],
.modal[style*="display:flex"],
.modal-overlay[style*="display: flex"],
.modal-overlay[style*="display:flex"] {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    width: 100% !important;
    height: 100% !important;
    max-width: none !important;
    max-height: none !important;
    background: rgba(0, 0, 0, 0.6) !important;
    z-index: 9999 !important;
    padding: 0 !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    opacity: 1 !important;
    visibility: visible !important;
    transform: none !important;
}

.modal[style*="display: flex"]>*,
.modal[style*="display:flex"]>*,
.modal-overlay[style*="display: flex"]>*,
.modal-overlay[style*="display:flex"]>* {
    background: var(--bg-card);
    border-radius: 12px;
    padding: 30px;
    max-width: 600px;
    width: 90%;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding-bottom: 15px;
    border-bottom: 1px solid var(--border-color);
}

.modal-title {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-primary);
    margin: 0;
}

.modal-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    color: var(--text-muted);
    cursor: pointer;
    padding: 0;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: background-color var(--transition-speed), color var(--transition-speed);
}

.modal-close:hover {
    background-color: var(--hover-bg);
    color: var(--text-primary);
}

.modal-body {
    margin-bottom: 20px;
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    border-top: 1px solid var(--border-color);
}

/* SweetAlert overrides for better button spacing */
.swal2-actions {
    display: flex !important;
    flex-wrap: wrap !important;
    gap: 15px !important;
    width: 100%;
    justify-content: center;
}

.swal2-actions button {
    margin: 0 !important;
    /* Reset default margins to use gap */
}

/* ==================================================================================
   ALERTAS E NOTIFICAÇÕES
   ================================================================================== */
.alert {
    padding: 15px 20px;
    border-radius: 8px;
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    gap: 12px;
}

.alert i {
    font-size: 1.25rem;
}

.alert-success {
    background: #e8f5e9;
    color: #2e7d32;
    border-left: 4px solid var(--success-color);
}

.alert-warning {
    background: #fff3e0;
    color: #e65100;
    border-left: 4px solid var(--warning-color);
}

.alert-danger {
    background: #ffebee;
    color: #c62828;
    border-left: 4px solid var(--danger-color);
}

.alert-info {
    background: #e3f2fd;
    color: #1565c0;
    border-left: 4px solid var(--info-color);
}

/* Toast Notifications */
.toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 10000;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.toast {
    background: var(--bg-card);
    padding: 15px 20px;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    min-width: 300px;
    display: flex;
    align-items: center;
    gap: 12px;
    animation: slideInRight 0.3s ease;
}

.toast.success {
    border-left: 4px solid var(--success-color);
}

.toast.warning {
    border-left: 4px solid var(--warning-color);
}

.toast.error {
    border-left: 4px solid var(--danger-color);
}

.toast.info {
    border-left: 4px solid var(--info-color);
}

@keyframes slideInRight {
    from {
        transform: translateX(400px);
        opacity: 0;
    }

    to {
        transform: translateX(0);
        opacity: 1;
    }
}

/* ==================================================================================
   LOADING SPINNER
   ================================================================================== */
.spinner {
    border: 3px solid var(--border-color);
    border-top: 3px solid var(--primary-orange);
    border-radius: 50%;
    width: 40px;
    height: 40px;
    animation: spin 1s linear infinite;
}

.spinner-sm {
    width: 20px;
    height: 20px;
    border-width: 2px;
}

@keyframes spin {
    0% {
        transform: rotate(0deg);
    }

    100% {
        transform: rotate(360deg);
    }
}

.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9998;
}

/* ==================================================================================
   UTILITÁRIOS
   ================================================================================== */
.text-center {
    text-align: center;
}

.text-left {
    text-align: left;
}

.text-right {
    text-align: right;
}

.text-primary {
    color: var(--primary-orange) !important;
}

.text-success {
    color: var(--success-color) !important;
}

.text-warning {
    color: var(--warning-color) !important;
}

.text-danger {
    color: var(--danger-color) !important;
}

.text-muted {
    color: var(--text-muted) !important;
}

.bg-primary {
    background-color: var(--primary-orange) !important;
}

.bg-success {
    background-color: var(--success-color) !important;
}

.bg-warning {
    background-color: var(--warning-color) !important;
}

.bg-danger {
    background-color: var(--danger-color) !important;
}

.mt-0 {
    margin-top: 0 !important;
}

.mt-1 {
    margin-top: 0.5rem !important;
}

.mt-2 {
    margin-top: 1rem !important;
}

.mt-3 {
    margin-top: 1.5rem !important;
}

.mt-4 {
    margin-top: 2rem !important;
}

.mb-0 {
    margin-bottom: 0 !important;
}

.mb-1 {
    margin-bottom: 0.5rem !important;
}

.mb-2 {
    margin-bottom: 1rem !important;
}

.mb-3 {
    margin-bottom: 1.5rem !important;
}

.mb-4 {
    margin-bottom: 2rem !important;
}

.p-0 {
    padding: 0 !important;
}

.p-1 {
    padding: 0.5rem !important;
}

.p-2 {
    padding: 1rem !important;
}

.p-3 {
    padding: 1.5rem !important;
}

.p-4 {
    padding: 2rem !important;
}

.d-none {
    display: none !important;
}

.d-block {
    display: block !important;
}

.d-flex {
    display: flex !important;
}

.d-grid {
    display: grid !important;
}

.flex-column {
    flex-direction: column !important;
}

.flex-wrap {
    flex-wrap: wrap !important;
}

.align-center {
    align-items: center !important;
}

.justify-center {
    justify-content: center !important;
}

.justify-between {
    justify-content: space-between !important;
}

.gap-1 {
    gap: 0.5rem !important;
}

.gap-2 {
    gap: 1rem !important;
}

.gap-3 {
    gap: 1.5rem !important;
}

.w-100 {
    width: 100% !important;
}

.h-100 {
    height: 100% !important;
}

.rounded {
    border-radius: 8px !important;
}

.rounded-full {
    border-radius: 50% !important;
}

.shadow {
    box-shadow: 0 2px 10px var(--shadow-color) !important;
}

.shadow-lg {
    box-shadow: 0 10px 40px var(--shadow-color) !important;
}

/* ==================================================================================
   ANIMAÇÕES
   ================================================================================== */
@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.fade-in {
    animation: fadeIn 0.3s ease;
}

.slide-down {
    animation: slideDown 0.3s ease;
}

/* ==================================================================================
   RESPONSIVIDADE
   ================================================================================== */
@media (max-width: 768px) {
    h1 {
        font-size: 2rem;
    }

    h2 {
        font-size: 1.75rem;
    }

    h3 {
        font-size: 1.5rem;
    }

    .form-grid {
        grid-template-columns: 1fr;
    }

    .form-row {
        flex-direction: column;
    }

    .modal {
        width: 95%;
        padding: 20px;
    }

    .toast-container {
        right: 10px;
        left: 10px;
    }

    .toast {
        min-width: auto;
    }

    .btn {
        padding: 10px 20px;
        font-size: 0.9rem;
    }
}

@media (max-width: 480px) {
    .card {
        padding: 15px;
    }

    .table th,
    .table td {
        padding: 10px;
        font-size: 0.875rem;
    }
}

/* Print Styles */
@media print {

    /* Hide non-essential elements */
    .sidebar,
    aside,
    .navbar,
    .btn,
    button,
    .no-print,
    .btn-action,
    .btn-secondary,
    .btn-primary,
    .btn-warning,
    .modal,
    .toast-container,
    #overlaySidebar,
    #swal2-container,
    .mobile-toggle,
    .desktop-toggle {
        display: none !important;
    }

    /* Reset Layout */
    body.admin-body {
        display: block !important;
        /* Disable flex layout */
        background: white !important;
        color: black !important;
        height: auto !important;
        overflow: visible !important;
    }

    /* Content Full Width */
    .main-content {
        margin: 0 !important;
        padding: 0 !important;
        width: 100% !important;
        background: white !important;
        flex: none !important;
    }

    /* Reset Cards */
    .content-card {
        box-shadow: none !important;
        border: 1px solid #ccc !important;
        /* Light border for structure */
        margin-bottom: 20px !important;
        page-break-inside: avoid;
    }

    /* Text Colors */
    h2,
    h3,
    p,
    label,
    th,
    td {
        color: black !important;
    }

    /* Charts and Tables */
    canvas,
    table {
        page-break-inside: avoid;
    }
}

/* ==================================================================================
   COMPONENTES AUXILIARES (Toast / Loading)
   ================================================================================== */
.toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.toast {
    background: white;
    padding: 15px 20px;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    display: flex;
    align-items: center;
    gap: 12px;
    animation: slideInRight 0.3s ease;
    min-width: 300px;
    border-left: 4px solid #ccc;
    color: #333;
    font-weight: 500;
}

.toast.success {
    border-left-color: var(--success-color);
}

.toast.success i {
    color: var(--success-color);
}

.toast.error {
    border-left-color: var(--danger-color);
}

.toast.error i {
    color: var(--danger-color);
}

.toast.warning {
    border-left-color: var(--warning-color);
}

.toast.warning i {
    color: var(--warning-color);
}

.toast.info {
    border-left-color: var(--info-color);
}

.toast.info i {
    color: var(--info-color);
}

@keyframes slideInRight {
    from {
        transform: translateX(100%);
        opacity: 0;
    }

    to {
        transform: translateX(0);
        opacity: 1;
    }
}

.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 10000;
}

.spinner {
    width: 40px;
    height: 40px;
    border: 4px solid #fff;
    border-top: 4px solid var(--primary-orange);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% {
        transform: rotate(0deg);
    }

    100% {
        transform: rotate(360deg);
    }
}

/* Dark Mode Overrides for Toast */
body.dark-mode .toast {
    background: var(--bg-card);
    color: var(--text-primary);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
}

/* ==================================================================================
   LAYOUT & SIDEBAR (Unified for Admin & Client)
   ================================================================================== */
body.admin-body {
    background-color: var(--bg-body);
    color: var(--text-primary);
    display: flex;
    flex-direction: row;
    /* Desktop default */
    align-items: stretch;
    height: 100vh;
    overflow: hidden;
    margin: 0;
    transition: background-color 0.3s, color 0.3s;
}

.sidebar {
    width: 260px;
    background-color: var(--bg-card);
    box-shadow: 2px 0 5px var(--shadow-color);
    display: flex;
    flex-direction: column;
    z-index: 100;
    transition: width 0.3s ease, transform 0.3s ease, background-color 0.3s;
    height: 100vh;
    flex-shrink: 0;
    overflow-y: auto;
}

.sidebar.collapsed {
    width: 70px;
}

.sidebar-header {
    padding: 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid rgba(0, 0, 0, 0.05);
}

.sidebar.collapsed .sidebar-header {
    justify-content: center;
    padding: 20px 0;
}

.brand {
    font-family: 'Outfit', sans-serif;
    font-weight: 800;
    font-size: 28px;
    color: var(--primary-orange);
    text-transform: uppercase;
    white-space: nowrap;
}

.sidebar.collapsed .brand {
    display: none;
}

.menu {
    padding: 20px 0;
    flex: 1;
}

.menu-item {
    padding: 12px 20px;
    cursor: pointer;
    color: var(--text-secondary);
    font-size: 15px;
    display: flex;
    align-items: center;
    gap: 12px;
    transition: all 0.2s;
    border-left: 4px solid transparent;
    text-decoration: none;
}

.menu-item:hover {
    background-color: var(--hover-bg);
    color: var(--primary-orange);
}

.menu-item.active {
    background-color: var(--hover-bg);
    color: var(--primary-orange);
    border-left-color: var(--primary-orange);
    font-weight: 600;
}

.sidebar.collapsed .menu-item {
    justify-content: center;
    padding: 15px;
}

.sidebar.collapsed .menu-text,
.sidebar.collapsed .brand {
    display: none;
}

.desktop-toggle {
    background: none;
    border: none;
    color: var(--primary-orange);
    cursor: pointer;
    font-size: 20px;
}

.sidebar.collapsed .desktop-toggle {
    margin: 0 auto;
}

.sidebar-footer {
    padding: 20px;
    border-top: 1px solid var(--border-color);
}

/* Main Content Area */
.main-content,
.content {
    flex: 1;
    padding: 30px;
    overflow-y: auto;
    position: relative;
    background-color: var(--bg-body);
}

/* Mobile Toggles */
.mobile-toggle {
    display: none;
    /* Hidden on desktop */
    position: fixed;
    top: 15px;
    left: 15px;
    z-index: 1001;
    background: var(--primary-orange);
    color: white;
    border: none;
    padding: 10px;
    border-radius: 5px;
    cursor: pointer;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
}

.sidebar-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 99;
}

/* ==================================================================================
   LOGIN PAGE STYLES
   ================================================================================== */
body.login-page {
    background: linear-gradient(135deg, #ff6d00 0%, #ff9100 100%);
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.login-container {
    background: white;
    max-width: 480px;
    width: 100%;
    padding: 50px 40px;
    border-radius: 20px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
}

.login-tabs {
    display: flex;
    gap: 10px;
    margin-bottom: 30px;
}

.login-tab {
    flex: 1;
    padding: 14px;
    border-radius: 12px;
    border: 2px solid #e0e0e0;
    background: #fafafa;
    font-weight: 700;
    cursor: pointer;
    text-align: center;
    transition: all 0.3s ease;
    font-size: 14px;
    color: #666;
}

.login-tab.active {
    border-color: var(--primary-orange);
    background: #fff3e0;
    color: var(--primary-orange);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(255, 109, 0, 0.2);
}

/* Missing Login Styles Restored */
.logo {
    text-align: center;
    margin-bottom: 10px;
}

.logo h1 {
    font-family: 'Outfit', sans-serif;
    font-weight: 800;
    font-size: 32px;
    color: #FF6D00;
    text-transform: uppercase;
    letter-spacing: -1px;
    margin: 0;
}

.logo a {
    text-decoration: none;
    color: #FF6D00;
}

.subtitle {
    text-align: center;
    color: #666;
    margin-bottom: 35px;
    font-size: 15px;
}

.login-container .form-group {
    margin-bottom: 20px;
}

.login-container label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    color: #333;
    font-size: 14px;
}

.login-container .form-control {
    width: 100%;
    padding: 14px 16px;
    border-radius: 10px;
    border: 2px solid #e0e0e0;
    font-size: 15px;
    transition: all 0.3s ease;
    background: #fafafa;
    color: #333;
    box-sizing: border-box;
    /* Ensure padding doesn't overflow */
}

.login-container .form-control:focus {
    outline: none;
    border-color: #ff6d00;
    background: white;
    box-shadow: 0 0 0 4px rgba(255, 109, 0, 0.1);
}

.btn-login {
    width: 100%;
    padding: 16px;
    border: none;
    border-radius: 10px;
    background: #ff6d00;
    color: white;
    font-weight: bold;
    font-size: 16px;
    cursor: pointer;
    transition: all 0.3s ease;
    margin-top: 10px;
    box-shadow: 0 4px 15px rgba(255, 109, 0, 0.3);
}

.btn-login:hover {
    background: #e65100;
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(255, 109, 0, 0.4);
}

.btn-login:active {
    transform: translateY(0);
}

.error-message {
    margin-top: 15px;
    padding: 12px;
    border-radius: 8px;
    background: #ffebee;
    color: #c62828;
    font-size: 14px;
    display: none;
    border-left: 4px solid #c62828;
}

.links {
    display: flex;
    justify-content: space-between;
    margin-top: 25px;
    gap: 15px;
    flex-wrap: wrap;
}

.links a {
    color: #666;
    text-decoration: none;
    font-weight: 600;
    font-size: 14px;
    transition: color 0.3s;
}

.links a:hover {
    color: #ff6d00;
}

.links .btn-driver-register {
    display: inline-block;
    background-color: white;
    color: #ff6d00;
    padding: 10px 20px;
    border-radius: 8px;
    text-decoration: none;
    font-weight: bold;
    border: 2px solid #ff6d00;
    transition: ALL 0.3s;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.05);
}

.links .btn-driver-register:hover {
    background-color: #ff6d00;
    color: white;
    border-color: #ff6d00;
    transform: translateY(-2px);
    box-shadow: 0 6px 12px rgba(255, 109, 0, 0.3);
}

/* ==================================================================================
   DASHBOARD & KPI CARDS
   ================================================================================== */
.kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

.kpi-card {
    background: var(--bg-card);
    padding: 20px;
    border-radius: 10px;
    box-shadow: 0 2px 5px var(--shadow-color);
    display: flex;
    align-items: center;
    gap: 15px;
}

.kpi-icon {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    color: white;
}

.kpi-info h3 {
    font-size: 14px;
    color: var(--text-muted);
    margin-bottom: 5px;
    margin-top: 0;
}

.kpi-info p {
    font-size: 24px;
    font-weight: bold;
    color: var(--text-primary);
    margin: 0;
}

.content-card {
    background: var(--bg-card);
    border-radius: 10px;
    padding: 25px;
    margin-bottom: 30px;
    box-shadow: 0 2px 5px var(--shadow-color);
}

/* ==================================================================================
   RESPONSIVE & LAYOUT FIXES (Simplified)
   ================================================================================== */

/* 1. Global Fixes (Sidebar Bullets) */
.sidebar-menu {
    list-style: none;
    padding: 0;
    margin: 0;
}

/* Section View Visibility */
.section-view {
    display: none;
}

.section-view.active {
    display: block;
}

/* 2. Desktop/Default Defaults (Applied Globally) */
body.admin-body {
    flex-direction: row !important;
    display: flex !important;
    overflow-x: hidden;
    /* Prevent page-wide scrolling */
    width: 100vw;
}

.main-content {
    flex: 1;
    overflow-x: hidden;
    /* Prevent content expansion */
    max-width: 100%;
    /* Ensure it doesn't exceed flex container */
}

.sidebar {
    position: static;
    width: 260px;
    height: 100vh;
    transform: none !important;
    box-shadow: 2px 0 5px var(--shadow-color);
    display: flex;
    flex-direction: column;
}

/* Kanban Card Styles */
.kanban-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 15px;
    margin-bottom: 15px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
    cursor: grab;
    transition: transform 0.2s, box-shadow 0.2s, border-color 0.2s;
    position: relative;
    overflow: hidden;
}

.kanban-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
    border-color: var(--primary-orange);
}

.kanban-card h4 {
    margin: 0 0 8px 0;
    font-size: 1rem;
    color: var(--text-primary);
    font-weight: 600;
}

.kanban-card p {
    margin: 0 0 12px 0;
    font-size: 0.875rem;
    color: var(--text-secondary);
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
    text-overflow: ellipsis;
}

.kanban-card .card-footer {
    border-top: 1px solid var(--border-color);
    padding-top: 10px;
    margin-top: 10px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

/* Priority Indicators (Left Border) */
.kanban-card.prio-high {
    border-left: 4px solid var(--danger-color);
}

.kanban-card.prio-medium {
    border-left: 4px solid var(--warning-color);
}

.kanban-card.prio-low {
    border-left: 4px solid var(--success-color);
}

/* Kanban Column Separator */
.kanban-column {
    border-top: 4px solid var(--primary-orange);
    border-radius: 8px 8px 0 0;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    padding: 15px;
    background: var(--bg-secondary);
    /* Restore lost background */
    min-height: 500px;
    /* Restore lost height */
}

.kanban-title {
    font-size: 0.9rem;
    font-weight: 800;
    /* Extra Bold */
    color: var(--text-muted);
    margin-bottom: 15px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.task-count {
    /* Background set dynamically via JS */
    color: white;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 700;
    min-width: 24px;
    text-align: center;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.btn-delete-task {
    color: var(--text-secondary);
    transition: all 0.2s;
    cursor: pointer;
    padding: 4px;
    border-radius: 4px;
    margin-left: 10px;
}

.btn-delete-task:hover {
    color: var(--danger-color);
    background: rgba(244, 67, 54, 0.1);
}

.kanban-column:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 12px -2px rgba(255, 109, 0, 0.15);
}

/* Dark Mode Overrides */
body.dark-theme .kanban-card {
    background: #2d2d2d;
    /* Make sure it contrasts with column bg */
    border-color: #404040;
}

body.dark-theme .kanban-column {
    background: #1e1e1e !important;
    /* Ensure column is darker than card */
}

.kanban-board {
    display: flex;
    overflow-x: auto;
    gap: 15px;
}

/* Fix Table Overlap on Desktop */
.table th,
.table td {
    white-space: normal !important;
    /* Allow wrapping */
    vertical-align: middle;
    word-wrap: break-word;
    /* Break long words if needed */
    padding: 12px 15px !important;
    /* Add spacing */
}


/* Ensure flex headers allow wrapping but default to row */
.content-card>div[style*="display:flex"] {
    flex-direction: row !important;
    flex-wrap: wrap;
}

/* 3. Mobile Overrides (< 768px) - MUST BE LAST */
@media (max-width: 768px) {

    /* Mobile Layout */
    body.admin-body {
        flex-direction: column !important;
    }

    .sidebar {
        position: fixed;
        width: 260px;
        transform: translateX(-100%) !important;
        top: 0;
        bottom: 0;
        left: 0;
        z-index: 1000;
        box-shadow: 2px 0 10px rgba(0, 0, 0, 0.2);
    }

    .main-content,
    .content {
        padding: 15px !important;
        margin-left: 0 !important;
        width: 100%;
    }

    /* Tables */
    .table-responsive,
    .table-container {
        overflow-x: auto !important;
        display: block;
        margin-bottom: 20px;
    }

    .table th,
    .table td {
        white-space: nowrap;
    }

    /* Filters & Forms */
    input.form-control[style],
    select.form-control[style] {
        width: 100% !important;
        max-width: 100% !important;
        margin-bottom: 10px;
        height: 45px !important;
    }

    /* Headers turn to column on mobile */
    .content-card>div[style*="display:flex"],
    .section-view>div[style*="display:flex"],
    .main-content>div[style*="display:flex"] {
        flex-direction: column !important;
        align-items: stretch !important;
        gap: 15px !important;
    }

    .content-card button {
        width: 100%;
        margin-bottom: 5px;
    }

    /* Mobile Toggle */
    .mobile-toggle {
        display: block;
    }

    .desktop-toggle {
        display: none !important;
    }
}

/* ==================================================================================
   THEME BUTTONS (Standardized)
   ================================================================================== */
.theme-btn {
    padding: 10px 20px;
    border-radius: 8px;
    border: 1px solid var(--border-color);
    background-color: transparent;
    color: var(--text-secondary);
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: all 0.3s ease;
    font-family: 'Inter', sans-serif;
}

.theme-btn:hover {
    border-color: var(--primary-orange);
    color: var(--primary-orange);
}

.theme-btn.active {
    background-color: var(--primary-orange);
    color: white;
    border-color: var(--primary-orange);
    box-shadow: 0 4px 10px rgba(255, 109, 0, 0.3);
}

.theme-btn i {
    font-size: 16px;
}

/* ==================================================================================
   MULTI-STEP WIZARD (CADASTRO REDESIGN)
   ================================================================================== */
.wizard-container {
    max-width: 900px;
    margin: 40px auto;
    background: transparent;
}

/* Stepper Header */
.stepper-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 40px;
    position: relative;
    padding: 0 20px;
}

.stepper-line {
    position: absolute;
    top: 50%;
    left: 40px;
    right: 40px;
    height: 2px;
    background: #e0e0e0;
    z-index: 0;
    transform: translateY(-50%);
}

.step-item {
    position: relative;
    z-index: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    background: var(--bg-primary);
    /* Masks line behind */
    padding: 0 10px;
}

.step-circle {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: white;
    border: 2px solid #e0e0e0;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #999;
    font-weight: 700;
    transition: all 0.3s ease;
}

.step-item.active .step-circle {
    border-color: var(--primary-orange);
    color: var(--primary-orange);
    box-shadow: 0 0 0 4px rgba(255, 109, 0, 0.1);
}

.step-item.completed .step-circle {
    background: var(--primary-orange);
    border-color: var(--primary-orange);
    color: white;
}

.step-label {
    font-size: 0.85rem;
    color: #999;
    font-weight: 500;
}

.step-item.active .step-label,
.step-item.completed .step-label {
    color: var(--text-primary);
    font-weight: 700;
}

/* Wizard Cards */
.wizard-card {
    background: white;
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.05);
    padding: 40px;
    margin-bottom: 20px;
    border: 1px solid var(--border-color);
}

.step-content {
    display: none;
    animation: fadeIn 0.4s ease;
}

.step-content.active {
    display: block;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Upload Area (Special Style) */
.upload-hero {
    border: 2px dashed var(--border-color);
    border-radius: 12px;
    padding: 50px 20px;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s ease;
    background: #fafafa;
}

.upload-hero:hover {
    border-color: var(--primary-orange);
    background: rgba(255, 109, 0, 0.03);
}

.upload-icon {
    font-size: 48px;
    color: var(--primary-orange);
    margin-bottom: 20px;
}

.upload-title {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 10px;
}

.upload-subtitle {
    color: var(--text-secondary);
    max-width: 400px;
    margin: 0 auto;
}

/* Navigation Buttons */
.wizard-footer {
    display: flex;
    justify-content: space-between;
    margin-top: 30px;
    padding-top: 20px;
    border-top: 1px solid var(--border-color);
}

/* Dark Mode Overrides */
body.dark-theme .step-item {
    background: var(--bg-primary);
    /* Inherit dark bg */
}

body.dark-theme .wizard-card {
    background: #1e1e1e;
    border-color: #333;
}

body.dark-theme .upload-hero {
    background: #2d2d2d;
    border-color: #444;
}

body.dark-theme .step-circle {
    background: #2d2d2d;
    border-color: #444;
    color: #888;
}

body.dark-theme .upload-hero:hover {
    border-color: var(--primary-orange);
    background: rgba(255, 109, 0, 0.1);
}

/* Sidebar Collapse Logic - Agent Fix */
.sidebar.collapsed .sidebar-header .sidebar-logo,
.sidebar.collapsed .sidebar-header .brand {
    display: none !important;
}

.sidebar.collapsed .sidebar-header {
    justify-content: center !important;
    padding-left: 0 !important;
    padding-right: 0 !important;
}

.sidebar.collapsed .sidebar-header .desktop-toggle {
    margin: 0 auto !important;
}

.sidebar.collapsed .sidebar-header .desktop-toggle i {
    transform: scaleX(-1);
}

.sidebar .sidebar-header .desktop-toggle i {
    transition: transform 0.3s ease;
}