/* ===== Variables ===== */
:root {
    --sidebar-width: 260px;
    --sidebar-collapsed-width: 70px;
    --sidebar-bg: #1e293b;
    --sidebar-hover: #334155;
    --sidebar-active: #3b82f6;
    --navbar-height: 60px;
    --body-bg: #f1f5f9;
    --card-border-radius: 0.75rem;
    --primary: #3b82f6;
    --primary-dark: #2563eb;
}

/* ===== Reset ===== */
body {
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
    background-color: var(--body-bg);
    margin: 0;
    overflow-x: hidden;
}

/* ===== Sidebar ===== */
#sidebar {
    min-width: var(--sidebar-width);
    max-width: var(--sidebar-width);
    height: 100vh;
    background: var(--sidebar-bg);
    transition: all 0.3s ease;
    position: fixed;
    top: 0;
    left: 0;
    z-index: 1040;
    overflow-y: auto;
    overflow-x: hidden;
    padding-bottom: 2rem;
}

#sidebar::-webkit-scrollbar {
    width: 4px;
}

#sidebar::-webkit-scrollbar-thumb {
    background: rgba(255,255,255,0.15);
    border-radius: 4px;
}

#sidebar.collapsed {
    min-width: var(--sidebar-collapsed-width);
    max-width: var(--sidebar-collapsed-width);
}

#sidebar.collapsed .sidebar-header {
    justify-content: center;
    padding: 0.6rem !important;
}

#sidebar.collapsed .sidebar-header img {
    display: none;
}

#sidebar.collapsed .sidebar-header::after {
    content: '\F3DC';
    font-family: 'bootstrap-icons';
    color: white;
    font-size: 1.4rem;
}

#sidebar.collapsed .sidebar-section-title {
    display: none;
}

#sidebar.collapsed .nav-link {
    justify-content: center;
    padding: 0.7rem;
    margin: 2px 0.5rem;
    border-radius: 0.5rem;
    gap: 0;
}

#sidebar.collapsed .nav-link span {
    display: none;
}

#sidebar.collapsed .nav-link[title] {
    position: relative;
}

#sidebar.collapsed .nav-link:hover::after {
    content: attr(title);
    position: absolute;
    left: calc(100% + 8px);
    top: 50%;
    transform: translateY(-50%);
    background: #1e293b;
    color: white;
    padding: 0.3rem 0.7rem;
    border-radius: 0.375rem;
    font-size: 0.75rem;
    white-space: nowrap;
    z-index: 1050;
    box-shadow: 0 2px 8px rgba(0,0,0,0.2);
    pointer-events: none;
}

#sidebar.collapsed .nav-link i {
    font-size: 1.15rem;
    margin: 0;
    width: auto;
}

.sidebar-header {
    padding: 1.25rem 1.25rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    border-bottom: 1px solid rgba(255,255,255,0.08);
}

.sidebar-header .logo-icon {
    width: 38px;
    height: 38px;
    background: linear-gradient(135deg, var(--primary) 0%, #8b5cf6 100%);
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
    color: white;
    flex-shrink: 0;
}

.sidebar-header h5 {
    font-size: 1.05rem;
    font-weight: 700;
    letter-spacing: -0.3px;
    margin: 0;
    color: white;
}

.sidebar-section-title {
    font-size: 0.65rem;
    text-transform: uppercase;
    letter-spacing: 1.2px;
    color: rgba(255,255,255,0.35);
    padding: 1.25rem 1.25rem 0.5rem;
    font-weight: 600;
}

#sidebar .nav-link {
    padding: 0.6rem 1.25rem;
    border-radius: 0.5rem;
    margin: 1px 0.75rem;
    font-size: 0.95rem;
    font-weight: 450;
    color: rgba(255,255,255,0.65);
    transition: all 0.15s ease;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    white-space: nowrap;
}

#sidebar .nav-link i {
    font-size: 1.05rem;
    width: 20px;
    text-align: center;
    flex-shrink: 0;
}

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

#sidebar .nav-link.active {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    color: white;
    font-weight: 500;
    box-shadow: 0 2px 8px rgba(59, 130, 246, 0.3);
}

