/* --- Base & Reset --- */
:root {
    /* Color Palette - Premium Corporate Dark Theme */
    --bg-base: #0f172a;
    /* Deep slate background */
    --bg-surface: #1e293b;
    /* Card/Sidebar background */
    --bg-surface-elevated: #334155;

    --primary: #3b82f6;
    /* Bright blue */
    --primary-hover: #2563eb;
    --primary-light: rgba(59, 130, 246, 0.1);

    --danger: #ef4444;
    /* Red for AGE */
    --danger-light: rgba(239, 68, 68, 0.1);
    --success: #10b981;
    /* Green for AGO */
    --text-main: #f8fafc;
    --text-muted: #94a3b8;

    --border: rgba(255, 255, 255, 0.08);
    --border-light: rgba(255, 255, 255, 0.15);

    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);

    /* Typography */
    --font-family: 'Outfit', sans-serif;

    /* Layout */
    --sidebar-width: 280px;
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

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

body {
    font-family: var(--font-family);
    background-color: var(--bg-base);
    color: var(--text-main);
    min-height: 100vh;
    overflow-x: hidden;
    line-height: 1.5;
}

/* --- Layout --- */
.app-container {
    display: flex;
    height: 100vh;
}

/* --- Sidebar --- */
.sidebar {
    width: var(--sidebar-width);
    background-color: var(--bg-surface);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    padding: 24px;
    z-index: 10;
    box-shadow: 4px 0 24px rgba(0, 0, 0, 0.2);
}

.brand {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 48px;
    color: var(--primary);
}

.brand i {
    font-size: 32px;
    background: linear-gradient(135deg, #60a5fa, #3b82f6);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.brand h2 {
    font-size: 22px;
    font-weight: 600;
    color: var(--text-main);
    letter-spacing: -0.5px;
}

.nav-menu {
    display: flex;
    flex-direction: column;
    gap: 8px;
    flex: 1;
}

.nav-btn {
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-family: var(--font-family);
    font-size: 15px;
    font-weight: 500;
    padding: 14px 16px;
    border-radius: var(--radius-md);
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 12px;
    transition: var(--transition);
    text-align: left;
}

.nav-btn i {
    font-size: 20px;
    transition: var(--transition);
}

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

.nav-btn.active {
    background-color: var(--primary-light);
    color: var(--primary);
    border-right: 3px solid var(--primary);
}

.nav-btn.active i {
    color: var(--primary);
    font-weight: bold;
}

.user-profile {
    display: flex;
    align-items: center;
    gap: 12px;
    padding-top: 24px;
    border-top: 1px solid var(--border);
    margin-top: auto;
}

.avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background-color: var(--bg-surface-elevated);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--primary);
}

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

.user-name {
    font-size: 14px;
    font-weight: 600;
}

.user-role {
    font-size: 12px;
    color: var(--text-muted);
}

/* --- Main Content --- */
.main-content {
    flex: 1;
    overflow-y: auto;
    position: relative;
    background: radial-gradient(circle at top right, rgba(59, 130, 246, 0.05), transparent 40%),
        var(--bg-base);
}

.view-section {
    display: none;
    padding: 48px;
    max-width: 1200px;
    margin: 0 auto;
    animation: fadeIn 0.4s ease-out;
}

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

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

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.section-header {
    margin-bottom: 40px;
}

.header-titles h1 {
    font-size: 32px;
    font-weight: 600;
    margin-bottom: 8px;
    letter-spacing: -1px;
}

.header-titles p {
    color: var(--text-muted);
    font-size: 16px;
}

/* --- Forms & Inputs --- */
.glass-form {
    background: rgba(30, 41, 59, 0.6);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 32px;
    box-shadow: var(--shadow-lg);
}

.form-section {
    margin-bottom: 32px;
}

.form-section h3 {
    font-size: 18px;
    font-weight: 500;
    margin-bottom: 24px;
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--primary);
    border-bottom: 1px solid var(--border);
    padding-bottom: 12px;
}

