/**
 * Custom CSS
 * Sistema de Cadastro Social - Secretaria de Habitação de Xambioá
 */

:root {
    --primary-color: #0d6efd;
    --secondary-color: #198754;
    --sidebar-width: 260px;
    --sidebar-bg: #1a1f2b;
    --sidebar-text: #8b92a5;
    --sidebar-active: #ffffff;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #f5f7fa 0%, #e4e8ec 100%);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Login Page */
.login-page {
    background: linear-gradient(135deg, #1a1f2b 0%, #2d3748 100%);
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
}

.login-card {
    background: white;
    border-radius: 20px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    overflow: hidden;
    width: 100%;
    max-width: 420px;
}

.login-header {
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--secondary-color) 100%);
    color: white;
    padding: 40px 30px;
    text-align: center;
}

.login-header i {
    font-size: 3rem;
    margin-bottom: 15px;
}

.login-header h2 {
    margin: 0;
    font-weight: 600;
}

.login-header p {
    margin: 10px 0 0;
    opacity: 0.9;
}

.login-body {
    padding: 40px 30px;
}

.login-body .form-control {
    border-radius: 10px;
    padding: 12px 15px;
    border: 2px solid #e9ecef;
    transition: all 0.3s ease;
}

.login-body .form-control:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(13, 110, 253, 0.15);
}

.login-body .input-group-text {
    border-radius: 10px 0 0 10px;
    background: #f8f9fa;
    border: 2px solid #e9ecef;
    border-right: none;
}

.login-body .btn-primary {
    border-radius: 10px;
    padding: 12px 30px;
    font-weight: 600;
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--secondary-color) 100%);
    border: none;
    transition: all 0.3s ease;
}

.login-body .btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 20px rgba(13, 110, 253, 0.4);
}

/* Wrapper and Sidebar */
.wrapper {
    display: flex;
    min-height: calc(100vh - 60px);
}

.sidebar {
    width: var(--sidebar-width);
    background: var(--sidebar-bg);
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    overflow-y: auto;
    transition: all 0.3s ease;
    z-index: 1000;
}

.sidebar-header {
    padding: 25px 20px;
    text-align: center;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.sidebar-header h4 {
    color: white;
    margin: 10px 0 5px;
    font-weight: 600;
}

.sidebar-header span {
    color: var(--sidebar-text);
}

.logo-container {
    width: 60px;
    height: 60px;
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--secondary-color) 100%);
    border-radius: 15px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto;
}

.logo-container i {
    color: white !important;
}

.user-info {
    background: rgba(255, 255, 255, 0.05);
}

.user-info .avatar {
    color: var(--sidebar-text);
}

.user-info strong {
    color: white;
    font-size: 0.9rem;
}

.sidebar .nav-section {
    color: var(--sidebar-text);
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    padding: 15px 20px 5px;
    font-weight: 600;
}

.sidebar .nav-link {
    color: var(--sidebar-text);
    padding: 12px 20px;
    display: flex;
    align-items: center;
    transition: all 0.3s ease;
    border-left: 3px solid transparent;
}

.sidebar .nav-link i {
    width: 20px;
    margin-right: 12px;
    text-align: center;
}

.sidebar .nav-link:hover {
    color: white;
    background: rgba(255, 255, 255, 0.05);
    border-left-color: var(--primary-color);
}

.sidebar .nav-link.active {
    color: white;
    background: rgba(13, 110, 253, 0.2);
    border-left-color: var(--primary-color);
}

/* Main Content */
.main-content {
    margin-left: var(--sidebar-width);
    flex: 1;
    padding: 30px;
}

/* Cards */
.card {
    border: none;
    border-radius: 15px;
    box-shadow: 0 5px 20px rgba(0, 0, 0, 0.08);
    transition: all 0.3s ease;
}

.card:hover {
    transform: translateY(-3px);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.12);
}

.card-header {
    background: transparent;
    border-bottom: 1px solid #e9ecef;
    padding: 20px 25px;
}

.card-body {
    padding: 25px;
}

/* Stats Cards */
.stat-card {
    border-radius: 15px;
    padding: 25px;
    color: white;
    position: relative;
    overflow: hidden;
}

.stat-card::after {
    content: '';
    position: absolute;
    top: -50%;
    right: -50%;
    width: 100%;
    height: 200%;
    background: rgba(255, 255, 255, 0.1);
    transform: rotate(30deg);
}

.stat-card.bg-primary {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%) !important;
}

.stat-card.bg-success {
    background: linear-gradient(135deg, #11998e 0%, #38ef7d 100%) !important;
}

.stat-card.bg-info {
    background: linear-gradient(135deg, #2193b0 0%, #6dd5ed 100%) !important;
}

.stat-card.bg-warning {
    background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%) !important;
}

.stat-card .stat-icon {
    font-size: 3rem;
    opacity: 0.3;
    position: absolute;
    right: 20px;
    top: 50%;
    transform: translateY(-50%);
}

.stat-card h3 {
    font-size: 2.5rem;
    font-weight: 700;
    margin-bottom: 5px;
}

/* Form Styles */
.form-section {
    background: #f8f9fa;
    border-radius: 10px;
    padding: 20px;
    margin-bottom: 25px;
}

.form-section-title {
    color: var(--primary-color);
    font-weight: 600;
    margin-bottom: 20px;
    padding-bottom: 10px;
    border-bottom: 2px solid var(--primary-color);
}

.form-control,
.form-select {
    border-radius: 8px;
    border: 2px solid #e9ecef;
    padding: 10px 15px;
    transition: all 0.3s ease;
}

.form-control:focus,
.form-select:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(13, 110, 253, 0.15);
}