/* ===== Page Content ===== */
#page-content-wrapper {
    min-height: 100vh;
    margin-left: var(--sidebar-width);
    transition: margin-left 0.3s ease;
    background-color: var(--body-bg);
}

#sidebar.collapsed ~ #page-content-wrapper {
    margin-left: var(--sidebar-collapsed-width);
}

/* ===== Navbar ===== */
.top-navbar {
    height: auto;
    background: white;
    border-bottom: 1px solid #e2e8f0;
    display: flex;
    align-items: center;
    padding: 0.4rem 1.5rem;
    position: sticky;
    top: 0;
    z-index: 1030;
    box-shadow: 0 1px 3px rgba(0,0,0,0.04);
}

/* Sincronizar altura do navbar com o sidebar-header via JS */
.sidebar-header {
    padding: 0.4rem !important;
}

.top-navbar .btn-toggle {
    border: none;
    background: none;
    padding: 0.4rem 0.6rem;
    border-radius: 0.5rem;
    color: #64748b;
    font-size: 1.2rem;
    cursor: pointer;
    transition: all 0.15s;
}

.top-navbar .btn-toggle:hover {
    background: #f1f5f9;
    color: #1e293b;
}

.top-navbar .user-menu .btn {
    border: 1px solid #e2e8f0;
    border-radius: 0.5rem;
    padding: 0.4rem 0.9rem;
    font-size: 0.85rem;
    color: #475569;
    font-weight: 500;
    background: white;
    transition: all 0.15s;
}

.top-navbar .user-menu .btn:hover {
    background: #f8fafc;
    border-color: #cbd5e1;
}

.top-navbar .user-avatar {
    width: 32px;
    height: 32px;
    background: linear-gradient(135deg, var(--primary) 0%, #8b5cf6 100%);
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 0.8rem;
    font-weight: 600;
    margin-right: 0.5rem;
}

/* ===== Main Content ===== */
main.container-fluid {
    padding: 1.5rem 2rem !important;
    max-width: 100%;
}

/* ===== Cards ===== */
.card {
    border: 1px solid #e2e8f0;
    border-radius: var(--card-border-radius);
    box-shadow: 0 1px 3px rgba(0,0,0,0.04);
    transition: box-shadow 0.15s;
}

.card:hover {
    box-shadow: 0 4px 12px rgba(0,0,0,0.06);
}

.card-header {
    background-color: white;
    border-bottom: 1px solid #f1f5f9;
    padding: 1rem 1.25rem;
    font-weight: 600;
    font-size: 0.9rem;
}

.card-body {
    padding: 1.25rem;
}

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

.kpi-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 25px rgba(0,0,0,0.12);
}

.kpi-card .card-body {
    padding: 1.5rem;
}

.kpi-card .kpi-value {
    font-size: 1.75rem;
    font-weight: 700;
    letter-spacing: -0.5px;
}

.kpi-card .kpi-label {
    font-size: 0.8rem;
    opacity: 0.8;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-weight: 500;
}

.kpi-card .kpi-icon {
    font-size: 2.5rem;
    opacity: 0.3;
}

/* ===== Tables ===== */
.table {
    margin-bottom: 0;
}

.table th {
    font-size: 0.75rem;
    text-transform: uppercase;
    color: #64748b;
    font-weight: 600;
    letter-spacing: 0.5px;
    padding: 0.875rem 1rem;
    border-bottom: 2px solid #e2e8f0;
    white-space: nowrap;
}

.table td {
    vertical-align: middle;
    padding: 0.75rem 1rem;
    color: #334155;
    font-size: 0.875rem;
    border-bottom: 1px solid #f1f5f9;
}

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

.table-responsive {
    border-radius: var(--card-border-radius);
}

/* ===== Badges ===== */
.badge {
    font-weight: 500;
    padding: 0.4em 0.75em;
    border-radius: 0.375rem;
    font-size: 0.75rem;
    letter-spacing: 0.2px;
}

/* ===== Buttons ===== */
.btn {
    border-radius: 0.5rem;
    font-weight: 500;
    font-size: 0.875rem;
    padding: 0.45rem 1rem;
    transition: all 0.15s;
}

.btn-primary {
    background: var(--primary);
    border-color: var(--primary);
}

