/* Estilos Customizados - Sistema APAE */

:root {
    --primary-color: #0d6efd;
    --secondary-color: #6c757d;
    --success-color: #198754;
    --danger-color: #dc3545;
    --warning-color: #ffc107;
    --info-color: #0dcaf0;
    
    /* Sidebar */
    --sidebar-width: 260px;
    --sidebar-collapsed-width: 70px;
    --sidebar-bg: #ffffff;
    --sidebar-color: #475569;
    --sidebar-hover: #f1f5f9;
    --sidebar-active: #0d6efd;
    --sidebar-border: #e2e8f0;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background-color: #f8f9fa;
}

/* Validação de campos com check verde */
.form-group-validated {
    position: relative;
}

.form-group-validated .form-control,
.form-group-validated .form-select {
    padding-right: 40px;
    transition: border-color 0.3s ease, box-shadow 0.3s ease;
}

.form-group-validated textarea.form-control {
    padding-right: 40px;
    padding-bottom: 10px;
}

.form-valid-icon {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: #198754;
    font-size: 1.2rem;
    opacity: 0;
    transition: opacity 0.3s ease;
    pointer-events: none;
    z-index: 10;
}

.form-group-validated.valid .form-valid-icon {
    opacity: 1;
}

.form-group-validated.valid .form-control,
.form-group-validated.valid .form-select {
    border-color: #198754;
    padding-right: 40px;
}

.form-group-validated.valid .form-control:focus,
.form-group-validated.valid .form-select:focus {
    border-color: #198754;
    box-shadow: 0 0 0 0.25rem rgba(25, 135, 84, 0.25);
}

/* Layout com Sidebar */
body.sidebar-enabled {
    display: flex;
    min-height: 100vh;
}

/* Sidebar */
.sidebar {
    position: fixed;
    top: 0;
    left: 0;
    width: var(--sidebar-width);
    height: 100vh;
    background: var(--sidebar-bg);
    color: var(--sidebar-color);
    border-right: 1px solid var(--sidebar-border);
    overflow: hidden;
    transition: transform 0.3s ease, margin-left 0.3s ease;
    z-index: 999;
    display: flex;
    flex-direction: column;
    box-shadow: 2px 0 8px rgba(0,0,0,0.05);
}

.sidebar-header {
    padding: 1.5rem 1rem;
    border-bottom: 1px solid var(--sidebar-border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: var(--sidebar-bg);
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    color: #1e293b;
    text-decoration: none;
    font-size: 1.25rem;
    font-weight: 700;
}

.sidebar-brand i {
    font-size: 1.5rem;
    color: var(--sidebar-active);
}

.sidebar-toggle {
    background: none;
    border: none;
    color: var(--sidebar-color);
    font-size: 1.25rem;
    padding: 0.25rem;
    cursor: pointer;
    transition: color 0.2s;
}

.sidebar-toggle:hover {
    color: #1e293b;
}

/* Sidebar Mobile Toggle */
.sidebar-mobile-toggle {
    display: none;
    padding: 1rem;
    border-bottom: 1px solid rgba(255,255,255,0.1);
}

.sidebar-mobile-toggle .btn-link {
    color: var(--sidebar-color);
    text-decoration: none;
    font-size: 1.5rem;
}

.sidebar-mobile-toggle .btn-link:hover {
    color: #1e293b;
}

/* Sidebar User (parte inferior) */
.sidebar-user {
    padding: 1rem;
    border-top: 1px solid var(--sidebar-border);
    margin-top: auto;
    background: var(--sidebar-hover);
    flex-shrink: 0;
    position: relative;
    z-index: 1000;
    overflow: visible;
    margin-bottom: 0;
}

.sidebar-user-info {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    position: relative;
    z-index: 1000;
}

.sidebar-user-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--sidebar-active);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
    flex-shrink: 0;
}

.sidebar-user-details {
    flex: 1;
    min-width: 0;
}

.sidebar-user-name {
    font-weight: 600;
    font-size: 0.875rem;
    margin-bottom: 0.125rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    color: #1e293b;
}

.sidebar-user-role {
    font-size: 0.7rem;
    opacity: 0.75;
    text-transform: capitalize;
}

.sidebar-user-toggle {
    color: var(--sidebar-color);
    padding: 0.25rem;
    font-size: 0.75rem;
    flex-shrink: 0;
    border: none;
    background: none;
    opacity: 0.7;
    transition: opacity 0.2s, color 0.2s;
}

.sidebar-user-toggle:hover {
    opacity: 1;
    color: #1e293b;
}

/* Evitar que o dropdown cause scroll na sidebar */
.sidebar-user .dropdown {
    position: static;
}

.sidebar-user-menu {
    position: absolute !important;
    bottom: calc(100% + 0.5rem) !important;
    left: 0 !important;
    right: 0 !important;
    top: auto !important;
    transform: none !important;
    background: #fff;
    border: 1px solid var(--sidebar-border);
    border-radius: 0.5rem;
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
    min-width: 100%;
    max-height: none;
    overflow: visible;
    z-index: 1001;
    margin: 0;
}

