/**
 * FluxosPHP - Estilos CSS
 * Layout Responsivo Mobile-First
 */

/* ========================================
   Page Header & Actions
======================================== */
.page-header {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
    gap: 1rem;
}

.page-header .page-title {
    flex: 1;
}

.page-header .page-title h1 {
    font-size: 1.5rem;
    margin: 0;
    color: var(--gray-800);
}

.page-header .page-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.page-header .page-actions .btn {
    white-space: nowrap;
}

@media (max-width: 768px) {
    .page-header {
        flex-direction: column;
        align-items: stretch;
    }
    
    .page-header .page-actions {
        justify-content: flex-start;
    }
}

/* ========================================
   Breadcrumb
======================================== */
.breadcrumb {
    display: flex;
    flex-wrap: wrap;
    padding: 0;
    margin-bottom: 1rem;
    list-style: none;
    background-color: transparent;
}

.breadcrumb-item {
    display: flex;
    align-items: center;
}

.breadcrumb-item + .breadcrumb-item {
    padding-left: 0.5rem;
}

.breadcrumb-item + .breadcrumb-item::before {
    display: inline-block;
    padding-right: 0.5rem;
    color: var(--gray-500);
    content: "/";
}

.breadcrumb-item a {
    color: var(--primary);
    text-decoration: none;
}

.breadcrumb-item a:hover {
    text-decoration: underline;
}

.breadcrumb-item.active {
    color: var(--gray-600);
}

/* ========================================
   Card Hover Effects
======================================== */
.card-hover {
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.card-hover:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow-lg);
}

/* Download Category Cards */
.card.shadow-sm:hover {
    transform: translateY(-5px);
    box-shadow: 0 8px 25px rgba(0,0,0,0.15) !important;
}

/* ========================================
   List Group Improvements
======================================== */
.list-group-item.active {
    background-color: var(--primary);
    border-color: var(--primary);
}

.list-group-item-action:hover {
    background-color: var(--gray-100);
}

/* ========================================
   CSS Variables
======================================== */
:root {
    --primary: #2B579A;
    --primary-dark: #1e3d6f;
    --primary-light: #4a7cc9;
    --secondary: #6c757d;
    --success: #28a745;
    --danger: #dc3545;
    --warning: #ffc107;
    --info: #17a2b8;
    --light: #f8f9fa;
    --dark: #343a40;
    --white: #ffffff;
    --gray-100: #f8f9fa;
    --gray-200: #e9ecef;
    --gray-300: #dee2e6;
    --gray-400: #ced4da;
    --gray-500: #adb5bd;
    --gray-600: #6c757d;
    --gray-700: #495057;
    --gray-800: #343a40;
    --gray-900: #212529;
    
    --sidebar-width: 260px;
    --sidebar-collapsed: 70px;
    --topbar-height: 60px;
    --border-radius: 8px;
    --shadow: 0 2px 10px rgba(0,0,0,0.1);
    --shadow-lg: 0 5px 25px rgba(0,0,0,0.15);
    --transition: all 0.3s ease;
}

/* ========================================
   Reset & Base
======================================== */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    font-size: 16px;
    scroll-behavior: smooth;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    font-size: 0.938rem;
    line-height: 1.6;
    color: var(--gray-800);
    background: var(--gray-100);
    min-height: 100vh;
}

a {
    color: var(--primary);
    text-decoration: none;
    transition: var(--transition);
}

a:hover {
    color: var(--primary-dark);
}

img {
    max-width: 100%;
    height: auto;
}

/* ========================================
   Typography
======================================== */
h1, h2, h3, h4, h5, h6 {
    font-weight: 600;
    line-height: 1.3;
    margin-bottom: 0.5rem;
    color: var(--gray-800);
}

h1 { font-size: 1.75rem; }
h2 { font-size: 1.5rem; }
h3 { font-size: 1.25rem; }
h4 { font-size: 1.125rem; }
h5 { font-size: 1rem; }
h6 { font-size: 0.875rem; }

p { margin-bottom: 1rem; }

.text-primary { color: var(--primary) !important; }
.text-success { color: var(--success) !important; }
.text-danger { color: var(--danger) !important; }
.text-warning { color: var(--warning) !important; }
.text-info { color: var(--info) !important; }
.text-muted { color: var(--gray-600) !important; }
.text-center { text-align: center; }
.text-right { text-align: right; }

/* ========================================
   Layout - Sidebar
======================================== */
.sidebar {
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    width: var(--sidebar-width);
    background: linear-gradient(180deg, var(--primary) 0%, var(--primary-dark) 100%);
    color: var(--white);
    z-index: 1000;
    display: flex;
    flex-direction: column;
    transition: var(--transition);
    box-shadow: var(--shadow-lg);
}

.sidebar-header {
    padding: 1.25rem;
    border-bottom: 1px solid rgba(255,255,255,0.1);
}