.btn-primary:hover {
    background: var(--primary-dark);
    border-color: var(--primary-dark);
    box-shadow: 0 2px 8px rgba(59, 130, 246, 0.35);
}

.btn-sm {
    padding: 0.3rem 0.7rem;
    font-size: 0.8rem;
}

.btn-outline-primary {
    color: var(--primary);
    border-color: var(--primary);
}

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

/* ===== Forms ===== */
.form-control, .form-select {
    border-radius: 0.5rem;
    border: 1px solid #cbd5e1;
    padding: 0.5rem 0.85rem;
    font-size: 0.875rem;
    transition: border-color 0.15s, box-shadow 0.15s;
}

.form-control:focus, .form-select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
}

.form-label {
    font-size: 0.85rem;
    font-weight: 500;
    color: #374151;
    margin-bottom: 0.35rem;
}

/* ===== Page Header ===== */
.page-header {
    margin-bottom: 1.5rem;
}

.page-header h2, .page-header h4 {
    font-weight: 700;
    color: #1e293b;
    letter-spacing: -0.3px;
}

/* ===== Kanban ===== */
.kanban-column {
    min-height: 400px;
    background-color: #f8fafc;
    border-radius: var(--card-border-radius);
    padding: 1rem;
    border: 1px dashed #e2e8f0;
}

.kanban-card {
    background: white;
    border-radius: 0.5rem;
    padding: 0.875rem;
    margin-bottom: 0.5rem;
    border-left: 3px solid var(--primary);
    box-shadow: 0 1px 3px rgba(0,0,0,0.06);
    cursor: grab;
    transition: box-shadow 0.15s;
}

.kanban-card:hover {
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}

.kanban-card.prioridade-alta { border-left-color: #ef4444; }
.kanban-card.prioridade-urgente { border-left-color: #a855f7; }
.kanban-card.prioridade-media { border-left-color: #f59e0b; }
.kanban-card.prioridade-baixa { border-left-color: #22c55e; }

/* ===== Auth Pages ===== */
.auth-card {
    width: 100%;
    max-width: 440px;
    border: none;
    border-radius: 1rem;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.2);
}

/* ===== Alerts ===== */
.alert {
    border-radius: 0.5rem;
    border: none;
    font-size: 0.875rem;
}

/* ===== Pagination ===== */
.pagination .page-link {
    border-radius: 0.375rem;
    margin: 0 2px;
    font-size: 0.85rem;
    color: #475569;
    border: 1px solid #e2e8f0;
    padding: 0.375rem 0.75rem;
}

.pagination .page-item.active .page-link {
    background-color: var(--primary);
    border-color: var(--primary);
}

/* ===== Dropdown ===== */
.dropdown-menu {
    border: 1px solid #e2e8f0;
    border-radius: 0.5rem;
    box-shadow: 0 10px 30px rgba(0,0,0,0.1);
    padding: 0.4rem;
    font-size: 0.875rem;
}

.dropdown-item {
    border-radius: 0.375rem;
    padding: 0.5rem 0.75rem;
}

/* ===== Map ===== */
.leaflet-container {
    border-radius: var(--card-border-radius);
}

/* ===== Calendar ===== */
.fc .fc-button-primary {
    background-color: var(--primary);
    border-color: var(--primary);
}

/* ===== Quill Editor ===== */
.ql-editor {
    min-height: 200px;
}

/* ===== Breadcrumb ===== */
.breadcrumb {
    font-size: 0.8rem;
    margin-bottom: 0;
}

/* ===== Empty state ===== */
.text-muted {
    color: #94a3b8 !important;
}

/* ===== Responsive ===== */
@media (max-width: 992px) {
    #sidebar {
        min-width: 0;
        max-width: 0;
        padding: 0;
    }

    #sidebar.show {
        min-width: var(--sidebar-width);
        max-width: var(--sidebar-width);
        box-shadow: 5px 0 25px rgba(0,0,0,0.2);
    }

    #page-content-wrapper {
        margin-left: 0;
    }

    main.container-fluid {
        padding: 1rem !important;
    }
}

/* ===== Sidebar overlay on mobile ===== */
.sidebar-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.4);
    z-index: 1035;
}

#sidebar.show ~ .sidebar-overlay {
    display: block;
}

/* ===== Scrollbar global ===== */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: #94a3b8;
}
