@import url('https://fonts.googleapis.com/css2?family=Roboto:wght@300;400;500;700;900&display=swap');

:root {
    --bg-primary: #0a0606;
    --bg-secondary: #140d0d;
    --bg-glass: rgba(20, 13, 13, 0.75);
    --border-glass: rgba(255, 255, 255, 0.08);
    --border-glass-hover: rgba(255, 255, 255, 0.16);
    
    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    
    --accent-red: #790000;
    --accent-red-hover: #9c0000;
    --accent-gold: #e3a14d;
    --accent-gold-hover: #f3b15d;
    
    --accent-color: var(--accent-red);
    --accent-color-hover: var(--accent-red-hover);
    --accent-success: #10b981;
    --accent-danger: #ef4444;
    
    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.2);
    --shadow-md: 0 8px 30px rgba(0, 0, 0, 0.35);
    --shadow-glass: 0 8px 32px 0 rgba(0, 0, 0, 0.37);
    
    --font-main: 'Roboto', sans-serif;
    --transition-fast: 0.2s ease;
    --transition-normal: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: var(--font-main);
    background-color: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    overflow-x: hidden;
    line-height: 1.6;
    background-image: 
        radial-gradient(circle at 10% 20%, rgba(121, 0, 0, 0.08) 0%, transparent 40%),
        radial-gradient(circle at 90% 80%, rgba(227, 161, 77, 0.06) 0%, transparent 40%);
    background-attachment: fixed;
}

/* Scrollbar Customization */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}
::-webkit-scrollbar-track {
    background: var(--bg-primary);
}
::-webkit-scrollbar-thumb {
    background: var(--border-glass);
    border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
    background: var(--border-glass-hover);
}

/* App Container */
.app-container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 2rem 1.5rem;
}

/* Header */
header {
    display: flex;
    flex-direction: column;
    margin-bottom: 2rem;
    padding-bottom: 1.25rem;
    border-bottom: 1px solid var(--border-glass);
    width: 100%;
}

.logo-section {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}

.logo-container {
    display: flex;
    align-items: center;
}

.logo-img {
    height: 52px;
    width: auto;
    object-fit: contain;
}

.logo-section p {
    font-size: 0.8rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 2px;
}

/* Tab Navigation */
.nav-tabs {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-start;
    align-items: center;
    gap: 0.35rem;
    background: var(--bg-secondary);
    padding: 0.4rem;
    border-radius: 12px;
    border: 1px solid var(--border-glass);
    width: 100%;
}

.tab-btn {
    flex: 1 1 auto;
    justify-content: center;
    background: transparent;
    border: none;
    color: var(--text-secondary);
    padding: 0.45rem 0.55rem;
    font-size: 0.8rem;
    font-weight: 500;
    border-radius: 8px;
    cursor: pointer;
    transition: var(--transition-fast);
    display: flex;
    align-items: center;
    gap: 0.35rem;
    white-space: nowrap;
}

.tab-btn:hover {
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.03);
}

.tab-btn.active {
    color: var(--text-primary);
    background: var(--accent-gold);
    box-shadow: 0 4px 12px rgba(227, 161, 77, 0.3);
}

/* Main Views */
.view-section {
    display: none;
    animation: fadeIn var(--transition-normal);
}

.view-section.active {
    display: block;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Card / Glass Panel */
.glass-panel {
    position: relative;
    background: var(--bg-glass);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--border-glass);
    border-radius: 16px;
    padding: 2rem;
    box-shadow: var(--shadow-glass);
}

.glass-panel:focus-within {
    z-index: 10;
}

.panel-title {
    font-size: 1.4rem;
    font-weight: 600;
    margin-bottom: 1.5rem;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 0.75rem;
    border-bottom: 1px solid var(--border-glass);
    padding-bottom: 0.75rem;
}

.panel-title i {
    color: var(--accent-gold);
}

/* Form Styles */
.form-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1.5rem;
}

@media (max-width: 1024px) {
    .form-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 768px) {
    .form-grid {
        grid-template-columns: 1fr;
    }
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.form-group.span-2 {
    grid-column: span 2;
}

.form-group.span-3 {
    grid-column: span 3;
}

@media (max-width: 768px) {
    .form-group.span-2, .form-group.span-3 {
        grid-column: span 1;
    }
}

label {
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-secondary);
    letter-spacing: 0.5px;
}