.sidebar-logo {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    color: var(--white);
    font-size: 1.25rem;
    font-weight: 700;
}

.sidebar-logo i {
    font-size: 1.5rem;
}

.sidebar-nav {
    flex: 1;
    overflow-y: auto;
    padding: 1rem 0;
}

.nav-list {
    list-style: none;
}

.nav-item {
    margin: 0.25rem 0.75rem;
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    color: rgba(255,255,255,0.8);
    border-radius: var(--border-radius);
    transition: var(--transition);
}

.nav-link:hover {
    background: rgba(255,255,255,0.1);
    color: var(--white);
}

.nav-item.active .nav-link {
    background: rgba(255,255,255,0.2);
    color: var(--white);
}

.nav-link i {
    width: 20px;
    text-align: center;
}

.nav-badge {
    margin-left: auto;
    background: var(--danger);
    color: var(--white);
    font-size: 0.75rem;
    padding: 0.125rem 0.5rem;
    border-radius: 10px;
}

/* Submenu Styles */
.nav-item.has-submenu .nav-link {
    justify-content: flex-start;
}

.submenu-arrow {
    margin-left: auto;
    font-size: 0.75rem;
    transition: transform 0.3s ease;
}

.nav-item.has-submenu.open .submenu-arrow {
    transform: rotate(180deg);
}

.submenu {
    display: none;
    list-style: none;
    padding: 0;
    margin: 0;
    background: rgba(0,0,0,0.15);
    border-radius: var(--border-radius);
    margin-top: 0.25rem;
    overflow: hidden;
}

.submenu-item {
    margin: 0;
}

.submenu-link {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.6rem 1rem 0.6rem 2.5rem;
    color: rgba(255,255,255,0.7);
    font-size: 0.875rem;
    transition: var(--transition);
}

.submenu-link:hover {
    background: rgba(255,255,255,0.1);
    color: var(--white);
}

.submenu-item.active .submenu-link {
    background: rgba(255,255,255,0.15);
    color: var(--white);
}

.submenu-link i {
    width: 18px;
    text-align: center;
    font-size: 0.85rem;
}

.sidebar-footer {
    padding: 1rem;
    border-top: 1px solid rgba(255,255,255,0.1);
}

.user-info {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.user-avatar-small {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: rgba(255,255,255,0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    overflow: hidden;
}

.user-avatar-small img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.user-details {
    display: flex;
    flex-direction: column;
}

.user-name-small {
    font-weight: 600;
    font-size: 0.875rem;
}

.user-role {
    font-size: 0.75rem;
    opacity: 0.8;
}

/* ========================================
   Layout - Main Content
======================================== */
.main-content {
    margin-left: var(--sidebar-width);
    min-height: 100vh;
    transition: var(--transition);
}

.topbar {
    position: sticky;
    top: 0;
    height: var(--topbar-height);
    background: var(--white);
    border-bottom: 1px solid var(--gray-200);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 1.5rem;
    z-index: 100;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}

.page-title {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--gray-800);
}

.topbar-right {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.topbar-item {
    position: relative;
}

.topbar-btn {
    background: none;
    border: none;
    padding: 0.5rem;
    cursor: pointer;
    color: var(--gray-600);
    border-radius: var(--border-radius);
    transition: var(--transition);
    position: relative;
}

.topbar-btn:hover {
    background: var(--gray-100);
    color: var(--gray-800);
}

.topbar-btn .badge {
    position: absolute;
    top: 0;
    right: 0;
    background: var(--danger);
    color: var(--white);
    font-size: 0.625rem;
    padding: 0.125rem 0.375rem;
    border-radius: 10px;
    min-width: 18px;
    text-align: center;
}

.user-btn {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.375rem 0.75rem;
}

.user-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--primary);
    color: var(--white);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    overflow: hidden;
}

.user-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.user-name {
    font-weight: 500;
    color: var(--gray-700);
}

/* Dropdown Menus */
.dropdown-menu {
    position: absolute;
    top: 100%;
    right: 0;
    background: var(--white);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-lg);
    min-width: 200px;
    padding: 0.5rem 0;
    display: none;
    z-index: 1001;
    border: 1px solid var(--gray-200);
}

.dropdown-menu.show {
    display: block;
    animation: fadeIn 0.2s ease;
}

.notifications-menu {
    width: 320px;
    max-height: 400px;
    overflow-y: auto;
}

.user-menu {
    min-width: 220px;
}

.dropdown-header {
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--gray-200);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.dropdown-header strong {
    display: block;
}

.dropdown-header small {
    color: var(--gray-500);
    font-size: 0.75rem;
}

.dropdown-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.625rem 1rem;
    color: var(--gray-700);
    transition: var(--transition);
}

