:root {
    --primary-color: #4361ee;
    --primary-dark: #3a56d4;
    --secondary-color: #7209b7;
    --success-color: #4cc9f0;
    --warning-color: #f72585;
    --danger-color: #ef233c;
    --info-color: #4895ef;
    
    --dark-color: #2b2d42;
    --light-color: #f8f9fa;
    --gray-color: #6c757d;
    --border-color: #e9ecef;
    
    --sidebar-width: 280px;
    --sidebar-collapsed: 80px;
    --header-height: 70px;
    
    --border-radius: 12px;
    --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Poppins', sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: var(--dark-color);
    line-height: 1.6;
    min-height: 100vh;
}

/* Login Screen */
.login-container {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.login-card {
    background: white;
    border-radius: 20px;
    padding: 40px;
    width: 100%;
    max-width: 400px;
    box-shadow: var(--shadow-lg);
    animation: slideUp 0.5s ease;
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.login-header {
    text-align: center;
    margin-bottom: 30px;
}

.logo {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    font-size: 24px;
    font-weight: 700;
    color: var(--primary-color);
    margin-bottom: 10px;
}

.logo i {
    font-size: 28px;
}

.login-header h2 {
    color: var(--dark-color);
    margin-bottom: 5px;
}

.login-header p {
    color: var(--gray-color);
    font-size: 14px;
}

.input-group {
    position: relative;
    margin-bottom: 20px;
}

.input-group i {
    position: absolute;
    left: 15px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--gray-color);
}

.input-group input {
    width: 100%;
    padding: 12px 15px 12px 45px;
    border: 2px solid var(--border-color);
    border-radius: 10px;
    font-size: 14px;
    transition: all 0.3s ease;
}

.input-group input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(67, 97, 238, 0.1);
}

.btn-login {
    width: 100%;
    padding: 12px;
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    color: white;
    border: none;
    border-radius: 10px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
}

.btn-login:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

.login-message {
    text-align: center;
    margin-top: 15px;
    color: var(--danger-color);
    font-size: 14px;
    min-height: 20px;
}

/* Layout Principal - CORRIGIDO */
.app-container {
    display: none;
    min-height: 100vh;
    background: #f5f7fb;
}