label span.required {
    color: var(--accent-danger);
    margin-left: 2px;
}

input, select, textarea {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border-glass);
    border-radius: 8px;
    padding: 0.75rem 1rem;
    color: var(--text-primary);
    font-family: var(--font-main);
    font-size: 0.95rem;
    transition: var(--transition-fast);
    outline: none;
    width: 100%;
}

input:focus, select:focus, textarea:focus {
    border-color: var(--accent-gold);
    background: rgba(255, 255, 255, 0.06);
    box-shadow: 0 0 0 3px rgba(227, 161, 77, 0.15);
}

select option {
    background: var(--bg-secondary);
    color: var(--text-primary);
}

textarea {
    resize: vertical;
    min-height: 100px;
}

.form-actions {
    display: flex;
    justify-content: flex-end;
    gap: 1rem;
    margin-top: 2rem;
    grid-column: 1 / -1;
}

@media (max-width: 768px) {
    .form-actions {
        flex-direction: column;
    }
}

/* Fieldset and Form Blocks styling */
.form-section {
    border: 1px solid var(--border-glass);
    border-radius: 12px;
    padding: 1.5rem;
    margin-bottom: 2rem;
    background: rgba(255, 255, 255, 0.01);
    grid-column: 1 / -1;
}

.form-section legend {
    font-size: 1.05rem;
    font-weight: 600;
    color: var(--accent-gold);
    padding: 0 0.75rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.form-section .form-grid {
    margin-top: 0.5rem;
}

/* Button Styles */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.75rem 1.75rem;
    font-size: 0.95rem;
    font-weight: 600;
    border-radius: 8px;
    border: none;
    cursor: pointer;
    transition: var(--transition-fast);
    text-decoration: none;
}

.btn-primary {
    background: var(--accent-color);
    color: white;
    box-shadow: 0 4px 14px rgba(121, 0, 0, 0.35);
}

.btn-primary:hover {
    background: var(--accent-color-hover);
    transform: translateY(-1px);
    box-shadow: 0 6px 20px rgba(121, 0, 0, 0.45);
}

.btn-secondary {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-secondary);
    border: 1px solid var(--border-glass);
}

.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.08);
    color: var(--text-primary);
    border-color: var(--border-glass-hover);
}

.btn-danger {
    background: rgba(239, 68, 68, 0.1);
    color: var(--accent-danger);
    border: 1px solid rgba(239, 68, 68, 0.2);
}

.btn-danger:hover {
    background: var(--accent-danger);
    color: white;
}

/* Dashboard KPIs */
.kpi-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 1.5rem;
    margin-bottom: 2rem;
}

@media (max-width: 1024px) {
    .kpi-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 576px) {
    .kpi-grid {
        grid-template-columns: 1fr;
    }
}

.kpi-card {
    background: var(--bg-glass);
    border: 1px solid var(--border-glass);
    border-radius: 12px;
    padding: 1.25rem 1.5rem;
    display: flex;
    align-items: center;
    gap: 1rem;
    transition: var(--transition-fast);
}

.kpi-card:hover {
    border-color: var(--border-glass-hover);
    transform: translateY(-2px);
}

.kpi-icon {
    width: 48px;
    height: 48px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
}

.kpi-icon.blue {
    background: rgba(121, 0, 0, 0.1);
    color: var(--accent-red);
}

.kpi-icon.gold {
    background: rgba(227, 161, 77, 0.15);
    color: var(--accent-gold);
}

.kpi-icon.green {
    background: rgba(16, 185, 129, 0.1);
    color: var(--accent-success);
}

.kpi-icon.red {
    background: rgba(239, 68, 68, 0.1);
    color: var(--accent-danger);
}

.kpi-info {
    display: flex;
    flex-direction: column;
}

.kpi-value {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-primary);
}

