/**
 * Estilos customizados para o sistema Retaguarda
 */

:root {
    --primary-color: #0d6efd;
    --secondary-color: #6c757d;
    --success-color: #198754;
    --danger-color: #dc3545;
    --warning-color: #ffc107;
    --info-color: #0dcaf0;
    --light-color: #f8f9fa;
    --dark-color: #212529;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    min-height: 100vh;
}

body.login-page {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

/* Página de Login */
.card {
    border-radius: 1rem;
    overflow: hidden;
}

.card-body {
    background: #fff;
}

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

.btn-primary {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border: none;
    transition: transform 0.2s, box-shadow 0.2s;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
    background: linear-gradient(135deg, #5568d3 0%, #6a3f8f 100%);
}

.btn-primary:active {
    transform: translateY(0);
}

/* Input com ícone */
.input-group .btn-outline-secondary {
    border-left: none;
}

.input-group .form-control:focus + .btn-outline-secondary {
    border-color: var(--primary-color);
    border-left: none;
}

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

.card {
    animation: fadeIn 0.5s ease-out;
}

/* Responsividade */
@media (max-width: 576px) {
    .card-body {
        padding: 2rem 1.5rem !important;
    }
    
    .display-1 {
        font-size: 3rem;
    }
}

/* Melhorias de acessibilidade */
.form-label {
    color: #495057;
}

.form-control::placeholder {
    color: #adb5bd;
}

/* Loading state */
.btn-loading {
    position: relative;
    pointer-events: none;
}

.btn-loading::after {
    content: "";
    position: absolute;
    width: 16px;
    height: 16px;
    top: 50%;
    left: 50%;
    margin-left: -8px;
    margin-top: -8px;
    border: 2px solid #ffffff;
    border-radius: 50%;
    border-top-color: transparent;
    animation: spinner 0.6s linear infinite;
}

@keyframes spinner {
    to {
        transform: rotate(360deg);
    }
}

/* Páginas internas (não login) */
body:not(.login-page) {
    background: #f8f9fa;
}

.container-fluid {
    background: #f8f9fa;
}

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

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

.table tbody tr {
    transition: background-color 0.2s;
}

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

.table td {
    vertical-align: middle;
}

/* Cards */
.card {
    border: none;
    box-shadow: 0 0.125rem 0.25rem rgba(0, 0, 0, 0.075);
}

.card-header {
    border-bottom: 1px solid #dee2e6;
    font-weight: 600;
}

/* Botões de ação */
.btn-sm {
    padding: 0.25rem 0.5rem;
    font-size: 0.875rem;
}

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

/* Estado vazio */
.text-center.py-5 {
    color: #6c757d;
}

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

.form-control:disabled {
    background-color: #e9ecef;
    cursor: not-allowed;
}

/* Responsividade para tabelas */
@media (max-width: 768px) {
    .table-responsive {
        font-size: 0.875rem;
    }
    
    .btn-sm {
        padding: 0.2rem 0.4rem;
        font-size: 0.75rem;
    }
}

/* Color Picker */
.form-control-color {
    width: 60px;
    height: 38px;
    padding: 2px;
    cursor: pointer;
    border: 1px solid #ced4da;
    border-radius: 0.375rem 0 0 0.375rem;
}

.form-control-color:hover {
    border-color: var(--primary-color);
}

.form-control-color::-webkit-color-swatch-wrapper {
    padding: 0;
}

.form-control-color::-webkit-color-swatch {
    border: none;
    border-radius: 0.25rem;
}

.input-group .form-control-color + .form-control {
    border-left: none;
    border-radius: 0 0.375rem 0.375rem 0;
}

.input-group .form-control-color:focus + .form-control {
    border-left: 1px solid var(--primary-color);
    border-color: var(--primary-color);
}

/* ============================================
   MENU LATERAL (SIDEBAR)
   ============================================ */

body.has-sidebar {
    background: #f8f9fa;
    overflow-x: hidden;
}

.main-content {
    margin-left: 0;
    transition: margin-left 0.3s ease;
    min-height: 100vh;
    padding-top: 0;
}

/* Sidebar */
.sidebar {
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    width: 260px;
    background: linear-gradient(180deg, #2c3e50 0%, #34495e 100%);
    color: #fff;
    z-index: 1000;
    transform: translateX(-100%);
    transition: transform 0.3s ease;
    box-shadow: 2px 0 10px rgba(0, 0, 0, 0.1);
    overflow-y: auto;
    overflow-x: hidden;
}

/* Sidebar sempre visível no desktop quando has-sidebar */
@media (min-width: 768px) {
    body.has-sidebar .sidebar {
        transform: translateX(0);
    }
    
    body.has-sidebar .main-content {
        margin-left: 260px;
    }
    
    .sidebar-toggle {
        display: none !important;
    }
    
    .sidebar-overlay {
        display: none !important;
    }
}

/* Sidebar oculto por padrão no mobile, aparece apenas com sidebar-open */
@media (max-width: 767px) {
    body.has-sidebar .sidebar {
        transform: translateX(-100%);
    }
    
    body.has-sidebar.sidebar-open .sidebar {
        transform: translateX(0);
    }
}

/* Sidebar Header */
.sidebar-header {
    padding: 1.5rem 1rem;
    background: rgba(0, 0, 0, 0.2);
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: sticky;
    top: 0;
    z-index: 10;
}

.sidebar-title {
    font-size: 1.25rem;
    font-weight: 600;
    color: #fff;
}

/* Sidebar Navigation */
.sidebar-nav {
    padding: 1rem 0;
}

.sidebar-nav .nav {
    list-style: none;
    padding: 0;
    margin: 0;
}

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

.sidebar-nav .nav-link {
    color: rgba(255, 255, 255, 0.8);
    padding: 0.75rem 1.5rem;
    display: flex;
    align-items: center;
    text-decoration: none;
    transition: all 0.2s ease;
    border-left: 3px solid transparent;
    position: relative;
}

.sidebar-nav .nav-link:hover {
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
    border-left-color: #667eea;
}

.sidebar-nav .nav-link.active {
    background: rgba(102, 126, 234, 0.2);
    color: #fff;
    border-left-color: #667eea;
    font-weight: 600;
}

.sidebar-nav .nav-link i {
    width: 20px;
    text-align: center;
    margin-right: 0.75rem;
}

.sidebar-nav .nav-link .bi-chevron-down {
    margin-left: auto;
    margin-right: 0;
    transition: transform 0.3s ease;
    font-size: 0.75rem;
}

.sidebar-nav .nav-link[aria-expanded="true"] .bi-chevron-down {
    transform: rotate(180deg);
}

/* Submenu */
.sidebar-nav .collapse .nav-link {
    padding-left: 3rem;
    font-size: 0.9rem;
    border-left-width: 2px;
}

.sidebar-nav .collapse .nav-link:hover,
.sidebar-nav .collapse .nav-link.active {
    background: rgba(255, 255, 255, 0.15);
    border-left-color: #667eea;
}

/* Separador */
.sidebar-divider {
    border-color: rgba(255, 255, 255, 0.1);
    margin: 0.5rem 1.5rem;
}

/* Link de logout */
.sidebar-nav .nav-link.text-danger {
    color: #ff6b6b !important;
}

.sidebar-nav .nav-link.text-danger:hover {
    background: rgba(255, 107, 107, 0.2);
    color: #ff5252 !important;
}

/* Botão toggle para mobile */
.sidebar-toggle {
    position: fixed;
    top: 1rem;
    left: 1rem;
    z-index: 999;
    width: 45px;
    height: 45px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
}

/* Overlay para mobile */
.sidebar-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 998;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

/* Overlay visível apenas quando sidebar está aberto no mobile */
@media (max-width: 767px) {
    body.has-sidebar.sidebar-open .sidebar-overlay {
        opacity: 1;
        visibility: visible;
    }
}

/* Scrollbar personalizada para sidebar */
.sidebar::-webkit-scrollbar {
    width: 6px;
}

.sidebar::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.1);
}

.sidebar::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.2);
    border-radius: 3px;
}

.sidebar::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.3);
}

/* ============================================
   DASHBOARD CARDS
   ============================================ */

.dashboard-card {
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    border-radius: 12px;
    overflow: hidden;
}

.dashboard-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.1) !important;
}

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

.dashboard-icon {
    transition: transform 0.3s ease;
}

.dashboard-card:hover .dashboard-icon {
    transform: scale(1.1) rotate(5deg);
}

/* Responsividade para cards do dashboard */
@media (max-width: 768px) {
    .dashboard-card .card-body h2 {
        font-size: 2rem !important;
    }
    
    .dashboard-icon {
        width: 50px !important;
        height: 50px !important;
        font-size: 1.5rem !important;
    }
}

