/**
 * ENSA Obras - Sistema de Gestão de Obras
 * Estilos Principais
 */

:root {
    --primary-color: #2563eb;
    --primary-dark: #1d4ed8;
    --primary-light: #3b82f6;
    --secondary-color: #10b981;
    --secondary-dark: #059669;
    --success-color: #22c55e;
    --warning-color: #f59e0b;
    --danger-color: #ef4444;
    --info-color: #06b6d4;
    
    --sidebar-width: 260px;
    --sidebar-collapsed-width: 70px;
    --topbar-height: 60px;
    
    --bg-primary: #f8fafc;
    --bg-secondary: #ffffff;
    --bg-sidebar: #1e293b;
    --bg-sidebar-hover: #334155;
    
    --text-primary: #1e293b;
    --text-secondary: #64748b;
    --text-muted: #94a3b8;
    --text-light: #f1f5f9;
    
    --border-color: #e2e8f0;
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow: 0 1px 3px 0 rgb(0 0 0 / 0.1), 0 1px 2px -1px rgb(0 0 0 / 0.1);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
    
    --radius-sm: 0.375rem;
    --radius: 0.5rem;
    --radius-lg: 0.75rem;
    --radius-xl: 1rem;
    
    --transition: all 0.3s ease;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    font-size: 14px;
    line-height: 1.6;
    color: var(--text-primary);
    background-color: var(--bg-primary);
}

/* ===== SIDEBAR ===== */
.sidebar {
    position: fixed;
    top: 0;
    left: 0;
    width: var(--sidebar-width);
    height: 100vh;
    background: var(--bg-sidebar);
    color: var(--text-light);
    z-index: 1000;
    transition: var(--transition);
    overflow-y: auto;
    overflow-x: hidden;
}

.sidebar::-webkit-scrollbar {
    width: 6px;
}

.sidebar::-webkit-scrollbar-thumb {
    background: var(--bg-sidebar-hover);
    border-radius: 3px;
}

.sidebar-header {
    padding: 1.25rem;
    border-bottom: 1px solid rgba(255,255,255,0.1);
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    color: var(--text-light);
    text-decoration: none;
    font-size: 1.25rem;
    font-weight: 700;
}

.sidebar-brand i {
    font-size: 1.5rem;
    color: var(--primary-light);
}

.sidebar-nav {
    list-style: none;
    padding: 1rem 0;
}

.nav-header {
    padding: 0.75rem 1.25rem 0.5rem;
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
}

.nav-item .nav-link {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1.25rem;
    color: var(--text-light);
    text-decoration: none;
    transition: var(--transition);
    border-left: 3px solid transparent;
}

.nav-item .nav-link:hover {
    background: var(--bg-sidebar-hover);
    border-left-color: var(--primary-light);
}

.nav-item .nav-link.active {
    background: var(--bg-sidebar-hover);
    border-left-color: var(--primary-color);
    color: var(--primary-light);
}

.nav-item .nav-link i {
    font-size: 1.1rem;
    width: 24px;
    text-align: center;
}

.sidebar-footer {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 1rem 1.25rem;
    border-top: 1px solid rgba(255,255,255,0.1);
    background: var(--bg-sidebar);
}

.user-info {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.user-info i {
    font-size: 2rem;
    color: var(--text-muted);
}

.user-info strong {
    display: block;
    font-size: 0.875rem;
}

.user-info small {
    color: var(--text-muted);
    font-size: 0.75rem;
}

/* ===== MAIN CONTENT ===== */
.main-content {
    margin-left: var(--sidebar-width);
    min-height: 100vh;
    transition: var(--transition);
}

.top-navbar {
    position: sticky;
    top: 0;
    height: var(--topbar-height);
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    padding: 0 1.5rem;
    gap: 1rem;
    z-index: 100;
}

.sidebar-toggle {
    font-size: 1.5rem;
    color: var(--text-secondary);
    padding: 0;
}

.navbar-search {
    flex: 1;
    max-width: 400px;
    position: relative;
}

.navbar-search i {
    position: absolute;
    left: 1rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
}

.navbar-search input {
    padding-left: 2.5rem;
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-color);
    background: var(--bg-primary);
}