.form-label {
    font-weight: 500;
    color: #495057;
    margin-bottom: 5px;
}

/* Buttons */
.btn {
    border-radius: 8px;
    padding: 10px 20px;
    font-weight: 500;
    transition: all 0.3s ease;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary-color) 0%, #0a58ca 100%);
    border: none;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(13, 110, 253, 0.4);
}

.btn-success {
    background: linear-gradient(135deg, var(--secondary-color) 0%, #146c43 100%);
    border: none;
}

.btn-success:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(25, 135, 84, 0.4);
}

/* Tables */
.table {
    border-radius: 10px;
    overflow: hidden;
}

.table thead th {
    background: var(--sidebar-bg);
    color: white;
    font-weight: 600;
    border: none;
    padding: 15px;
}

.table tbody td {
    padding: 12px 15px;
    vertical-align: middle;
}

.table tbody tr:hover {
    background: rgba(13, 110, 253, 0.05);
}

/* Steps Form */
.steps-indicator {
    display: flex;
    justify-content: center;
    margin-bottom: 30px;
}

.step {
    display: flex;
    align-items: center;
    color: #adb5bd;
}

.step-number {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: #e9ecef;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    margin-right: 10px;
}

.step.active .step-number {
    background: var(--primary-color);
    color: white;
}

.step.completed .step-number {
    background: var(--secondary-color);
    color: white;
}

.step-connector {
    width: 60px;
    height: 3px;
    background: #e9ecef;
    margin: 0 15px;
}

.step.completed+.step-connector,
.step-connector.completed {
    background: var(--secondary-color);
}

/* Photo Upload */
.photo-upload-container {
    text-align: center;
    padding: 20px;
}

.photo-preview {
    width: 200px;
    height: 200px;
    border-radius: 50%;
    background: #e9ecef;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 20px;
    overflow: hidden;
    border: 4px solid var(--primary-color);
}

.photo-preview img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.photo-preview i {
    font-size: 4rem;
    color: #adb5bd;
}

/* Webcam Modal */
#webcamVideo {
    width: 100%;
    max-width: 400px;
    border-radius: 10px;
}

/* Footer */
.footer {
    margin-top: auto;
}

/* Alerts */
.alert {
    border-radius: 10px;
    border: none;
}

/* Responsive */
@media (max-width: 992px) {
    .sidebar {
        transform: translateX(-100%);
    }

    .sidebar.show {
        transform: translateX(0);
    }

    .main-content {
        margin-left: 0;
    }
}

/* Print Styles (A4 Optimization) */
@media print {
    @page {
        size: A4;
        margin: 1.5cm;
    }

    body {
        margin: 0;
        padding: 0;
        background: white !important;
        font-family: 'Times New Roman', Times, serif;
        /* More formal for documents */
        font-size: 12pt;
        color: #000;
    }

    /* Hide web interface elements */
    .sidebar,
    .footer,
    .btn,
    .no-print,
    .print-hide,
    .navbar,
    form,
    .alert,
    .breadcrumb-item,
    .page-header-actions {
        display: none !important;
    }

    .main-content {
        margin-left: 0 !important;
        padding: 0 !important;
        width: 100% !important;
    }

    /* Container fixes */
    .container,
    .container-fluid,
    .card,
    .card-body {
        width: 100% !important;
        padding: 0 !important;
        margin: 0 !important;
        border: none !important;
        box-shadow: none !important;
    }

    /* Table optimization */
    .table {
        width: 100% !important;
        border-collapse: collapse !important;
        margin-bottom: 20px !important;
        font-size: 10pt;
        /* Slightly smaller for tables to fit more data */
    }

    .table th,
    .table td {
        border: 1px solid #000 !important;
        padding: 6px 8px !important;
        background-color: transparent !important;
        color: #000 !important;
    }

    .table thead th {
        background-color: #f0f0f0 !important;
        /* Light grey for header */
        font-weight: bold;
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }

    /* Ensure header shows up */
    .print-show {
        display: block !important;
        margin-bottom: 20px;
    }

    /* Badges to text */
    .badge {
        border: none !important;
        padding: 0 !important;
        font-weight: normal;
        color: #000 !important;
        background: none !important;
    }

    /* Break page rules */
    tr {
        page-break-inside: avoid;
    }

    h4,
    h5 {
        page-break-after: avoid;
        margin-top: 20px;
        margin-bottom: 10px;
    }

    /* Grid system for print */
    .row {
        display: flex;
        flex-wrap: wrap;
        margin-right: -15px;
        margin-left: -15px;
    }

    .col-md-3,
    .col-md-4,
    .col-md-6,
    .col-md-12 {
        position: relative;
        width: 100%;
        padding-right: 15px;
        padding-left: 15px;
    }

    /* Force column widths for print since Bootstrap grid might fail on some print drivers */
    .col-md-6 {
        width: 50% !important;
        float: left;
    }

    .col-md-4 {
        width: 33.33% !important;
        float: left;
    }

    .col-md-3 {
        width: 25% !important;
        float: left;
    }

    .col-md-12 {
        width: 100% !important;
        float: left;
    }

    /* Signature lines */
    .signature-line {
        margin-top: 50px;
        border-top: 1px solid #000;
        width: 80%;
        margin-left: auto;
        margin-right: auto;
        padding-top: 5px;
    }
}