.dropdown-item:hover {
    background: var(--gray-100);
    color: var(--gray-900);
}

.dropdown-item i {
    width: 16px;
    text-align: center;
    color: var(--gray-500);
}

.dropdown-divider {
    height: 1px;
    background: var(--gray-200);
    margin: 0.5rem 0;
}

/* Page Content */
.page-content {
    padding: 1.5rem;
}

/* ========================================
   Cards
======================================== */
.card {
    background: var(--white);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow);
    margin-bottom: 1.5rem;
}

.card-header {
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--gray-200);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.card-title {
    font-size: 1rem;
    font-weight: 600;
    margin: 0;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.card-body {
    padding: 1.25rem;
}

.card-footer {
    padding: 1rem 1.25rem;
    border-top: 1px solid var(--gray-200);
    background: var(--gray-50);
}

/* ========================================
   Buttons
======================================== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
    font-weight: 500;
    border-radius: var(--border-radius);
    border: none;
    cursor: pointer;
    transition: var(--transition);
    text-decoration: none;
}

.btn-sm {
    padding: 0.375rem 0.75rem;
    font-size: 0.813rem;
}

.btn-lg {
    padding: 0.75rem 1.5rem;
    font-size: 1rem;
}

.btn-primary {
    background: var(--primary);
    color: var(--white);
}

.btn-primary:hover {
    background: var(--primary-dark);
    color: var(--white);
}

.btn-secondary {
    background: var(--gray-600);
    color: var(--white);
}

.btn-secondary:hover {
    background: var(--gray-700);
    color: var(--white);
}

.btn-success {
    background: var(--success);
    color: var(--white);
}

.btn-success:hover {
    background: #218838;
    color: var(--white);
}

.btn-danger {
    background: var(--danger);
    color: var(--white);
}

.btn-danger:hover {
    background: #c82333;
    color: var(--white);
}

.btn-warning {
    background: var(--warning);
    color: var(--dark);
}

.btn-info {
    background: var(--info);
    color: var(--white);
}

.btn-outline-primary {
    background: transparent;
    color: var(--primary);
    border: 1px solid var(--primary);
}

.btn-outline-primary:hover {
    background: var(--primary);
    color: var(--white);
}

.btn-outline-secondary {
    background: transparent;
    color: var(--gray-600);
    border: 1px solid var(--gray-400);
}

.btn-outline-secondary:hover {
    background: var(--gray-200);
    color: var(--gray-800);
}

.btn-group {
    display: inline-flex;
    gap: 0.5rem;
}

/* ========================================
   Forms
======================================== */
.form-group {
    margin-bottom: 1rem;
}

.form-label {
    display: block;
    margin-bottom: 0.375rem;
    font-weight: 500;
    color: var(--gray-700);
}

.form-label.required::after {
    content: ' *';
    color: var(--danger);
}

.form-control {
    display: block;
    width: 100%;
    padding: 0.5rem 0.75rem;
    font-size: 0.938rem;
    line-height: 1.5;
    color: var(--gray-700);
    background: var(--white);
    border: 1px solid var(--gray-300);
    border-radius: var(--border-radius);
    transition: var(--transition);
}

.form-control:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(43, 87, 154, 0.15);
}

.form-control:disabled,
.form-control[readonly] {
    background: var(--gray-100);
    cursor: not-allowed;
}

.form-control.is-invalid {
    border-color: var(--danger);
}

.invalid-feedback {
    color: var(--danger);
    font-size: 0.813rem;
    margin-top: 0.25rem;
}

textarea.form-control {
    min-height: 100px;
    resize: vertical;
}

.form-select {
    appearance: none;
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3e%3cpath fill='none' stroke='%23343a40' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='m2 5 6 6 6-6'/%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: right 0.75rem center;
    background-size: 16px 12px;
    padding-right: 2.5rem;
}

.form-check {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
}

.form-check-input {
    width: 1rem;
    height: 1rem;
    margin: 0;
    cursor: pointer;
}

.form-check-label {
    cursor: pointer;
}

.form-row {
    display: grid;
    gap: 1rem;
}

.form-row-2 {
    grid-template-columns: repeat(2, 1fr);
}

.form-row-3 {
    grid-template-columns: repeat(3, 1fr);
}

.form-row-4 {
    grid-template-columns: repeat(4, 1fr);
}

.form-text {
    font-size: 0.813rem;
    color: var(--gray-600);
    margin-top: 0.25rem;
}

/* ========================================
   Tables
======================================== */
.table-responsive {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.875rem;
}

.table th,
.table td {
    padding: 0.75rem 1rem;
    text-align: left;
    vertical-align: middle;
    border-bottom: 1px solid var(--gray-200);
}

.table th {
    font-weight: 600;
    color: var(--gray-600);
    background: var(--gray-50);
    text-transform: uppercase;
    font-size: 0.75rem;
    letter-spacing: 0.5px;
}