.navbar-search input:focus {
    background: var(--bg-secondary);
    box-shadow: none;
    border-color: var(--primary-color);
}

.navbar-actions {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-left: auto;
}

.notification-btn, .user-btn {
    position: relative;
    font-size: 1.25rem;
    color: var(--text-secondary);
    padding: 0.5rem;
}

.notification-badge {
    position: absolute;
    top: 0;
    right: 0;
    width: 18px;
    height: 18px;
    background: var(--danger-color);
    color: white;
    font-size: 0.65rem;
    font-weight: 600;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.notification-dropdown {
    width: 320px;
    max-height: 400px;
    overflow-y: auto;
}

.notification-item {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--border-color);
}

.notification-item i {
    font-size: 1.25rem;
    margin-top: 0.125rem;
}

.notification-item.danger i { color: var(--danger-color); }
.notification-item.warning i { color: var(--warning-color); }
.notification-item.info i { color: var(--info-color); }
.notification-item.success i { color: var(--success-color); }

.notification-item div {
    flex: 1;
}

.notification-item strong {
    display: block;
    font-size: 0.875rem;
    margin-bottom: 0.125rem;
}

.notification-item small {
    color: var(--text-secondary);
    font-size: 0.75rem;
}

.page-content {
    padding: 1.5rem;
}

/* ===== PAGE HEADER ===== */
.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
    gap: 1rem;
}

.page-title {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-primary);
    margin: 0;
}

.page-title i {
    color: var(--primary-color);
    margin-right: 0.5rem;
}

.breadcrumb {
    margin: 0;
    padding: 0;
    background: transparent;
    font-size: 0.875rem;
}

/* ===== CARDS ===== */
.card {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    transition: var(--transition);
}

.card:hover {
    box-shadow: var(--shadow);
}

.card-header {
    background: transparent;
    border-bottom: 1px solid var(--border-color);
    padding: 1rem 1.25rem;
    font-weight: 600;
}

.card-body {
    padding: 1.25rem;
}

.card-footer {
    background: var(--bg-primary);
    border-top: 1px solid var(--border-color);
    padding: 1rem 1.25rem;
}

/* Stats Cards */
.stat-card {
    position: relative;
    overflow: hidden;
}

.stat-card .stat-icon {
    position: absolute;
    right: 1rem;
    top: 50%;
    transform: translateY(-50%);
    font-size: 4rem;
    opacity: 0.1;
}

.stat-card .stat-value {
    font-size: 2rem;
    font-weight: 700;
    line-height: 1.2;
}

.stat-card .stat-label {
    color: var(--text-secondary);
    font-size: 0.875rem;
    margin-top: 0.25rem;
}

.stat-card .stat-change {
    font-size: 0.75rem;
    margin-top: 0.5rem;
}

.stat-card .stat-change.positive { color: var(--success-color); }
.stat-card .stat-change.negative { color: var(--danger-color); }

.stat-card.primary { border-left: 4px solid var(--primary-color); }
.stat-card.success { border-left: 4px solid var(--success-color); }
.stat-card.warning { border-left: 4px solid var(--warning-color); }
.stat-card.danger { border-left: 4px solid var(--danger-color); }
.stat-card.info { border-left: 4px solid var(--info-color); }

/* ===== TABLES ===== */
.table-container {
    background: var(--bg-secondary);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-color);
    overflow: hidden;
}

.table {
    margin-bottom: 0;
}

.table thead th {
    background: var(--bg-primary);
    border-bottom: 2px solid var(--border-color);
    font-weight: 600;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-secondary);
    padding: 1rem;
}

.table tbody td {
    padding: 1rem;
    vertical-align: middle;
    border-bottom: 1px solid var(--border-color);
}

.table tbody tr:hover {
    background: var(--bg-primary);
}

.table tbody tr:last-child td {
    border-bottom: none;
}

/* ===== BUTTONS ===== */
.btn {
    font-weight: 500;
    padding: 0.5rem 1rem;
    border-radius: var(--radius);
    transition: var(--transition);
}