.form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 24px;
}

.input-group.full-width {
    grid-column: 1 / -1;
}

.input-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.input-group label {
    font-size: 14px;
    color: var(--text-muted);
    font-weight: 500;
}

input[type="text"],
input[type="date"],
input[type="time"],
textarea,
select {
    width: 100%;
    background-color: rgba(15, 23, 42, 0.6);
    border: 1px solid var(--border-light);
    color: var(--text-main);
    padding: 12px 16px;
    border-radius: var(--radius-md);
    font-family: var(--font-family);
    font-size: 15px;
    transition: var(--transition);
    outline: none;
}

input:focus,
textarea:focus,
select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-light);
    background-color: rgba(15, 23, 42, 0.9);
}

/* Custom Select styling to replace default dropdown arrow elegantly (browser permitting) */
.custom-select-wrapper {
    position: relative;
}

select {
    appearance: none;
    -webkit-appearance: none;
    cursor: pointer;
}

.select-icon {
    position: absolute;
    right: 16px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    pointer-events: none;
}

/* Color indicating placeholder vs selected in options */
select:invalid {
    color: var(--text-muted);
}

/* --- Checkbox Styling (Insumos) --- */
.insumos-selector {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 24px;
}

.category-group {
    background: rgba(15, 23, 42, 0.4);
    border-radius: var(--radius-md);
    padding: 16px;
    border: 1px solid var(--border);
}

.category-title {
    font-weight: 600;
    margin-bottom: 16px;
    font-size: 14px;
    color: #cbd5e1;
    display: flex;
    align-items: center;
    gap: 8px;
}

.checkbox-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.checkbox-item {
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    font-size: 14px;
    color: var(--text-muted);
    transition: var(--transition);
}

.checkbox-item:hover {
    color: var(--text-main);
}

.checkbox-item input[type="checkbox"] {
    appearance: none;
    -webkit-appearance: none;
    width: 20px;
    height: 20px;
    border: 2px solid var(--border-light);
    border-radius: 4px;
    background-color: transparent;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
    position: relative;
}

.checkbox-item input[type="checkbox"]:checked {
    background-color: var(--primary);
    border-color: var(--primary);
}

.checkbox-item input[type="checkbox"]:checked::after {
    content: '\2714';
    /* Checkmark Unicode */
    color: white;
    font-size: 14px;
    position: absolute;
}

/* --- Buttons & Utils --- */
.mt-16 {
    margin-top: 16px;
}

.mt-24 {
    margin-top: 24px;
}

.w-full {
    width: 100%;
}

.form-actions {
    display: flex;
    justify-content: flex-end;
    gap: 16px;
    margin-top: 32px;
    padding-top: 24px;
    border-top: 1px solid var(--border);
}

.btn {
    padding: 12px 24px;
    border-radius: var(--radius-md);
    font-family: var(--font-family);
    font-weight: 500;
    font-size: 15px;
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    align-items: center;
    gap: 8px;
    border: none;
}

.btn-primary {
    background-color: var(--primary);
    color: white;
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.3);
}

.btn-primary:hover {
    background-color: var(--primary-hover);
    transform: translateY(-1px);
    box-shadow: 0 6px 16px rgba(59, 130, 246, 0.4);
}

.btn-secondary {
    background-color: transparent;
    color: var(--text-muted);
    border: 1px solid var(--border-light);
}

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

/* --- Google Calendar Style Grid --- */
.gc-calendar-container {
    display: flex;
    flex-direction: column;
    height: calc(100vh - 180px);
    /* Fill the remaining screen height */
    background: var(--bg-surface);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border);
    overflow: hidden;
    box-shadow: var(--shadow-sm);
}

.gc-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 24px;
    border-bottom: 1px solid var(--border-light);
    background: var(--bg-surface-elevated);
}