.table tbody tr:hover {
    background: var(--gray-50);
}

.table-striped tbody tr:nth-child(odd) {
    background: var(--gray-50);
}

.table-actions {
    display: flex;
    gap: 0.5rem;
    justify-content: flex-end;
}

/* ========================================
   Badges & Status
======================================== */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.25rem 0.625rem;
    font-size: 0.75rem;
    font-weight: 500;
    border-radius: 20px;
    line-height: 1.4;
}

.badge-primary { background: rgba(43, 87, 154, 0.15); color: var(--primary); }
.badge-success { background: rgba(40, 167, 69, 0.15); color: var(--success); }
.badge-danger { background: rgba(220, 53, 69, 0.15); color: var(--danger); }
.badge-warning { background: rgba(255, 193, 7, 0.25); color: #856404; }
.badge-info { background: rgba(23, 162, 184, 0.15); color: var(--info); }
.badge-secondary { background: rgba(108, 117, 125, 0.15); color: var(--secondary); }

.status-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    padding: 0.375rem 0.75rem;
    font-size: 0.75rem;
    font-weight: 600;
    border-radius: 20px;
    text-transform: uppercase;
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
}

/* ========================================
   Alerts
======================================== */
.alert {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 1rem 1.25rem;
    border-radius: var(--border-radius);
    margin-bottom: 1rem;
}

.alert-success {
    background: rgba(40, 167, 69, 0.1);
    color: #155724;
    border-left: 4px solid var(--success);
}

.alert-error,
.alert-danger {
    background: rgba(220, 53, 69, 0.1);
    color: #721c24;
    border-left: 4px solid var(--danger);
}

.alert-warning {
    background: rgba(255, 193, 7, 0.15);
    color: #856404;
    border-left: 4px solid var(--warning);
}

.alert-info {
    background: rgba(23, 162, 184, 0.1);
    color: #0c5460;
    border-left: 4px solid var(--info);
}

.alert-close {
    margin-left: auto;
    background: none;
    border: none;
    cursor: pointer;
    color: inherit;
    opacity: 0.6;
}

.alert-close:hover {
    opacity: 1;
}

/* ========================================
   Pagination
======================================== */
.pagination-nav {
    display: flex;
    justify-content: center;
    margin-top: 1.5rem;
}

.pagination {
    display: flex;
    list-style: none;
    gap: 0.25rem;
}

.pagination li a,
.pagination li span {
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 36px;
    height: 36px;
    padding: 0 0.5rem;
    border-radius: var(--border-radius);
    background: var(--white);
    color: var(--gray-700);
    border: 1px solid var(--gray-300);
    transition: var(--transition);
}

.pagination li a:hover {
    background: var(--gray-100);
    border-color: var(--gray-400);
}

.pagination li.active a {
    background: var(--primary);
    border-color: var(--primary);
    color: var(--white);
}

/* ========================================
   Stats Cards (Dashboard)
======================================== */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 1.5rem;
    margin-bottom: 1.5rem;
}

.stat-card {
    background: var(--white);
    border-radius: var(--border-radius);
    padding: 1.5rem;
    box-shadow: var(--shadow);
    display: flex;
    align-items: center;
    gap: 1rem;
    transition: var(--transition);
}

.stat-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

.stat-icon {
    width: 60px;
    height: 60px;
    border-radius: var(--border-radius);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
}

.stat-icon.primary { background: rgba(43, 87, 154, 0.15); color: var(--primary); }
.stat-icon.success { background: rgba(40, 167, 69, 0.15); color: var(--success); }
.stat-icon.warning { background: rgba(255, 193, 7, 0.2); color: #d39e00; }
.stat-icon.danger { background: rgba(220, 53, 69, 0.15); color: var(--danger); }
.stat-icon.info { background: rgba(23, 162, 184, 0.15); color: var(--info); }

.stat-info h3 {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--gray-800);
    margin: 0;
}

.stat-info p {
    color: var(--gray-600);
    font-size: 0.875rem;
    margin: 0;
}

/* ========================================
   Charts
======================================== */
.chart-container {
    position: relative;
    height: 300px;
    width: 100%;
}

.chart-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(400px, 1fr));
    gap: 1.5rem;
}

/* ========================================
   Demandas List
======================================== */
.demanda-item {
    display: flex;
    gap: 1rem;
    padding: 1rem;
    border-bottom: 1px solid var(--gray-200);
    transition: var(--transition);
}

.demanda-item:hover {
    background: var(--gray-50);
}

.demanda-item:last-child {
    border-bottom: none;
}

.demanda-icon {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.demanda-content {
    flex: 1;
    min-width: 0;
}

.demanda-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.25rem;
}

.demanda-protocolo {
    font-weight: 600;
    color: var(--primary);
}