.kpi-label {
    font-size: 0.8rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Dashboard Filter Bar */
.filter-bar {
    display: flex;
    gap: 1rem;
    align-items: flex-end;
    flex-wrap: wrap;
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid var(--border-glass);
    padding: 1.25rem;
    border-radius: 12px;
    margin-bottom: 1.5rem;
}

.filter-group {
    flex: 1;
    min-width: 180px;
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}

.filter-group.search {
    flex: 2;
    min-width: 250px;
}

.filter-actions {
    display: flex;
    gap: 0.75rem;
}

@media (max-width: 768px) {
    .filter-bar {
        flex-direction: column;
        align-items: stretch;
    }
    .filter-actions {
        margin-top: 1rem;
        justify-content: flex-end;
    }
}

/* Data Table Panel */
.table-container {
    overflow-x: auto;
    border-radius: 12px;
    border: 1px solid var(--border-glass);
    background: rgba(255, 255, 255, 0.01);
}

table {
    width: 100%;
    border-collapse: collapse;
    text-align: left;
    font-size: 0.9rem;
}

th {
    background: rgba(255, 255, 255, 0.03);
    padding: 1rem;
    font-weight: 600;
    color: var(--text-secondary);
    border-bottom: 1px solid var(--border-glass);
    white-space: nowrap;
}

td {
    padding: 1rem;
    border-bottom: 1px solid var(--border-glass);
    color: var(--text-primary);
    white-space: nowrap;
}

tr:hover td {
    background: rgba(255, 255, 255, 0.015);
}

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

/* Badges */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 0.25rem 0.6rem;
    font-size: 0.75rem;
    font-weight: 600;
    border-radius: 9999px;
    text-transform: uppercase;
}

.badge-blue {
    background: rgba(121, 0, 0, 0.15);
    color: #ffa3a3;
}

.badge-gold {
    background: rgba(227, 161, 77, 0.15);
    color: #f3b15d;
}

.badge-green {
    background: rgba(16, 185, 129, 0.15);
    color: #34d399;
}

.badge-red {
    background: rgba(239, 68, 68, 0.15);
    color: #f87171;
}

/* Actions Column */
.table-actions {
    display: flex;
    gap: 0.5rem;
}

.icon-btn {
    background: transparent;
    border: none;
    width: 32px;
    height: 32px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: var(--transition-fast);
    color: var(--text-secondary);
}

.icon-btn:hover {
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.05);
}

.icon-btn.delete:hover {
    color: var(--accent-danger);
    background: rgba(239, 68, 68, 0.1);
}

/* Empty State */
.empty-state {
    padding: 3.5rem 2rem;
    text-align: center;
    color: var(--text-secondary);
}

.empty-state i {
    font-size: 3rem;
    color: var(--text-muted);
    margin-bottom: 1rem;
}

.empty-state p {
    font-size: 0.95rem;
}

/* Loading Overlay */
.loading-spinner {
    display: inline-block;
    width: 24px;
    height: 24px;
    border: 3px solid rgba(255, 255, 255, 0.1);
    border-radius: 50%;
    border-top-color: var(--accent-gold);
    animation: spin 1s ease-in-out infinite;
}

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