.gc-header-left {
    display: flex;
    align-items: center;
    gap: 16px;
}

.gc-btn-today {
    padding: 8px 16px;
    font-size: 14px;
    border-radius: var(--radius-sm);
}

.gc-nav-arrows {
    display: flex;
    gap: 4px;
}

.gc-nav-arrows .btn-icon {
    width: 32px;
    height: 32px;
}

.gc-month-title {
    font-size: 22px;
    font-weight: 400;
    color: var(--text-main);
    margin: 0;
    margin-left: 8px;
}

.gc-grid-container {
    display: flex;
    flex-direction: column;
    flex: 1;
    overflow: hidden;
}

.gc-days-header {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    border-bottom: 1px solid var(--border);
    background: var(--bg-main);
}

.gc-days-header div {
    padding: 12px 8px;
    text-align: center;
    font-size: 11px;
    font-weight: 600;
    color: var(--text-muted);
    border-right: 1px solid var(--border-light);
}

.gc-days-header div:last-child {
    border-right: none;
}

.gc-days-grid {
    flex: 1;
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    grid-auto-rows: minmax(100px, 1fr);
    /* Each row distributes height equally */
    overflow-y: auto;
    background: var(--bg-main);
}

.gc-days-grid::-webkit-scrollbar {
    width: 6px;
}

.gc-days-grid::-webkit-scrollbar-track {
    background: transparent;
}

.gc-days-grid::-webkit-scrollbar-thumb {
    background-color: var(--border);
    border-radius: 10px;
}

.gc-day-cell {
    border-right: 1px solid var(--border-light);
    border-bottom: 1px solid var(--border-light);
    padding: 8px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    transition: background 0.2s ease;
}

.gc-day-cell:nth-child(7n) {
    border-right: none;
}

.gc-day-cell:hover {
    background: var(--bg-surface-elevated);
}

.gc-day-cell.other-month {
    background: var(--bg-surface);
}

.gc-day-cell.other-month .gc-day-number {
    color: var(--text-muted);
    opacity: 0.5;
}

.gc-day-number {
    font-size: 13px;
    font-weight: 500;
    color: var(--text-main);
    text-align: center;
    width: 26px;
    height: 26px;
    line-height: 26px;
    border-radius: 50%;
    margin: 0 auto 4px auto;
}

.gc-day-cell.today .gc-day-number {
    background-color: var(--primary);
    color: white;
}

/* Event Chips */
.gc-event-chip {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 500;
    color: #fff;
    cursor: pointer;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
    transition: opacity 0.2s ease, transform 0.1s ease;
}

.gc-event-chip:hover {
    opacity: 0.9;
    transform: scale(1.02);
}

.gc-event-chip.age {
    background-color: rgba(239, 68, 68, 0.85);
    /* Red for AGE */
}

.gc-event-chip.ago {
    background-color: rgba(34, 197, 94, 0.85);
    /* Green for AGO */
}

.gc-event-time {
    font-weight: 600;
    opacity: 0.9;
}

.gc-event-title {
    overflow: hidden;
    text-overflow: ellipsis;
}

.btn-delete {
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 8px;
    border-radius: var(--radius-md);
    transition: var(--transition);
}

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

.empty-state {
    grid-column: 1 / -1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 64px 24px;
    text-align: center;
    color: var(--text-muted);
    background: rgba(30, 41, 59, 0.3);
    border-radius: var(--radius-lg);
    border: 1px dashed var(--border-light);
}

.empty-state i {
    font-size: 48px;
    margin-bottom: 16px;
    opacity: 0.5;
}

/* --- Catálogo View --- */
.catalogo-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 24px;
}

.catalogo-card {
    background: var(--bg-surface);
    border-radius: var(--radius-lg);
    padding: 24px;
    border: 1px solid var(--border);
}