.demanda-titulo {
    font-weight: 500;
    color: var(--gray-800);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.demanda-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    font-size: 0.813rem;
    color: var(--gray-600);
}

.demanda-meta span {
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

/* ========================================
   Timeline
======================================== */
.timeline {
    position: relative;
    padding-left: 2rem;
}

.timeline::before {
    content: '';
    position: absolute;
    left: 0.5rem;
    top: 0;
    bottom: 0;
    width: 2px;
    background: var(--gray-200);
}

.timeline-item {
    position: relative;
    padding-bottom: 1.5rem;
}

.timeline-item:last-child {
    padding-bottom: 0;
}

.timeline-dot {
    position: absolute;
    left: -1.75rem;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: var(--primary);
    border: 2px solid var(--white);
    box-shadow: 0 0 0 2px var(--primary);
}

.timeline-content {
    background: var(--gray-50);
    padding: 1rem;
    border-radius: var(--border-radius);
}

.timeline-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 0.5rem;
}

.timeline-title {
    font-weight: 600;
    color: var(--gray-800);
}

.timeline-date {
    font-size: 0.75rem;
    color: var(--gray-500);
}

.timeline-body {
    color: var(--gray-700);
    font-size: 0.875rem;
}

/* ========================================
   Modal
======================================== */
.modal-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: 2000;
    padding: 1rem;
    opacity: 0;
    visibility: hidden;
    transition: var(--transition);
}

.modal-overlay.show {
    opacity: 1;
    visibility: visible;
}

.modal {
    background: var(--white);
    border-radius: var(--border-radius);
    width: 100%;
    max-width: 500px;
    max-height: 90vh;
    overflow-y: auto;
    transform: scale(0.9);
    transition: var(--transition);
    box-shadow: var(--shadow-lg);
}

.modal-overlay.show .modal {
    transform: scale(1);
}

.modal-lg {
    max-width: 800px;
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--gray-200);
}

.modal-title {
    font-size: 1.125rem;
    font-weight: 600;
    margin: 0;
}

.modal-close {
    background: none;
    border: none;
    font-size: 1.25rem;
    color: var(--gray-500);
    cursor: pointer;
    padding: 0.25rem;
    line-height: 1;
}

.modal-close:hover {
    color: var(--gray-700);
}

.modal-body {
    padding: 1.25rem;
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 0.5rem;
    padding: 1rem 1.25rem;
    border-top: 1px solid var(--gray-200);
}

/* ========================================
   Empty State
======================================== */
.empty-state {
    text-align: center;
    padding: 3rem 1.5rem;
}

.empty-state-icon {
    font-size: 4rem;
    color: var(--gray-300);
    margin-bottom: 1rem;
}

.empty-state h3 {
    color: var(--gray-600);
    margin-bottom: 0.5rem;
}

.empty-state p {
    color: var(--gray-500);
    margin-bottom: 1.5rem;
}

/* ========================================
   Login Page
======================================== */
.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    padding: 1rem;
}

.login-container {
    width: 100%;
    max-width: 420px;
}

.login-card {
    background: var(--white);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-lg);
    padding: 2rem;
}

.login-logo {
    text-align: center;
    margin-bottom: 2rem;
}

.login-logo i {
    font-size: 3rem;
    color: var(--primary);
}

.login-logo h1 {
    font-size: 1.5rem;
    color: var(--gray-800);
    margin-top: 0.5rem;
}

.login-card .form-group {
    margin-bottom: 1.25rem;
}

.login-card .btn-primary {
    width: 100%;
    padding: 0.75rem;
    font-size: 1rem;
}

.login-footer {
    text-align: center;
    margin-top: 1.5rem;
}

.login-footer a {
    color: var(--primary);
    font-size: 0.875rem;
}

/* ========================================
   Error Page
======================================== */
.error-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--gray-100);
}

.error-container {
    text-align: center;
    padding: 2rem;
}

.error-icon {
    font-size: 5rem;
    color: var(--warning);
    margin-bottom: 1rem;
}

.error-container h1 {
    font-size: 6rem;
    font-weight: 700;
    color: var(--gray-800);
    line-height: 1;
}

.error-container h2 {
    color: var(--gray-600);
    margin-bottom: 1rem;
}

.error-container p {
    color: var(--gray-500);
    margin-bottom: 2rem;
}

/* ========================================
   Sidebar Toggle (Mobile)
======================================== */
.sidebar-toggle {
    display: none;
    position: fixed;
    top: 0.75rem;
    left: 0.75rem;
    z-index: 1001;
    width: 40px;
    height: 40px;
    background: var(--primary);
    color: var(--white);
    border: none;
    border-radius: var(--border-radius);
    cursor: pointer;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
}

.sidebar-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.5);
    z-index: 999;
}