.btn-primary {
    background: var(--primary-color);
    border-color: var(--primary-color);
}

.btn-primary:hover {
    background: var(--primary-dark);
    border-color: var(--primary-dark);
}

.btn-success {
    background: var(--success-color);
    border-color: var(--success-color);
}

.btn-outline-primary {
    color: var(--primary-color);
    border-color: var(--primary-color);
}

.btn-outline-primary:hover {
    background: var(--primary-color);
    color: white;
}

.btn-icon {
    width: 36px;
    height: 36px;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius);
}

/* ===== FORMS ===== */
.form-control, .form-select {
    border-radius: var(--radius);
    border-color: var(--border-color);
    padding: 0.625rem 1rem;
}

.form-control:focus, .form-select:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.form-label {
    font-weight: 500;
    margin-bottom: 0.5rem;
    color: var(--text-primary);
}

.form-text {
    color: var(--text-muted);
    font-size: 0.75rem;
}

/* ===== BADGES ===== */
.badge {
    font-weight: 500;
    padding: 0.375rem 0.75rem;
    border-radius: var(--radius);
}

/* ===== PROGRESS ===== */
.progress {
    height: 8px;
    border-radius: var(--radius);
    background: var(--bg-primary);
}

.progress-bar {
    border-radius: var(--radius);
}

.progress-lg {
    height: 12px;
}

/* ===== ALERTS ===== */
.alert {
    border-radius: var(--radius);
    border: none;
    padding: 1rem 1.25rem;
}

.alert-dismissible .btn-close {
    padding: 1.25rem;
}

/* ===== MODALS ===== */
.modal-content {
    border: none;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
}

.modal-header {
    border-bottom: 1px solid var(--border-color);
    padding: 1.25rem;
}

.modal-body {
    padding: 1.25rem;
}

.modal-footer {
    border-top: 1px solid var(--border-color);
    padding: 1rem 1.25rem;
}

/* ===== CHARTS ===== */
.chart-container {
    position: relative;
    height: 300px;
}

.chart-container.chart-lg {
    height: 400px;
}

/* ===== TIMELINE ===== */
.timeline {
    position: relative;
    padding-left: 2rem;
}

.timeline::before {
    content: '';
    position: absolute;
    left: 0.5rem;
    top: 0;
    bottom: 0;
    width: 2px;
    background: var(--border-color);
}

.timeline-item {
    position: relative;
    padding-bottom: 1.5rem;
}

.timeline-item::before {
    content: '';
    position: absolute;
    left: -1.75rem;
    top: 0.25rem;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: var(--primary-color);
    border: 2px solid var(--bg-secondary);
}

.timeline-item.completed::before {
    background: var(--success-color);
}

.timeline-item.warning::before {
    background: var(--warning-color);
}

.timeline-item.danger::before {
    background: var(--danger-color);
}

.timeline-content {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    padding: 1rem;
}

.timeline-date {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-bottom: 0.25rem;
}

.timeline-title {
    font-weight: 600;
    margin-bottom: 0.25rem;
}

/* ===== GANTT CHART ===== */
.gantt-container {
    overflow-x: auto;
    background: var(--bg-secondary);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-color);
}

.gantt-row {
    display: flex;
    align-items: center;
    border-bottom: 1px solid var(--border-color);
    min-height: 50px;
}

.gantt-label {
    width: 200px;
    flex-shrink: 0;
    padding: 0.75rem 1rem;
    font-weight: 500;
    background: var(--bg-primary);
    border-right: 1px solid var(--border-color);
}

.gantt-bar-container {
    flex: 1;
    padding: 0.5rem;
    position: relative;
}

.gantt-bar {
    height: 30px;
    border-radius: var(--radius);
    position: relative;
}