.catalogo-icon-wrapper {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    background: var(--primary-light);
    color: var(--primary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    margin-bottom: 20px;
}

.catalogo-card h3 {
    font-size: 18px;
    font-weight: 500;
    margin-bottom: 16px;
    color: var(--text-main);
}

.catalogo-items-list {
    list-style: none;
    margin: 0;
    padding: 0;
}

.catalogo-items-list li {
    padding: 12px 0;
    border-bottom: 1px solid var(--border);
    font-size: 14px;
    color: var(--text-muted);
}

.catalogo-item-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
}

.catalogo-item-row span {
    display: flex;
    align-items: center;
    gap: 12px;
}

.catalogo-item-row span::before {
    content: '';
    display: block;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--primary);
}

/* --- Configuracoes --- */
.settings-card {
    transition: all 0.3s ease;
}

.settings-card:hover {
    box-shadow: var(--shadow-md);
    border-color: rgba(59, 130, 246, 0.3);
}

.settings-card input[type="password"] {
    font-family: monospace;
    letter-spacing: 2px;
}

/* --- Gestão de Assembleia (Modal Lg) --- */
.modal-lg {
    max-width: 900px !important;
    width: 95%;
}

.gestao-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 32px;
}

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

.gestao-section {
    background: var(--bg-main);
    padding: 24px;
    border-radius: var(--radius-md);
    border: 1px solid var(--border);
}

.section-title {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 18px;
    font-weight: 500;
    margin-bottom: 8px;
    color: var(--text-main);
}

.section-title i {
    color: var(--primary);
    font-size: 24px;
}

/* Tracking Insumos */
.insumos-track-list {
    display: flex;
    flex-direction: column;
    gap: 16px;
    max-height: 500px;
    overflow-y: auto;
    padding-right: 8px;
}

/* Custom Scrollbar */
.insumos-track-list::-webkit-scrollbar {
    width: 6px;
}

.insumos-track-list::-webkit-scrollbar-track {
    background: var(--bg-surface);
}

.insumos-track-list::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 4px;
}

.insumos-track-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px;
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
}

.insumo-info {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.insumo-nome {
    font-weight: 500;
    font-size: 14px;
}

.insumo-cat {
    font-size: 12px;
    color: var(--text-muted);
}

.status-select {
    padding: 6px 12px;
    border-radius: var(--radius-sm);
    background: var(--bg-main);
    border: 1px solid var(--border);
    color: var(--text-main);
    font-size: 13px;
    font-family: inherit;
    cursor: pointer;
    outline: none;
    transition: all 0.2s;
}

.status-select:focus {
    border-color: var(--primary);
}

/* Ata e Tags */
.tags-container {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    min-height: 24px;
}

.ata-tag {
    background: rgba(59, 130, 246, 0.15);
    color: var(--primary-light);
    border: 1px solid rgba(59, 130, 246, 0.3);
    padding: 4px 10px;
    border-radius: 16px;
    font-size: 12px;
    display: flex;
    align-items: center;
    gap: 6px;
    animation: fadeIn 0.3s ease;
}

.ata-tag button {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2px;
    border-radius: 50%;
    transition: all 0.2s;
}

.ata-tag button:hover {
    color: var(--danger);
    background: rgba(239, 68, 68, 0.1);
}

/* Dashboard de Despacho */
.dashboard-despacho {
    margin-top: 32px;
    padding: 20px;
    background: rgba(16, 185, 129, 0.05);
    /* Greenish tint for dashboard */
    border: 1px dashed rgba(16, 185, 129, 0.3);
    border-radius: var(--radius-md);
    text-align: center;
    transition: all 0.3s ease;
}

.dashboard-despacho.despachada {
    background: rgba(16, 185, 129, 0.15);
    border: 1px solid var(--success);
}

.despacho-header {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    font-weight: 600;
    color: var(--success);
    font-size: 16px;
    margin-bottom: 12px;
}

.catalogo-item-row button {
    opacity: 0;
    visibility: hidden;
}

.catalogo-items-list li:hover .catalogo-item-row button {
    opacity: 1;
    visibility: visible;
}

/* --- Usuarios List & Table --- */
.usuarios-table-container {
    background: var(--bg-surface);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border);
    overflow: hidden;
    box-shadow: var(--shadow-md);
}