.sidebar-user-menu .dropdown-item {
    color: var(--sidebar-color);
    padding: 0.5rem 1rem;
}

.sidebar-user-menu .dropdown-item:hover {
    background: var(--sidebar-hover);
    color: #1e293b;
}

/* Sidebar Menu - Scrollable */
.sidebar-menu {
    list-style: none;
    padding: 1rem 0;
    margin: 0;
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding-bottom: 0.5rem;
    margin-bottom: 0.5rem;
}

.sidebar-menu-item {
    margin: 0.25rem 0;
}

.sidebar-menu-link {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1.5rem;
    color: #334155;
    text-decoration: none;
    transition: all 0.2s;
    position: relative;
    border-radius: 0.375rem;
    margin: 0 0.5rem;
    font-weight: 500;
}

.sidebar-menu-link:hover {
    background: var(--sidebar-hover);
    color: #1e293b;
}

.sidebar-menu-item.active > .sidebar-menu-link {
    background: var(--sidebar-active);
    color: #fff;
    font-weight: 600;
}

.sidebar-menu-item.active > .sidebar-menu-link::before {
    content: '';
    position: absolute;
    left: -0.5rem;
    top: 50%;
    transform: translateY(-50%);
    width: 4px;
    height: 60%;
    background: var(--sidebar-active);
    border-radius: 0 2px 2px 0;
}

.sidebar-menu-link i {
    font-size: 1.1rem;
    width: 20px;
    text-align: center;
}

.sidebar-submenu-toggle {
    margin-left: auto;
    transition: transform 0.3s;
}

.sidebar-menu-item.open > .sidebar-menu-link .sidebar-submenu-toggle {
    transform: rotate(180deg);
}

/* Sidebar Submenu */
.sidebar-submenu {
    list-style: none;
    padding: 0;
    margin: 0;
    background: var(--sidebar-hover);
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease;
}

.sidebar-menu-item.open > .sidebar-submenu {
    max-height: 500px;
}

.sidebar-submenu li a {
    display: block;
    padding: 0.625rem 1.5rem 0.625rem 3.5rem;
    color: #475569;
    text-decoration: none;
    font-size: 0.9rem;
    transition: all 0.2s;
    border-radius: 0.375rem;
    margin: 0.25rem 0.5rem;
}

.sidebar-submenu li a:hover {
    background: rgba(13, 110, 253, 0.1);
    color: var(--sidebar-active);
    padding-left: 4rem;
}

.sidebar-submenu li a.active {
    background: var(--sidebar-active);
    color: #fff;
    font-weight: 600;
}


/* Main Content */
.main-content {
    flex: 1;
    margin-left: var(--sidebar-width);
    transition: margin-left 0.3s ease;
    min-height: 100vh;
    background: #f8f9fa;
}

/* Overlay para mobile */
.sidebar-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.5);
    z-index: 998;
}

/* Responsividade */
@media (max-width: 991.98px) {
    .sidebar {
        transform: translateX(-100%);
    }
    
    .sidebar.show {
        transform: translateX(0);
    }
    
    .main-content {
        margin-left: 0;
    }
    
    .sidebar-overlay.show {
        display: block;
    }
    
    .sidebar-mobile-toggle {
        display: block;
    }
}

/* Navbar */
.navbar-brand {
    font-weight: 600;
    font-size: 1.25rem;
}

.navbar-nav .nav-link {
    padding: 0.5rem 1rem;
    transition: background-color 0.2s;
}

.navbar-nav .nav-link:hover {
    background-color: rgba(255, 255, 255, 0.1);
    border-radius: 0.25rem;
}

/* Cards */
.card {
    border: none;
    border-radius: 0.5rem;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    transition: transform 0.2s, box-shadow 0.2s;
}

.card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);
}

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

.table thead th {
    background-color: #f8f9fa;
    border-bottom: 2px solid #dee2e6;
    font-weight: 600;
    text-transform: uppercase;
    font-size: 0.75rem;
    letter-spacing: 0.5px;
}

/* Formulários */
.form-label {
    font-weight: 500;
    margin-bottom: 0.5rem;
}

.form-control:focus,
.form-select:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 0.2rem rgba(13, 110, 253, 0.25);
}

/* Botões */
.btn {
    border-radius: 0.375rem;
    font-weight: 500;
    padding: 0.5rem 1rem;
    transition: all 0.2s;
}

.btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

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

/* Responsividade */
@media (max-width: 768px) {
    .navbar-nav {
        margin-top: 1rem;
    }

    .card-body {
        padding: 1rem;
    }

    .table-responsive {
        font-size: 0.85rem;
    }
}

/* Animações */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.fade-in {
    animation: fadeIn 0.3s ease-in;
}

/* Loading */
.spinner-border-sm {
    width: 1rem;
    height: 1rem;
}

/* Acessibilidade */
.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border-width: 0;
}

/* Print styles */
@media print {
    .navbar,
    .btn,
    .no-print {
        display: none !important;
    }
}