.gantt-bar.critical {
    background: linear-gradient(135deg, var(--danger-color), #dc2626);
}

.gantt-bar.normal {
    background: linear-gradient(135deg, var(--primary-color), var(--primary-dark));
}

.gantt-bar.completed {
    background: linear-gradient(135deg, var(--success-color), #16a34a);
}

/* ===== RISK MATRIX ===== */
.risk-matrix {
    display: grid;
    grid-template-columns: auto repeat(4, 1fr);
    gap: 2px;
    background: var(--border-color);
    border-radius: var(--radius);
    overflow: hidden;
}

.risk-matrix-cell {
    padding: 1rem;
    text-align: center;
    background: var(--bg-secondary);
    font-size: 0.875rem;
}

.risk-matrix-header {
    background: var(--bg-primary);
    font-weight: 600;
}

.risk-matrix-cell.low { background: #dcfce7; }
.risk-matrix-cell.medium { background: #fef3c7; }
.risk-matrix-cell.high { background: #fee2e2; }
.risk-matrix-cell.critical { background: #fecaca; }

/* ===== RESPONSIVE ===== */
@media (max-width: 992px) {
    .sidebar {
        transform: translateX(-100%);
    }
    
    .sidebar.show {
        transform: translateX(0);
    }
    
    .main-content {
        margin-left: 0;
    }
}

@media (max-width: 768px) {
    .page-header {
        flex-direction: column;
        align-items: flex-start;
    }
    
    .navbar-search {
        display: none;
    }
    
    .stat-card .stat-value {
        font-size: 1.5rem;
    }
}

/* ===== UTILITIES ===== */
.text-primary { color: var(--primary-color) !important; }
.text-success { color: var(--success-color) !important; }
.text-warning { color: var(--warning-color) !important; }
.text-danger { color: var(--danger-color) !important; }
.text-info { color: var(--info-color) !important; }

.bg-primary-light { background: rgba(37, 99, 235, 0.1) !important; }
.bg-success-light { background: rgba(34, 197, 94, 0.1) !important; }
.bg-warning-light { background: rgba(245, 158, 11, 0.1) !important; }
.bg-danger-light { background: rgba(239, 68, 68, 0.1) !important; }

.rounded-lg { border-radius: var(--radius-lg) !important; }
.rounded-xl { border-radius: var(--radius-xl) !important; }

.shadow-sm { box-shadow: var(--shadow-sm) !important; }
.shadow { box-shadow: var(--shadow) !important; }
.shadow-md { box-shadow: var(--shadow-md) !important; }
.shadow-lg { box-shadow: var(--shadow-lg) !important; }

/* ===== ANIMATIONS ===== */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.fade-in {
    animation: fadeIn 0.3s ease-out;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

.pulse {
    animation: pulse 2s infinite;
}

/* ===== LOGIN PAGE ===== */
.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-dark) 100%);
    padding: 1rem;
}

.login-card {
    width: 100%;
    max-width: 420px;
    background: var(--bg-secondary);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-lg);
    overflow: hidden;
}

.login-header {
    background: var(--bg-primary);
    padding: 2rem;
    text-align: center;
}

.login-logo {
    font-size: 3rem;
    color: var(--primary-color);
    margin-bottom: 0.5rem;
}

.login-title {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-primary);
    margin: 0;
}

.login-subtitle {
    color: var(--text-secondary);
    font-size: 0.875rem;
    margin-top: 0.25rem;
}

.login-body {
    padding: 2rem;
}

.login-footer {
    padding: 1rem 2rem 2rem;
    text-align: center;
}

/* ===== PUBLIC PAGE ===== */
.public-page {
    background: var(--bg-primary);
    min-height: 100vh;
}

.public-header {
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-dark) 100%);
    color: white;
    padding: 3rem 1rem;
    text-align: center;
}

.public-logo {
    font-size: 4rem;
    margin-bottom: 1rem;
}

.public-title {
    font-size: 2rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
}

.public-subtitle {
    opacity: 0.9;
    font-size: 1.1rem;
}

.public-content {
    max-width: 1200px;
    margin: -2rem auto 2rem;
    padding: 0 1rem;
}

/* ===== PRINT STYLES ===== */
@media print {
    .sidebar, .top-navbar, .btn, .no-print {
        display: none !important;
    }
    
    .main-content {
        margin-left: 0 !important;
    }
    
    .page-content {
        padding: 0 !important;
    }
    
    .card {
        box-shadow: none !important;
        border: 1px solid #ddd !important;
    }
}