.usuarios-table {
    width: 100%;
    border-collapse: collapse;
    text-align: left;
}

.usuarios-table th {
    padding: 16px 24px;
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
    font-weight: 600;
    border-bottom: 1px solid var(--border);
    background: rgba(15, 23, 42, 0.4);
}

.usuarios-table td {
    padding: 16px 24px;
    border-bottom: 1px solid var(--border-light);
    color: var(--text-main);
    font-size: 14px;
}

.usuarios-table tr:hover td {
    background-color: rgba(255, 255, 255, 0.02);
}

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

.user-badge {
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
    display: inline-block;
}

.badge-superadmin {
    background: rgba(139, 92, 246, 0.15);
    color: #c4b5fd;
}

.badge-admin {
    background: rgba(59, 130, 246, 0.15);
    color: #93c5fd;
}

.badge-gerente {
    background: rgba(16, 185, 129, 0.15);
    color: #6ee7b7;
}

.badge-default {
    background: rgba(148, 163, 184, 0.15);
    color: #cbd5e1;
}

.action-btns {
    display: flex;
    gap: 8px;
}

.btn-icon {
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    border-radius: var(--radius-sm);
    padding: 6px;
    transition: var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
}

.btn-icon:hover {
    background: var(--bg-surface-elevated);
    color: var(--text-main);
}

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

/* --- Modals --- */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100vw;
    height: 100vh;
    background-color: rgba(15, 23, 42, 0.7);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    align-items: flex-start;
    justify-content: center;
    padding: 40px 16px;
    overflow-y: auto;
    animation: fadeIn 0.2s ease-out;
}

.modal.active {
    display: flex;
}

.modal-content {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    margin: 0 auto;
    width: 100%;
    max-width: 500px;
    position: relative;
    border-radius: var(--radius-lg);
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
    transform: translateY(20px);
    animation: slideUp 0.3s ease-out forwards;
}

@keyframes slideUp {
    to {
        transform: translateY(0);
    }
}

.modal-content h3 {
    font-size: 20px;
    margin-bottom: 24px;
    color: var(--text-main);
}

.close-modal {
    position: absolute;
    right: 24px;
    top: 24px;
    color: var(--text-muted);
    font-size: 24px;
    font-weight: bold;
    cursor: pointer;
    transition: var(--transition);
    line-height: 1;
}

.close-modal:hover {
    color: var(--text-main);
}

/* --- Toast --- */
.toast {
    position: fixed;
    bottom: 32px;
    right: 32px;
    background: var(--success);
    color: white;
    padding: 16px 24px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    gap: 12px;
    box-shadow: 0 10px 25px rgba(16, 185, 129, 0.3);
    transform: translateY(100px);
    opacity: 0;
    transition: var(--transition);
    z-index: 1000;
}

.toast.show {
    transform: translateY(0);
    opacity: 1;
}

.toast-icon {
    font-size: 24px;
}

/* Responsive */
@media (max-width: 768px) {
    .app-container {
        flex-direction: column;
    }

    .sidebar {
        width: 100%;
        height: auto;
        padding: 16px;
        flex-direction: row;
        align-items: center;
        justify-content: space-between;
        border-right: none;
        border-bottom: 1px solid var(--border);
    }

    .brand {
        margin-bottom: 0;
    }

    .nav-menu {
        flex-direction: row;
        flex: 0;
    }

    .nav-btn {
        padding: 8px;
    }

    .nav-btn span {
        display: none;
        /* Hide text, just icons */
    }

    .user-profile {
        display: none;
    }

    .view-section {
        padding: 24px 16px;
    }

    .form-grid {
        grid-template-columns: 1fr;
    }
}