/* ========================================
   Utilities
======================================== */
.d-flex { display: flex; }
.flex-wrap { flex-wrap: wrap; }
.align-items-center { align-items: center; }
.justify-content-between { justify-content: space-between; }
.justify-content-center { justify-content: center; }
.gap-1 { gap: 0.5rem; }
.gap-2 { gap: 1rem; }
.gap-3 { gap: 1.5rem; }
.mb-0 { margin-bottom: 0 !important; }
.mb-1 { margin-bottom: 0.5rem; }
.mb-2 { margin-bottom: 1rem; }
.mb-3 { margin-bottom: 1.5rem; }
.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mt-3 { margin-top: 1.5rem; }
.p-0 { padding: 0 !important; }
.w-100 { width: 100%; }

/* ========================================
   Animations
======================================== */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(-10px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.loading {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 2px solid var(--gray-300);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

/* ========================================
   Responsive - Tablet
======================================== */
@media (max-width: 992px) {
    .form-row-3,
    .form-row-4 {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .chart-grid {
        grid-template-columns: 1fr;
    }
    
    .user-name {
        display: none;
    }
}

/* ========================================
   Responsive - Mobile
======================================== */
@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
    }
    
    .sidebar.open {
        transform: translateX(0);
    }
    
    .sidebar-toggle {
        display: flex;
    }
    
    .sidebar-overlay.show {
        display: block;
    }
    
    .main-content {
        margin-left: 0;
    }
    
    .topbar {
        padding-left: 4rem;
    }
    
    .page-title {
        font-size: 1rem;
    }
    
    .page-content {
        padding: 1rem;
    }
    
    .stats-grid {
        grid-template-columns: 1fr;
    }
    
    .form-row-2,
    .form-row-3,
    .form-row-4 {
        grid-template-columns: 1fr;
    }
    
    .table-responsive {
        font-size: 0.813rem;
    }
    
    .table th,
    .table td {
        padding: 0.5rem;
    }
    
    .btn-group {
        flex-direction: column;
        width: 100%;
    }
    
    .btn-group .btn {
        width: 100%;
    }
    
    .demanda-meta {
        flex-direction: column;
        gap: 0.25rem;
    }
    
    .card-header {
        flex-direction: column;
        gap: 0.75rem;
        align-items: flex-start;
    }
}

/* ========================================
   Print Styles
======================================== */
@media print {
    .sidebar,
    .topbar,
    .sidebar-toggle,
    .btn,
    .no-print {
        display: none !important;
    }
    
    .main-content {
        margin-left: 0;
    }
    
    .page-content {
        padding: 0;
    }
    
    .card {
        box-shadow: none;
        border: 1px solid var(--gray-300);
    }
}

/* ========================================
   Bootstrap Grid Compatibility
======================================== */
.row {
    display: flex;
    flex-wrap: wrap;
    margin: 0 -0.75rem;
}
.row > * {
    padding: 0 0.75rem;
}
.col-md-2 { flex: 0 0 16.666%; max-width: 16.666%; }
.col-md-3 { flex: 0 0 25%; max-width: 25%; }
.col-md-4 { flex: 0 0 33.333%; max-width: 33.333%; }
.col-md-6 { flex: 0 0 50%; max-width: 50%; }
.col-md-8 { flex: 0 0 66.666%; max-width: 66.666%; }
.col-md-12 { flex: 0 0 100%; max-width: 100%; }

@media (max-width: 768px) {
    .col-md-2, .col-md-3, .col-md-4, .col-md-6, .col-md-8 {
        flex: 0 0 100%;
        max-width: 100%;
    }
}

.g-3 { gap: 1rem; }
.mb-4 { margin-bottom: 1.5rem; }
.mb-3 { margin-bottom: 1rem; }
.mb-2 { margin-bottom: 0.5rem; }
.mb-0 { margin-bottom: 0; }
.mt-3 { margin-top: 1rem; }
.mt-4 { margin-top: 1.5rem; }
.me-2 { margin-right: 0.5rem; }
.ms-2 { margin-left: 0.5rem; }
.p-0 { padding: 0; }

.d-flex { display: flex; }
.flex-wrap { flex-wrap: wrap; }
.align-items-center { align-items: center; }
.align-items-end { align-items: flex-end; }
.justify-content-between { justify-content: space-between; }
.justify-content-center { justify-content: center; }
.gap-2 { gap: 0.5rem; }
.gap-3 { gap: 1rem; }

.text-center { text-align: center; }
.text-right { text-align: right; }
.text-muted { color: #6c757d; }
.text-success { color: #28a745; }
.text-danger { color: #dc3545; }
.text-warning { color: #ffc107; }
.text-primary { color: var(--primary); }
.text-info { color: #17a2b8; }
.text-dark { color: #333; }

/* Form Select Bootstrap Style */
.form-select {
    display: block;
    width: 100%;
    padding: 0.5rem 2rem 0.5rem 0.75rem;
    font-size: 0.9375rem;
    line-height: 1.5;
    color: #333;
    background-color: #fff;
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3e%3cpath fill='none' stroke='%23343a40' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M2 5l6 6 6-6'/%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: right 0.75rem center;
    background-size: 16px 12px;
    border: 1px solid var(--gray-300);
    border-radius: var(--border-radius);
    appearance: none;
    transition: border-color 0.2s, box-shadow 0.2s;
}
.form-select:focus {
    border-color: var(--primary);
    outline: 0;
    box-shadow: 0 0 0 3px rgba(43, 87, 154, 0.1);
}

/* Badge Colors Bootstrap */
.bg-primary { background-color: var(--primary) !important; color: white; }
.bg-success { background-color: #28a745 !important; color: white; }
.bg-danger { background-color: #dc3545 !important; color: white; }
.bg-warning { background-color: #ffc107 !important; color: #333; }
.bg-info { background-color: #17a2b8 !important; color: white; }
.bg-secondary { background-color: #6c757d !important; color: white; }

/* Progress Bar */
.progress {
    display: flex;
    height: 1rem;
    overflow: hidden;
    background-color: #e9ecef;
    border-radius: 0.25rem;
}
.progress-bar {
    display: flex;
    flex-direction: column;
    justify-content: center;
    overflow: hidden;
    color: #fff;
    text-align: center;
    white-space: nowrap;
    background-color: var(--primary);
    transition: width 0.6s ease;
    font-size: 0.75rem;
}
.progress-bar.bg-success { background-color: #28a745 !important; }
.progress-bar.bg-warning { background-color: #ffc107 !important; color: #333; }
.progress-bar.bg-danger { background-color: #dc3545 !important; }

/* Table Small */
.table-sm td, .table-sm th {
    padding: 0.4rem 0.5rem;
    font-size: 0.875rem;
}

/* Chart Container */
.chart-container {
    position: relative;
    height: 300px;
}

/* Relatórios Filtros Form */
.filtros-form {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    align-items: flex-end;
    margin-bottom: 1.5rem;
    padding: 1rem;
    background: #f8f9fa;
    border-radius: var(--border-radius);
}
.filtros-form .form-group {
    min-width: 150px;
}
.filtros-form .form-group label {
    display: block;
    margin-bottom: 0.25rem;
    font-size: 0.875rem;
    font-weight: 500;
    color: #555;
}
.filtros-form .form-control,
.filtros-form .form-select {
    min-width: 150px;
}

/* Card Header Flex Fix */
.card-header.d-flex {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}
.card-header .btn-group,
.card-header > div {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

/* Table Responsive */
.table-responsive {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

/* Toggle Switch */
.toggle-switch {
    position: relative;
    display: inline-block;
    width: 50px;
    height: 26px;
    cursor: pointer;
}
.toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}
.toggle-slider {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #ccc;
    transition: 0.3s;
    border-radius: 26px;
}
.toggle-slider:before {
    position: absolute;
    content: "";
    height: 20px;
    width: 20px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    transition: 0.3s;
    border-radius: 50%;
    box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}
.toggle-switch input:checked + .toggle-slider {
    background-color: var(--primary, #3498db);
}
.toggle-switch input:checked + .toggle-slider:before {
    transform: translateX(24px);
}
.toggle-switch input:focus + .toggle-slider {
    box-shadow: 0 0 1px var(--primary, #3498db);
}

/* Modal Container (para etapas e outros modais inline) */
.modal-overlay[style*="display: flex"],
.modal-overlay[style*="display:flex"] {
    opacity: 1 !important;
    visibility: visible !important;
}
.modal-container {
    background: #fff;
    border-radius: 8px;
    width: 100%;
    max-width: 500px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 10px 40px rgba(0,0,0,0.2);
}
.modal-container .modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1.25rem;
    border-bottom: 1px solid #dee2e6;
    background: #f8f9fa;
    border-radius: 8px 8px 0 0;
}
.modal-container .modal-header h3 {
    margin: 0;
    font-size: 1.1rem;
    font-weight: 600;
}
.modal-container .modal-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: #666;
    line-height: 1;
    padding: 0;
}
.modal-container .modal-close:hover {
    color: #333;
}
.modal-container .modal-body {
    padding: 1.25rem;
}
.modal-container .modal-footer {
    padding: 1rem 1.25rem;
    border-top: 1px solid #dee2e6;
    display: flex;
    justify-content: flex-end;
    gap: 0.5rem;
    background: #f8f9fa;
    border-radius: 0 0 8px 8px;
}

/* Form Row */
.form-row {
    display: flex;
    gap: 1rem;
    margin-bottom: 0;
}
.form-row .form-group {
    margin-bottom: 1rem;
}

/* Drag and Drop para etapas */
.etapa-card.dragging {
    opacity: 0.5;
    border: 2px dashed var(--primary, #3498db);
}
.etapa-card.drag-over {
    border-top: 3px solid var(--primary, #3498db);
}

/* =============================================
   TABS / ABAS (para formulários, não sidebar)
   ============================================= */
.card .nav-tabs,
.card-body .nav-tabs,
.tab-container .nav-tabs,
ul.nav-tabs {
    display: flex !important;
    flex-wrap: wrap;
    padding-left: 0;
    margin-bottom: 1rem;
    list-style: none !important;
    border-bottom: 2px solid #dee2e6;
    gap: 0;
    background: transparent;
}
.card .nav-tabs .nav-item,
.card-body .nav-tabs .nav-item,
ul.nav-tabs .nav-item,
ul.nav-tabs > li {
    margin: 0 !important;
    margin-bottom: -2px !important;
    list-style: none !important;
}
.card .nav-tabs .nav-link,
.card-body .nav-tabs .nav-link,
ul.nav-tabs .nav-link,
ul.nav-tabs > li > a {
    display: block !important;
    padding: 0.75rem 1.25rem !important;
    color: #6c757d !important;
    text-decoration: none !important;
    background: transparent !important;
    border: 2px solid transparent !important;
    border-top-left-radius: 0.375rem !important;
    border-top-right-radius: 0.375rem !important;
    cursor: pointer;
    transition: all 0.2s ease;
    font-weight: 500;
}
.card .nav-tabs .nav-link:hover,
.card-body .nav-tabs .nav-link:hover,
ul.nav-tabs .nav-link:hover,
ul.nav-tabs > li > a:hover {
    color: var(--primary, #3498db) !important;
    background-color: #f8f9fa !important;
    border-color: #dee2e6 #dee2e6 transparent !important;
}
.card .nav-tabs .nav-link.active,
.card-body .nav-tabs .nav-link.active,
ul.nav-tabs .nav-link.active,
ul.nav-tabs > li.active > a,
ul.nav-tabs > li > a.active {
    color: var(--primary, #3498db) !important;
    background-color: #fff !important;
    border-color: #dee2e6 #dee2e6 #fff !important;
    font-weight: 600;
}

/* Tab Content */
.tab-content {
    padding: 1rem 0;
}
.tab-content > .tab-pane {
    display: none;
}
.tab-content > .tab-pane.active {
    display: block;
}

/* Fade effect */
.tab-pane.fade {
    opacity: 0;
    transition: opacity 0.15s linear;
}
.tab-pane.fade.show {
    opacity: 1;
}
.tab-pane.fade.show.active {
    display: block;
    opacity: 1;
}

/* =============================================
   ALERTS
   ============================================= */
.alert-info {
    background-color: #d1ecf1;
    border-color: #bee5eb;
    color: #0c5460;
}
.alert-warning {
    background-color: #fff3cd;
    border-color: #ffeeba;
    color: #856404;
}
.alert-danger {
    background-color: #f8d7da;
    border-color: #f5c6cb;
    color: #721c24;
}

/* Form Check inline */
.form-check {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
}
.form-check-input {
    width: 1.1rem;
    height: 1.1rem;
    margin: 0;
    cursor: pointer;
}
.form-check-label {
    cursor: pointer;
    user-select: none;
}

/* Input Group */
.input-group {
    display: flex;
    flex-wrap: wrap;
}
.input-group .form-control {
    flex: 1;
    border-top-right-radius: 0;
    border-bottom-right-radius: 0;
}
.input-group .btn {
    border-top-left-radius: 0;
    border-bottom-left-radius: 0;
}

/* Gap utilities */
.g-2 { gap: 0.5rem; }
.g-3 { gap: 1rem; }
.me-2 { margin-right: 0.5rem; }
.me-3 { margin-right: 1rem; }
.me-4 { margin-right: 1.5rem; }
.mb-0 { margin-bottom: 0 !important; }
.mb-1 { margin-bottom: 0.25rem !important; }
.mb-3 { margin-bottom: 1rem !important; }
.mt-2 { margin-top: 0.5rem !important; }
.mt-3 { margin-top: 1rem !important; }
.mt-4 { margin-top: 1.5rem !important; }
.py-2 { padding-top: 0.5rem; padding-bottom: 0.5rem; }
.w-100 { width: 100% !important; }

/* Text colors */
.text-warning { color: #ffc107 !important; }
.text-info { color: #17a2b8 !important; }

/* Border colors */
.border-success { border-color: #28a745 !important; }
.border-warning { border-color: #ffc107 !important; }
.border-secondary { border-color: #6c757d !important; }

/* Background colors */
.bg-light { background-color: #f8f9fa !important; }
.bg-success { background-color: #28a745 !important; }
.bg-secondary { background-color: #6c757d !important; }