/* Toast Notifications */
.toast-container {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    z-index: 1000;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.toast {
    background: var(--bg-secondary);
    border-left: 4px solid var(--accent-color);
    color: var(--text-primary);
    padding: 1rem 1.5rem;
    border-radius: 8px;
    box-shadow: var(--shadow-md);
    display: flex;
    align-items: center;
    gap: 0.75rem;
    min-width: 300px;
    max-width: 450px;
    animation: slideIn 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    border-top: 1px solid var(--border-glass);
    border-right: 1px solid var(--border-glass);
    border-bottom: 1px solid var(--border-glass);
}

.toast.success {
    border-left-color: var(--accent-success);
}

.toast.error {
    border-left-color: var(--accent-danger);
}

.toast i {
    font-size: 1.2rem;
}

.toast.success i {
    color: var(--accent-success);
}

.toast.error i {
    color: var(--accent-danger);
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateX(100%);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

.toast.fade-out {
    animation: fadeOut 0.4s ease forwards;
}

@keyframes fadeOut {
    to {
        opacity: 0;
        transform: translateY(20px);
    }
}

/* Autocomplete Combobox Styles */
.autocomplete-container {
    position: relative;
    width: 100%;
}

.autocomplete-list {
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    width: 100%;
    max-height: 220px;
    overflow-y: auto;
    background: var(--bg-secondary);
    border: 1px solid var(--border-glass);
    border-radius: 8px;
    z-index: 100;
    box-shadow: var(--shadow-md);
    display: none;
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
}

.autocomplete-list.active {
    display: block;
    animation: fadeInFast 0.15s ease-out;
}

.autocomplete-item {
    padding: 0.75rem 1rem;
    cursor: pointer;
    font-size: 0.9rem;
    color: var(--text-primary);
    transition: var(--transition-fast);
    border-bottom: 1px solid rgba(255, 255, 255, 0.02);
}

.autocomplete-item:last-child {
    border-bottom: none;
}

.autocomplete-item:hover {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-primary);
    padding-left: 1.25rem;
    border-left: 3px solid var(--accent-gold);
}

.autocomplete-no-results {
    padding: 0.75rem 1rem;
    color: var(--text-muted);
    font-size: 0.9rem;
    font-style: italic;
}

@keyframes fadeInFast {
    from {
        opacity: 0;
        transform: translateY(-5px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Modal de Edição (Overlay & Content) */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(4, 7, 13, 0.7);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

.modal-overlay.active {
    opacity: 1;
    pointer-events: auto;
}

.modal-content {
    width: 90%;
    max-width: 950px;
    max-height: 90vh;
    overflow-y: auto;
    background: var(--bg-glass);
    border: 1px solid var(--border-glass);
    box-shadow: var(--shadow-md);
    transform: scale(0.9) translateY(20px);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.modal-overlay.active .modal-content {
    transform: scale(1) translateY(0);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--border-glass);
    padding-bottom: 0.75rem;
    margin-bottom: 1.5rem;
}

/* Login Overlay and Card */
.login-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: var(--bg-primary);
    background-image: 
        radial-gradient(circle at 20% 30%, rgba(121, 0, 0, 0.12) 0%, transparent 50%),
        radial-gradient(circle at 80% 70%, rgba(227, 161, 77, 0.08) 0%, transparent 50%);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
}

.login-card {
    width: 90%;
    max-width: 420px;
    padding: 2.5rem;
    border-radius: 16px;
    box-shadow: var(--shadow-glass);
    border: 1px solid var(--border-glass);
    background: var(--bg-glass);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    animation: loginFadeIn 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes loginFadeIn {
    from {
        opacity: 0;
        transform: translateY(20px) scale(0.95);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

/* User Profile Info in Header */
.user-profile {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid var(--border-glass);
    padding: 0.4rem 0.8rem;
    border-radius: 8px;
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.user-profile #user-email-display {
    color: var(--text-primary);
    font-weight: 500;
}

.user-profile .icon-btn.logout:hover {
    color: var(--accent-danger) !important;
    background: rgba(239, 68, 68, 0.1);
    border-radius: 4px;
}

/* Convenção Contracheque Checklist styling */
.contrato-checkbox-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem;
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid var(--border-glass);
    border-radius: 8px;
    cursor: pointer;
    transition: var(--transition-fast);
}

.contrato-checkbox-item:hover {
    background: rgba(255, 255, 255, 0.05);
    border-color: var(--border-glass-hover);
}

.contrato-checkbox-item input[type="checkbox"] {
    width: 18px;
    height: 18px;
    cursor: pointer;
    accent-color: var(--accent-gold);
}

.contrato-checkbox-item label {
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
    cursor: pointer;
    flex: 1;
}

.contrato-checkbox-item .contrato-code {
    font-weight: 600;
    color: var(--accent-gold);
    font-size: 0.95rem;
}

.contrato-checkbox-item .contrato-title {
    color: var(--text-secondary);
    font-size: 0.8rem;
}

#search-contratos-input {
    width: 100%;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border-glass);
    border-radius: 8px;
    padding: 0.75rem 1rem;
    color: var(--text-primary);
    outline: none;
    font-size: 0.95rem;
    transition: var(--transition-fast);
}

#search-contratos-input:focus {
    border-color: var(--accent-gold);
    box-shadow: 0 0 0 3px rgba(227, 161, 77, 0.15);
}

/* Table Input styles for Regra Geral Extra */
/* BI Sub-dashboard Selector Buttons */
.bi-btn {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border-glass);
    color: var(--text-secondary);
    padding: 0.6rem 1.2rem;
    border-radius: 8px;
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    transition: all 0.3s ease;
}

.bi-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-primary);
    border-color: var(--accent-gold);
    transform: translateY(-1px);
}

.bi-btn.active {
    background: linear-gradient(135deg, rgba(234, 179, 8, 0.2), rgba(202, 138, 4, 0.3));
    border-color: #eab308;
    color: #fef08a;
    box-shadow: 0 4px 12px rgba(234, 179, 8, 0.2);
}
.form-grid-2 {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1.5rem;
}

.form-grid-1 {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1.5rem;
}

@media (max-width: 768px) {
    .form-grid-2 {
        grid-template-columns: 1fr;
    }
}
