/**
 * SIGSB - Sistema Integrado de Gestão de Saneamento Básico
 * Estilos Principais
 */

/* ============================================
   VARIÁVEIS CSS
============================================ */
:root {
    --primary: #0d6efd;
    --primary-dark: #0b5ed7;
    --primary-light: #3d8bfd;
    --secondary: #6c757d;
    --success: #198754;
    --danger: #dc3545;
    --warning: #ffc107;
    --info: #0dcaf0;
    --light: #f8f9fa;
    --dark: #212529;
    
    --sidebar-width: 280px;
    --sidebar-collapsed: 70px;
    --header-height: 60px;
    
    --font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    --border-radius: 0.5rem;
    --box-shadow: 0 0.125rem 0.25rem rgba(0, 0, 0, 0.075);
    --box-shadow-lg: 0 0.5rem 1rem rgba(0, 0, 0, 0.15);
    
    --gradient-primary: linear-gradient(135deg, #0d6efd 0%, #6610f2 100%);
    --gradient-success: linear-gradient(135deg, #198754 0%, #20c997 100%);
    --gradient-info: linear-gradient(135deg, #0dcaf0 0%, #0d6efd 100%);
    --gradient-warning: linear-gradient(135deg, #ffc107 0%, #fd7e14 100%);
    --gradient-danger: linear-gradient(135deg, #dc3545 0%, #e35d6a 100%);
}

/* ============================================
   RESET E BASE
============================================ */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
}

body {
    font-family: var(--font-family);
    font-size: 0.9375rem;
    line-height: 1.5;
    color: #333;
    background-color: #f5f7fb;
    min-height: 100vh;
}

a {
    color: var(--primary);
    text-decoration: none;
    transition: color 0.2s ease;
}

a:hover {
    color: var(--primary-dark);
}

/* ============================================
   PÁGINA DE LOGIN
============================================ */
.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--gradient-primary);
    padding: 20px;
}

.login-container {
    width: 100%;
    max-width: 420px;
}

.login-card {
    background: white;
    border-radius: 1rem;
    box-shadow: var(--box-shadow-lg);
    overflow: hidden;
}

.login-header {
    background: var(--gradient-primary);
    color: white;
    padding: 2rem;
    text-align: center;
}

.login-header .logo {
    width: 80px;
    height: 80px;
    background: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 1rem;
    font-size: 2rem;
    color: var(--primary);
    font-weight: bold;
}

.login-header h1 {
    font-size: 1.5rem;
    font-weight: 600;
    margin-bottom: 0.25rem;
}

.login-header p {
    opacity: 0.9;
    font-size: 0.875rem;
}

.login-body {
    padding: 2rem;
}

.login-body .form-label {
    font-weight: 500;
    color: #555;
}

.login-body .form-control {
    padding: 0.75rem 1rem;
    border-radius: 0.5rem;
    border: 1px solid #ddd;
    font-size: 0.9375rem;
}

.login-body .form-control:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(13, 110, 253, 0.15);
}

.login-body .btn-login {
    width: 100%;
    padding: 0.75rem;
    font-weight: 600;
    font-size: 1rem;
    border-radius: 0.5rem;
    background: var(--gradient-primary);
    border: none;
    margin-top: 1rem;
}

.login-body .btn-login:hover {
    opacity: 0.9;
}

/* ============================================
   LAYOUT PRINCIPAL
============================================ */
.wrapper {
    display: flex;
    min-height: 100vh;
}

/* Sidebar */
.sidebar {
    width: var(--sidebar-width);
    background: linear-gradient(180deg, #1e3a5f 0%, #0d2137 100%);
    color: white;
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    z-index: 1000;
    transition: width 0.3s ease;
    overflow: hidden;
}

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

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

.sidebar-logo {
    width: 42px;
    height: 42px;
    background: var(--gradient-primary);
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    font-size: 1.25rem;
    flex-shrink: 0;
}

.sidebar-brand {
    overflow: hidden;
    white-space: nowrap;
}

.sidebar-brand h2 {
    font-size: 1.25rem;
    font-weight: 700;
    margin: 0;
}

.sidebar-brand small {
    font-size: 0.75rem;
    opacity: 0.7;
}

.sidebar.collapsed .sidebar-brand {
    display: none;
}

/* Menu */
.sidebar-menu {
    padding: 1rem 0;
    height: calc(100vh - 80px);
    overflow-y: auto;
}

.sidebar-menu::-webkit-scrollbar {
    width: 4px;
}

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

.menu-section {
    padding: 0.5rem 1.25rem;
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: rgba(255, 255, 255, 0.4);
    margin-top: 0.5rem;
}

.sidebar.collapsed .menu-section {
    display: none;
}

.menu-item {
    display: block;
    padding: 0.75rem 1.25rem;
    color: rgba(255, 255, 255, 0.8);
    display: flex;
    align-items: center;
    gap: 0.75rem;
    transition: all 0.2s ease;
    border-left: 3px solid transparent;
}

.menu-item:hover {
    background: rgba(255, 255, 255, 0.1);
    color: white;
}

.menu-item.active {
    background: rgba(13, 110, 253, 0.2);
    color: white;
    border-left-color: var(--primary);
}

.menu-item i {
    width: 20px;
    text-align: center;
    font-size: 1rem;
    flex-shrink: 0;
}

.menu-item span {
    white-space: nowrap;
    overflow: hidden;
}

.sidebar.collapsed .menu-item span {
    display: none;
}

.sidebar.collapsed .menu-item {
    justify-content: center;
    padding: 0.75rem;
}

/* Content */
.main-content {
    flex: 1;
    margin-left: var(--sidebar-width);
    transition: margin-left 0.3s ease;
}

.sidebar.collapsed + .main-content {
    margin-left: var(--sidebar-collapsed);
}

/* Header */
.main-header {
    background: white;
    height: var(--header-height);
    padding: 0 1.5rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    box-shadow: var(--box-shadow);
    position: sticky;
    top: 0;
    z-index: 100;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.btn-toggle-sidebar {
    width: 40px;
    height: 40px;
    border: none;
    background: transparent;
    color: #666;
    font-size: 1.25rem;
    cursor: pointer;
    border-radius: 0.5rem;
    transition: all 0.2s ease;
}

.btn-toggle-sidebar:hover {
    background: #f0f0f0;
    color: var(--primary);
}

.page-title {
    font-size: 1.125rem;
    font-weight: 600;
    color: #333;
    margin: 0;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.header-icon {
    width: 40px;
    height: 40px;
    border: none;
    background: transparent;
    color: #666;
    font-size: 1.125rem;
    cursor: pointer;
    border-radius: 50%;
    position: relative;
    transition: all 0.2s ease;
}

.header-icon:hover {
    background: #f0f0f0;
    color: var(--primary);
}

.header-icon .badge {
    position: absolute;
    top: 2px;
    right: 2px;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    font-size: 0.65rem;
    display: flex;
    align-items: center;
    justify-content: center;
}

.user-dropdown {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.25rem 0.5rem;
    border-radius: 0.5rem;
    cursor: pointer;
    transition: background 0.2s ease;
}

.user-dropdown:hover {
    background: #f0f0f0;
}

.user-avatar {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 0.875rem;
    color: white;
}

.user-info {
    line-height: 1.2;
}

.user-name {
    font-weight: 600;
    font-size: 0.875rem;
    color: #333;
}

.user-role {
    font-size: 0.75rem;
    color: #888;
}

/* Main Body */
.main-body {
    padding: 1.5rem;
}

/* ============================================
   CARDS
============================================ */
.card {
    background: white;
    border: none;
    border-radius: var(--border-radius);
    box-shadow: var(--box-shadow);
    margin-bottom: 1.5rem;
}

.card-header {
    background: transparent;
    border-bottom: 1px solid #eee;
    padding: 1rem 1.25rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.card-title {
    font-size: 1rem;
    font-weight: 600;
    color: #333;
    margin: 0;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.card-title i {
    color: var(--primary);
}

.card-body {
    padding: 1.25rem;
}

/* Stats Cards */
.stat-card {
    position: relative;
    overflow: hidden;
    border-radius: var(--border-radius);
    padding: 1.5rem;
    color: white;
}

.stat-card.primary { background: var(--gradient-primary); }
.stat-card.success { background: var(--gradient-success); }
.stat-card.info { background: var(--gradient-info); }
.stat-card.warning { background: var(--gradient-warning); color: #333; }
.stat-card.danger { background: var(--gradient-danger); }

.stat-card .stat-icon {
    position: absolute;
    right: 1rem;
    top: 50%;
    transform: translateY(-50%);
    font-size: 4rem;
    opacity: 0.15;
}

.stat-card .stat-value {
    font-size: 2rem;
    font-weight: 700;
    margin-bottom: 0.25rem;
}

.stat-card .stat-label {
    font-size: 0.875rem;
    opacity: 0.9;
}

.stat-card .stat-change {
    font-size: 0.75rem;
    margin-top: 0.5rem;
    opacity: 0.9;
}

/* ============================================
   TABELAS
============================================ */
.table-responsive {
    border-radius: var(--border-radius);
}

.table {
    margin-bottom: 0;
}

.table thead th {
    background: #f8f9fa;
    border-bottom: 2px solid #dee2e6;
    font-weight: 600;
    font-size: 0.8125rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: #666;
    padding: 0.875rem 1rem;
    white-space: nowrap;
}

.table tbody td {
    padding: 0.875rem 1rem;
    vertical-align: middle;
    border-bottom: 1px solid #eee;
}

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

.table tbody tr:last-child td {
    border-bottom: none;
}

/* ============================================
   BOTÕES
============================================ */
.btn {
    font-weight: 500;
    padding: 0.5rem 1rem;
    border-radius: var(--border-radius);
    transition: all 0.2s ease;
}

.btn-sm {
    padding: 0.375rem 0.75rem;
    font-size: 0.8125rem;
}

.btn-lg {
    padding: 0.75rem 1.5rem;
    font-size: 1rem;
}

.btn-icon {
    width: 36px;
    height: 36px;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 0.5rem;
}

.btn-icon.btn-sm {
    width: 30px;
    height: 30px;
}

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

.btn-primary:hover {
    opacity: 0.9;
    transform: translateY(-1px);
}

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

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

/* ============================================
   FORMULÁRIOS
============================================ */
.form-label {
    font-weight: 500;
    font-size: 0.875rem;
    color: #555;
    margin-bottom: 0.375rem;
}

.form-control, .form-select {
    border-radius: var(--border-radius);
    border: 1px solid #ddd;
    padding: 0.625rem 0.875rem;
    font-size: 0.9375rem;
    transition: all 0.2s ease;
}

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

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

.input-group-text {
    background: #f8f9fa;
    border: 1px solid #ddd;
    border-radius: var(--border-radius);
}

/* ============================================
   BADGES
============================================ */
.badge {
    font-weight: 500;
    padding: 0.375em 0.65em;
    font-size: 0.75rem;
    border-radius: 0.375rem;
}

/* ============================================
   ALERTAS
============================================ */
.alert {
    border: none;
    border-radius: var(--border-radius);
    padding: 1rem 1.25rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.alert i {
    font-size: 1.25rem;
}

.alert-success { background: #d1e7dd; color: #0a3622; }
.alert-danger { background: #f8d7da; color: #58151c; }
.alert-warning { background: #fff3cd; color: #664d03; }
.alert-info { background: #cff4fc; color: #055160; }

/* ============================================
   PAGINAÇÃO
============================================ */
.pagination {
    gap: 0.25rem;
}

.page-link {
    border: none;
    border-radius: 0.375rem;
    padding: 0.5rem 0.875rem;
    color: #666;
    font-weight: 500;
}

.page-link:hover {
    background: #e9ecef;
    color: var(--primary);
}

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

/* ============================================
   UTILITÁRIOS
============================================ */
.text-muted { color: #888 !important; }
.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; }

.bg-light-primary { background: rgba(13, 110, 253, 0.1) !important; }
.bg-light-success { background: rgba(25, 135, 84, 0.1) !important; }
.bg-light-danger { background: rgba(220, 53, 69, 0.1) !important; }
.bg-light-warning { background: rgba(255, 193, 7, 0.1) !important; }
.bg-light-info { background: rgba(13, 202, 240, 0.1) !important; }

.rounded-circle { border-radius: 50% !important; }
.rounded-pill { border-radius: 50rem !important; }

.shadow-sm { box-shadow: var(--box-shadow) !important; }
.shadow { box-shadow: var(--box-shadow-lg) !important; }

/* ============================================
   RESPONSIVO
============================================ */
@media (max-width: 991.98px) {
    .sidebar {
        transform: translateX(-100%);
        width: var(--sidebar-width);
    }
    
    .sidebar.show {
        transform: translateX(0);
    }
    
    .sidebar.collapsed {
        width: var(--sidebar-width);
    }
    
    .main-content {
        margin-left: 0;
    }
    
    .sidebar.collapsed + .main-content {
        margin-left: 0;
    }
    
    .sidebar-overlay {
        display: none;
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background: rgba(0, 0, 0, 0.5);
        z-index: 999;
    }
    
    .sidebar.show + .sidebar-overlay {
        display: block;
    }
}

@media (max-width: 767.98px) {
    .main-body {
        padding: 1rem;
    }
    
    .stat-card {
        padding: 1rem;
    }
    
    .stat-card .stat-value {
        font-size: 1.5rem;
    }
    
    .card-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.75rem;
    }
    
    .user-info {
        display: none;
    }
}

/* ============================================
   ANIMAÇÕES
============================================ */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

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

@keyframes slideIn {
    from { transform: translateX(-20px); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

.slide-in {
    animation: slideIn 0.3s ease forwards;
}

/* Loading */
.loading-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid #f3f3f3;
    border-top: 3px solid var(--primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}