/* Sidebar Elegante - CORRIGIDO */
.sidebar {
    width: var(--sidebar-width);
    background: linear-gradient(180deg, var(--dark-color) 0%, #1a1c2e 100%);
    color: white;
    transition: all 0.3s ease;
    display: flex;
    flex-direction: column;
    box-shadow: var(--shadow);
    position: fixed;
    left: 0;
    top: 0;
    height: 100vh;
    z-index: 1000;
    overflow-y: auto;
}

.sidebar-header {
    padding: 20px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.sidebar-toggle {
    background: none;
    border: none;
    color: white;
    font-size: 18px;
    cursor: pointer;
    opacity: 0.7;
    transition: opacity 0.3s ease;
}

.sidebar-toggle:hover {
    opacity: 1;
}

.sidebar-content {
    flex: 1;
    padding: 20px 0;
}

.user-info {
    padding: 0 20px 20px;
    display: flex;
    align-items: center;
    gap: 15px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    margin-bottom: 20px;
}

.user-avatar {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
}

.user-details {
    flex: 1;
}

.user-name {
    display: block;
    font-weight: 600;
    font-size: 16px;
}

.user-role {
    font-size: 12px;
    opacity: 0.7;
}

.sidebar-menu {
    list-style: none;
}

.menu-item {
    display: flex;
    align-items: center;
    gap: 15px;
    padding: 15px 20px;
    color: rgba(255, 255, 255, 0.8);
    text-decoration: none;
    transition: all 0.3s ease;
    border-left: 3px solid transparent;
}

.menu-item:hover {
    background: rgba(255, 255, 255, 0.1);
    color: white;
    border-left-color: var(--primary-color);
}

.menu-item.active {
    background: rgba(67, 97, 238, 0.2);
    color: white;
    border-left-color: var(--primary-color);
}

.menu-item i {
    width: 20px;
    text-align: center;
    font-size: 18px;
}

.menu-section {
    padding: 15px 20px;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 1px;
    opacity: 0.5;
    margin-top: 20px;
}

.sidebar-footer {
    padding: 20px;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.logout-btn {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px;
    background: rgba(239, 35, 60, 0.1);
    color: rgba(255, 255, 255, 0.8);
    border: 1px solid rgba(239, 35, 60, 0.3);
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.logout-btn:hover {
    background: rgba(239, 35, 60, 0.2);
    color: white;
}

/* Conteúdo Principal - CORRIGIDO */
.main-content {
    margin-left: var(--sidebar-width);
    width: calc(100% - var(--sidebar-width));
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.content-header {
    height: var(--header-height);
    background: white;
    padding: 0 30px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    box-shadow: var(--shadow);
    z-index: 100;
    position: sticky;
    top: 0;
}

.header-left h1 {
    font-size: 24px;
    font-weight: 600;
    color: var(--dark-color);
}

.breadcrumb {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 12px;
    color: var(--gray-color);
    margin-top: 5px;
}

.breadcrumb i {
    font-size: 10px;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 15px;
}

.notification-btn, .user-menu-btn {
    background: none;
    border: none;
    font-size: 20px;
    color: var(--gray-color);
    cursor: pointer;
    position: relative;
    transition: color 0.3s ease;
}

.notification-btn:hover, .user-menu-btn:hover {
    color: var(--primary-color);
}

.notification-badge {
    position: absolute;
    top: -5px;
    right: -5px;
    background: var(--danger-color);
    color: white;
    border-radius: 50%;
    width: 18px;
    height: 18px;
    font-size: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Conteúdo - CORRIGIDO */
.content-wrapper {
    flex: 1;
    padding: 30px;
    overflow-y: auto;
    background: #f5f7fb;
}

.page {
    display: none;
}

.page.active {
    display: block;
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Dashboard */
.dashboard-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 30px;
}

.dashboard-header h2 {
    font-size: 28px;
    font-weight: 700;
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.date-filter {
    display: flex;
    align-items: center;
    gap: 10px;
}

.date-filter select {
    padding: 8px 15px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    background: white;
}

/* Cards de Estatísticas */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 25px;
    margin-bottom: 40px;
}

.stat-card {
    background: white;
    border-radius: var(--border-radius);
    padding: 25px;
    box-shadow: var(--shadow);
    display: flex;
    align-items: center;
    gap: 20px;
    transition: all 0.3s ease;
    border-left: 4px solid;
}

.stat-card:hover {
    transform: translateY(-5px);
    box-shadow: var(--shadow-lg);
}

.stat-card.primary { border-left-color: var(--primary-color); }
.stat-card.success { border-left-color: var(--success-color); }
.stat-card.warning { border-left-color: var(--warning-color); }
.stat-card.danger { border-left-color: var(--danger-color); }

.stat-icon {
    width: 60px;
    height: 60px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    color: white;
}

.stat-card.primary .stat-icon { background: var(--primary-color); }
.stat-card.success .stat-icon { background: var(--success-color); }
.stat-card.warning .stat-icon { background: var(--warning-color); }
.stat-card.danger .stat-icon { background: var(--danger-color); }

.stat-content {
    flex: 1;
}

.stat-content h3 {
    font-size: 14px;
    color: var(--gray-color);
    margin-bottom: 5px;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.stat-value {
    font-size: 32px;
    font-weight: 700;
    display: block;
    margin-bottom: 5px;
}

.stat-change {
    font-size: 12px;
    display: flex;
    align-items: center;
    gap: 5px;
}

.stat-change.positive { color: #10b981; }
.stat-change.negative { color: var(--danger-color); }

/* Gráficos */
.dashboard-charts {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 25px;
    margin-bottom: 40px;
}

.chart-container {
    background: white;
    border-radius: var(--border-radius);
    padding: 25px;
    box-shadow: var(--shadow);
    position: relative;
}

.chart-container.large {
    grid-column: 1;
}

.chart-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.chart-header h3 {
    font-size: 18px;
    font-weight: 600;
}

.chart-legend {
    display: flex;
    gap: 15px;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 12px;
    color: var(--gray-color);
}

.chart-container canvas {
    max-height: 300px !important;
    width: 100% !important;
}

/* Widgets */
.dashboard-widgets {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 25px;
}

.widget {
    background: white;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow);
}

.widget-header {
    padding: 20px 25px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.widget-header h3 {
    font-size: 16px;
    font-weight: 600;
}

.widget-badge {
    padding: 4px 8px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
    color: white;
}

.widget-badge.danger { background: var(--danger-color); }
.widget-badge.warning { background: var(--warning-color); }

.widget-content {
    padding: 20px 25px;
}

.alert-item {
    display: flex;
    align-items: center;
    gap: 15px;
    padding: 15px 0;
    border-bottom: 1px solid var(--border-color);
}

.alert-item:last-child {
    border-bottom: none;
}

.alert-item i {
    font-size: 18px;
}

.alert-item.critical i { color: var(--danger-color); }
.alert-item.warning i { color: var(--warning-color); }
.alert-item.info i { color: var(--info-color); }

.alert-content {
    flex: 1;
}

.alert-content strong {
    display: block;
    font-size: 14px;
    margin-bottom: 2px;
}

.alert-content span {
    font-size: 12px;
    color: var(--gray-color);
}

.alert-time {
    font-size: 11px;
    color: var(--gray-color);
}

.activity-item {
    display: flex;
    align-items: center;
    gap: 15px;
    padding: 12px 0;
}

.activity-avatar {
    width: 35px;
    height: 35px;
    border-radius: 50%;
    background: var(--light-color);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
}

.activity-content {
    flex: 1;
    font-size: 14px;
}

.activity-time {
    display: block;
    font-size: 11px;
    color: var(--gray-color);
    margin-top: 2px;
}

/* Gerenciamento de Usuários */
.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 30px;
}

.page-header h2 {
    font-size: 28px;
    font-weight: 700;
    color: var(--dark-color);
}

.page-header p {
    color: var(--gray-color);
    margin-top: 5px;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    color: white;
    border: none;
    padding: 12px 24px;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 8px;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

.users-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

.user-card {
    background: white;
    border-radius: var(--border-radius);
    padding: 20px;
    box-shadow: var(--shadow);
}

.user-card.admin {
    border-left: 4px solid var(--warning-color);
}

.user-card.user {
    border-left: 4px solid var(--info-color);
}

.user-header {
    display: flex;
    align-items: center;
    gap: 15px;
    margin-bottom: 15px;
}

.user-avatar {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    color: white;
}

.user-card.admin .user-avatar {
    background: linear-gradient(135deg, #ffd700, #ffa500);
}

.user-card.user .user-avatar {
    background: linear-gradient(135deg, var(--info-color), #64b5f6);
}

.user-info {
    flex: 1;
}

.user-info h4 {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 2px;
}

.user-info span {
    font-size: 12px;
    color: var(--gray-color);
}

.user-actions {
    display: flex;
    gap: 5px;
}

.btn-icon {
    background: none;
    border: none;
    padding: 8px;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.3s ease;
    color: var(--gray-color);
}

.btn-icon:hover {
    background: var(--light-color);
    color: var(--dark-color);
}

.btn-icon.danger:hover {
    background: #fee2e2;
    color: var(--danger-color);
}

.user-stats {
    border-top: 1px solid var(--border-color);
    padding-top: 15px;
}

.stat {
    display: flex;
    justify-content: space-between;
    font-size: 12px;
}

.stat span {
    color: var(--gray-color);
}

.stat strong {
    color: var(--dark-color);
}

/* Tabelas */
.table-container {
    background: white;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow);
    overflow: hidden;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
}

.data-table th {
    background: #f8f9fa;
    padding: 15px 20px;
    text-align: left;
    font-weight: 600;
    font-size: 14px;
    color: var(--dark-color);
    border-bottom: 1px solid var(--border-color);
}

.data-table td {
    padding: 15px 20px;
    border-bottom: 1px solid var(--border-color);
    font-size: 14px;
}

.data-table tr:hover {
    background: #f8f9fa;
}

/* Modal */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1000;
    align-items: center;
    justify-content: center;
}

.modal-content {
    background: white;
    border-radius: var(--border-radius);
    width: 90%;
    max-width: 500px;
    box-shadow: var(--shadow-lg);
    animation: modalSlide 0.3s ease;
}

@keyframes modalSlide {
    from {
        opacity: 0;
        transform: translateY(-30px) scale(0.9);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.modal-header {
    padding: 20px 25px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h3 {
    font-size: 20px;
    font-weight: 600;
}

.modal-close {
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: var(--gray-color);
}

.modal-form {
    padding: 25px;
}

.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    font-size: 14px;
}

.form-group input,
.form-group select {
    width: 100%;
    padding: 12px 15px;
    border: 2px solid var(--border-color);
    border-radius: 8px;
    font-size: 14px;
    transition: all 0.3s ease;
}

.form-group input:focus,
.form-group select:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(67, 97, 238, 0.1);
}

.form-actions {
    display: flex;
    gap: 15px;
    justify-content: flex-end;
    margin-top: 25px;
}

.btn-secondary {
    background: var(--light-color);
    color: var(--dark-color);
    border: 1px solid var(--border-color);
    padding: 12px 24px;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
}

.btn-secondary:hover {
    background: #e9ecef;
}

/* Responsividade */
@media (max-width: 1024px) {
    .dashboard-charts {
        grid-template-columns: 1fr;
    }
    
    .dashboard-widgets {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 768px) {
    .sidebar {
        width: var(--sidebar-collapsed);
    }
    
    .main-content {
        margin-left: var(--sidebar-collapsed);
        width: calc(100% - var(--sidebar-collapsed));
    }
    
    .sidebar .logo span,
    .sidebar .user-details,
    .sidebar .menu-item span,
    .sidebar .menu-section,
    .sidebar .logout-btn span {
        display: none;
    }
    
    .sidebar .menu-item {
        justify-content: center;
        padding: 15px;
    }
    
    .stats-grid {
        grid-template-columns: 1fr;
    }
    
    .content-header {
        padding: 0 20px;
    }
    
    .content-wrapper {
        padding: 20px;
    }
}

@media (max-width: 480px) {
    .login-card {
        padding: 30px 20px;
    }
    
    .dashboard-header {
        flex-direction: column;
        gap: 15px;
        align-items: flex-start;
    }
    
    .page-header {
        flex-direction: column;
        gap: 15px;
        align-items: flex-start;
    }
}

/* Estilos para elementos dinâmicos */
.badge {
    padding: 4px 8px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
}

.badge.admin {
    background: #fff3cd;
    color: #856404;
}

.badge.user {
    background: #d1ecf1;
    color: #0c5460;
}

.status {
    padding: 4px 8px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 600;
}

.status.active {
    background: #d4edda;
    color: #155724;
}

.status.inactive {
    background: #f8d7da;
    color: #721c24;
}

.sidebar.collapsed {
    width: 80px;
}

.sidebar.collapsed .logo span,
.sidebar.collapsed .user-details,
.sidebar.collapsed .menu-item span,
.sidebar.collapsed .menu-section,
.sidebar.collapsed .logout-btn span {
    display: none;
}

.sidebar.collapsed .menu-item {
    justify-content: center;
    padding: 15px;
}

.sidebar.collapsed .user-info {
    justify-content: center;
}

.sidebar.collapsed .user-avatar {
    margin: 0 auto;
}