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

:root {
    /* --- PALETA TOYOTA & STATUS --- */
    --toyota-red: #EB0A1E;
    --toyota-black: #000000;
    
    --planned-dark: #5f6368;
    --planned-light: #f1f3f4;
    --success-dark: #0f9d58;
    --success-light: #e6f4ea;
    --warning-dark: #f57f17;
    --warning-light: #fef7e0;
    --danger-dark: #d93025;
    --danger-light: #fce8e6;

    /* Dimensões */
    --col-index-width: 44px;
    --col-actions-width: 56px;
    --col-name-width: 180px;
    --col-owner-width: 120px;
    --col-date-width: 60px;
    --col-pct-width: 40px;
    
    --header-height: 60px;
    --row-height: 44px;
    --border-color: #dadce0;
}

* {
    box-sizing: border-box;
}

body {
    font-family: 'Roboto', sans-serif;
    background-color: #f4f4f4;
    color: #333;
    margin: 0;
    padding: 0;
}

/* 1. BARRA TOYOTA */
.toyota-bar {
    background-color: #fff;
    height: 80px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 30px;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
    border-bottom: 3px solid var(--toyota-red);
    position: sticky;
    top: 0;
    z-index: 1000;
}

.brand-area {
    display: flex;
    align-items: center;
    gap: 20px;
}

.brand-logo {
    height: 60px;
    width: auto;
}

.brand-title {
    font-size: 24px;
    font-weight: 300;
    color: #333;
    border-left: 1px solid #ccc;
    padding-left: 20px;
}

/* FILTROS NA BARRA SUPERIOR */
.top-filters {
    display: flex;
    gap: 15px;
    align-items: center;
}

.filter-group {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
}

.filter-group label {
    font-size: 10px;
    text-transform: uppercase;
    color: #666;
    font-weight: bold;

    margin-bottom: 2px;
}

.toyota-select {
    padding: 6px 10px;
    border: 1px solid #ccc;
    border-radius: 4px;
    background-color: #f9f9f9;
    color: #333;
    font-size: 13px;
    min-width: 200px;
    outline: none;
    cursor: pointer;
}

/* 2. LAYOUT */
.main-wrapper {
    padding: 20px 30px;
    max-width: 100%;
}

.content-box {
    background: #fff;
    border-radius: 8px;
    padding: 20px;
    margin-bottom: 20px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    border: 1px solid var(--border-color);
}

/* Info Projeto */
.project-info-container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
}

.input-group label {
    display: block;
    font-size: 11px;
    color: #666;
    margin-bottom: 4px;
    text-transform: uppercase;
    font-weight: bold;
}

.input-title {
    font-size: 22px;
    font-weight: 700;
    color: #333;
    border: 1px solid transparent;
    border-bottom: 1px solid #ccc;
    padding: 5px;
    width: 400px;
    transition: 0.3s;
}

.input-owner {
    font-size: 16px;
    color: #555;
    border: 1px solid transparent;
    border-bottom: 1px solid #ccc;
    padding: 5px;
    width: 200px;
}

.input-title:hover,
.input-owner:hover,
.toyota-select:hover,
#projFiscalYearInput:hover {
    background-color: #fdfdfd;
    border-color: #bdbdbd;
}

/* Células editáveis */
.editable-cell {
    cursor: pointer;
    transition: background-color 0.2s;
}

.editable-cell:hover {
    background-color: #f0f0f0;
    outline: 1px solid #ddd;
}

.input-title:focus,
.input-owner:focus {
    outline: none;
    border-bottom: 2px solid var(--toyota-red);
    background-color: #fff;
}

/* 3. COMANDOS E BOTÕES */
.controls-container {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.view-controls {
    display: flex;
    align-items: center;
    gap: 8px;
}

.btn-view {
    height: 36px;
    border: 1px solid var(--border-color);
    background: #fff;
    padding: 0 16px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 13px;
    color: #555;
    font-weight: 500;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    transition: 0.2s;
    text-decoration: none;
}

.btn-view:hover {
    background: #ffe2e2;
    border: 1px solid var(--toyota-red);
    color: var(--toyota-red);
}

.btn-view.btn-rc-summary:hover {
    background: #e3f2fd;
    border-color: #90caf9;
    color: #1565c0;
}

.btn-view.active {
    background: var(--toyota-red);
    color: #fff;
    border-color: var(--toyota-red);
    font-weight: bold;
}

.btn-save {
    background-color: #fff;
    color: var(--toyota-red);
    border: 1px solid var(--toyota-red);
}

.btn-save:hover {
    background-color: var(--toyota-red);
    color: #fff;
}

/* Legenda */
.legend {
    display: flex;
    gap: 8px;
}

.legend-item {
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: bold;
    height: 24px;
    display: inline-flex;
    align-items: center;
}

/* 4. GANTT */
#gantt-container {
    background: #fff;
    border: none;
    border-radius: 8px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    margin-bottom: 20px;
    padding: 0;
    overflow: visible;
    max-height: none;
    position: relative;
}

.gantt-table {
    border: 1px solid var(--border-color);
    width: 100%;
    background: #fff;
    overflow: visible;
}

.gantt-header,
.gantt-row {
    display: flex;
    min-width: 100%;
    width: max-content;
    border-bottom: 1px solid var(--border-color);
}

.gantt-header-scroll {
    position: sticky;
    top: 80px;
    z-index: 25;
    background: #f8f9fa;
    overflow-x: auto;
    overflow-y: hidden;
    border: none;
    width: 100%;
}

.gantt-header-scroll::-webkit-scrollbar {
    height: 0;
}

.gantt-header-scroll {
    scrollbar-width: none;
}

.gantt-header {
    position: relative;
    z-index: 20;
    background: #f8f9fa;
    height: var(--header-height);
    font-weight: 600;
    font-size: 13px;
    color: #5f6368;
}

.gantt-row {
    height: var(--row-height);
    background: #fff;
    overflow: visible;
    position: relative;
    z-index: 0;
}

.gantt-row:hover {
    background-color: #fafafa;
}

.col-fixed {
    position: sticky;
    background: #fff;
    display: flex;
    align-items: center;
    padding: 0 8px;
    font-size: 12px;
    border-right: none;
    border-left: 1px solid var(--border-color);
    flex-shrink: 0;
    height: 100%;
    z-index: 5;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.gantt-header .col-fixed {
    z-index: 10;
    background: #f8f9fa;
    justify-content: center;
}

.gantt-row .col-fixed {
    background: #fff !important;
}

.gantt-row:hover .col-fixed {
    background: #fafafa;
}

.c-index {
    left: 0;
    width: var(--col-index-width);
    justify-content: center;
    border-left: none;
    gap: 4px;
}

.c-actions {
    left: var(--col-index-width);
    width: var(--col-actions-width);
    justify-content: center;
    overflow: visible;
    z-index: 40;
}

.subtask-toggle {
    border: none;
    background: transparent;
    cursor: pointer;
    padding: 2px;
    border-radius: 4px;
    color: #666;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.subtask-toggle:hover {
    background: #f1f3f4;
    color: #333;
}

.c-name {
    left: calc(var(--col-index-width) + var(--col-actions-width));
    width: var(--col-name-width);
}

.gantt-row .c-name {
    cursor: pointer;
}

.gantt-row .c-name:hover {
    background-color: #f1f3f4;
    text-decoration: underline;
    text-decoration-style: dotted;
}

.c-owner {
    left: calc(var(--col-index-width) + var(--col-actions-width) + var(--col-name-width));
    width: var(--col-owner-width);
}

.gantt-row .c-owner {
    cursor: pointer;
}

.gantt-row .c-owner:hover {
    background-color: #f1f3f4;
}

.c-start {
    left: calc(var(--col-index-width) + var(--col-actions-width) + var(--col-name-width) + var(--col-owner-width));
    width: var(--col-date-width);
    justify-content: center;
}

.gantt-row .c-start {
    cursor: pointer;
}

.gantt-row .c-start:hover {
    background-color: #f1f3f4;
}

.c-end {
    left: calc(var(--col-index-width) + var(--col-actions-width) + var(--col-name-width) + var(--col-owner-width) + var(--col-date-width));
    width: var(--col-date-width);
    justify-content: center;
}

.gantt-row .c-end {
    cursor: pointer;
}

.gantt-row .c-end:hover {
    background-color: #f1f3f4;
}

.c-pct {
    left: calc(var(--col-index-width) + var(--col-actions-width) + var(--col-name-width) + var(--col-owner-width) + var(--col-date-width) + var(--col-date-width));
    width: var(--col-pct-width);
    justify-content: center;
    font-weight: bold;
}

.gantt-scrolled .c-pct {
    border-right: 1px solid var(--border-color);
}

.actions-dropdown {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.actions-trigger {
    border: 1px solid #ddd;
    background: #fff;
    cursor: pointer;
    padding: 4px;
    border-radius: 6px;
    color: #555;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.actions-trigger:hover {
    background: #f1f3f4;
}

.actions-menu {
    position: fixed;
    transform: translateX(-50%);
    background: #fff;
    color: #333;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.12);
    padding: 6px;
    display: none;
    flex-direction: column;
    gap: 4px;
    min-width: 160px;
    z-index: 9999;
}

.actions-menu.open {
    display: flex;
}

.actions-item {
    border: none;
    background: transparent;
    cursor: pointer;
    padding: 6px 8px;
    border-radius: 6px;
    font-size: 12px;
    color: #333;
    display: flex;
    align-items: center;
    gap: 8px;
    text-align: left;
}

.actions-item:hover {
    background: #f5f5f5;
}

.actions-item.danger {
    color: var(--toyota-red);
}

.gantt-row .c-pct {
    cursor: pointer;
}

.gantt-row .c-pct:hover {
    background-color: #f1f3f4;
}

.btn-action {
    border: none;
    background: transparent;
    cursor: pointer;
    padding: 4px;
    border-radius: 3px;
    color: #555;
    margin: 0 1px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.btn-action:hover {
    background-color: #ddd;
    color: #000;
}

.btn-del:hover {
    background-color: #fce8e6;
    color: var(--toyota-red);
}

.btn-icon {
    border: none;
    background: transparent;
    cursor: pointer;
    padding: 8px;
    border-radius: 8px;
    margin: 0 4px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.btn-icon:hover {
    transform: scale(1.1);
}

.btn-icon:active {
    transform: scale(0.95);
}

/* Botão de adicionar/comentar - azul */
.btn-icon:has([style*="2196F3"]) {
    background: #2196F3;
}

.btn-icon:has([style*="2196F3"]):hover {
    background: #1976D2;
    box-shadow: 0 2px 8px rgba(33, 150, 243, 0.4);
}

.btn-icon:has([style*="2196F3"]) .material-icons-outlined {
    color: white !important;
}

/* Botão de excluir - vermelho */
.btn-icon:has([style*="toyota-red"]) {
    background: var(--toyota-red);
}

.btn-icon:has([style*="toyota-red"]):hover {
    background: #c00000;
    box-shadow: 0 2px 8px rgba(235, 10, 30, 0.4);
}

.btn-icon:has([style*="toyota-red"]) .material-icons-outlined {
    color: white !important;
}

/* Atualizações (RCs) */
.update-item {
    font-size: 11px;
    padding: 6px;
    margin: 3px 0;
    background: #e9ecef;
    border-radius: 4px;
}

.update-date {
    color: #666;
    font-size: 10px;
    margin-bottom: 3px;
}

.update-text {
    color: #333;
    line-height: 1.4;
    word-wrap: break-word;
    overflow-wrap: anywhere;
    word-break: break-word;
    white-space: normal;
}

.btn-text {
    background: none;
    border: none;
    color: #2196F3;
    cursor: pointer;
    font-size: 11px;
    padding: 2px 5px;
    text-decoration: underline;
}

.btn-text:hover {
    color: #1976D2;
}

#purchase-requests-container .rc-optional {
    display: none;
}

#purchase-requests-container.rc-expanded .rc-optional {
    display: table-cell;
}

#purchase-requests-container .rc-table {
    min-width: 100% !important;
}

#purchase-requests-container.rc-expanded .rc-table {
    min-width: 1900px !important;
}

#purchase-requests-container:not(.rc-expanded) .rc-table {
    table-layout: fixed;
    width: 100%;
}

#purchase-requests-container:not(.rc-expanded) {
    overflow-x: hidden;
}

#purchase-requests-container.rc-expanded {
    overflow-x: auto;
}

#purchase-requests-container:not(.rc-expanded) th,
#purchase-requests-container:not(.rc-expanded) td {
    min-width: 0 !important;
    max-width: none;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.modal-updates-container {
    max-height: 180px;
    overflow-y: auto;
    margin-bottom: 15px;
}

.modal-update-item {
    padding: 12px;
    margin: 8px 0;
    background: #e9ecef;
    border-radius: 6px;
}

.modal-update-date {
    font-size: 11px;
    color: #666;
    margin-bottom: 5px;
    font-weight: 600;
}

.modal-update-text {
    font-size: 13px;
    color: #333;
    line-height: 1.5;
}

.rc-updates-modal {
    position: relative;
}

.rc-updates-close {
    position: absolute;
    top: 10px;
    right: 10px;
    border: none;
    background: none;
    color: #666;
    font-size: 36px;
    cursor: pointer;
    line-height: 1;
    padding: 2px 10px;
}

.rc-updates-close:hover {
    color: var(--toyota-red);
}

.new-update-section textarea {
    width: 100%;
    min-height: 80px;
    padding: 10px;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-size: 14px;
    font-family: inherit;
    resize: vertical;
    box-sizing: border-box;
}

.new-update-section textarea:focus {
    outline: none;
    border-color: #555;
}

/* Modal de Atualização Rápida (RC) */
.quick-update-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1001;
    animation: fadeIn 0.2s;
}

.quick-update-modal.active {
    display: flex;
    align-items: center;
    justify-content: center;
}

.quick-update-content {
    background: white;
    border-radius: 8px;
    width: 90%;
    max-width: 600px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.2);
    animation: slideUp 0.3s;
}

.modal-header {
    padding: 20px;
    border-bottom: 1px solid #e0e0e0;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h2 {
    margin: 0;
    font-size: 20px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.modal-close {
    background: none;
    border: none;
    cursor: pointer;
    padding: 5px;
    color: #666;
    transition: all 0.2s;
}

.modal-close:hover {
    color: var(--toyota-red);
}

.modal-body {
    padding: 20px;
}

.modal-form-group {
    margin-bottom: 15px;
}

.modal-form-group label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: #666;
    margin-bottom: 5px;
}

.modal-form-group textarea {
    width: 100%;
    padding: 10px;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-size: 14px;
    box-sizing: border-box;
    font-family: inherit;
    resize: vertical;
}

.modal-form-group textarea:focus {
    outline: none;
    border-color: #555;
}

.modal-footer {
    padding: 20px;
    border-top: 1px solid #e0e0e0;
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}

.btn {
    padding: 10px 20px;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.btn-primary {
    background: var(--toyota-red);
    color: white;
}

.btn-primary:hover {
    background: #c71e1d;
}

.btn-secondary {
    background: white;
    color: #666;
    border: 1px solid #ddd;
}

.btn-secondary:hover {
    background: #f5f5f5;
}

.char-counter {
    text-align: right;
    margin-top: 5px;
    font-size: 11px;
    color: #666;
}

.timeline-wrapper {
    flex-grow: 1;
    position: relative;
    z-index: 0;
    border-right: none;
    overflow: hidden;
}

.timeline-area {
    position: relative;
    height: 100%;
    z-index: 0;
}

.gantt-scroll-area {
    width: 100%;
    overflow-y: auto;
    position: relative;
    z-index: 1;
    max-height: 70vh;
}

.header-cell {
    position: absolute;
    height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    background: #f8f9fa;
    border-left: 1px solid var(--border-color);
}

.header-top {
    font-size: 10px;
    text-transform: uppercase;
    color: #666;
    font-weight: 600;
    margin-bottom: 2px;
    width: 100%;
    text-align: center;
}

.header-bottom {
    font-size: 14px;
    font-weight: bold;
    color: #333;
    width: 100%;
    text-align: center;
}

.task-bar {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    height: 24px;
    border-radius: 4px;
    cursor: pointer;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.15);
    border: 1px solid;
    background: transparent;
    overflow: hidden;
    z-index: 1;
}

.task-bar:hover {
    filter: brightness(0.95);
    z-index: 5;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.tb-base {
    position: absolute;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    font-weight: 600;
}

.tb-clip {
    position: absolute;
    top: 0;
    left: 0;
    bottom: 0;
    overflow: hidden;
    z-index: 1;
}

.tb-overlay {
    position: absolute;
    top: 0;
    left: 0;
    bottom: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-size: 11px;
    font-weight: 600;
    white-space: nowrap;
}

.theme-planned {
    border-color: var(--planned-dark);
}

.theme-success {
    border-color: var(--success-dark);
}

.theme-warning {
    border-color: var(--warning-dark);
}

.theme-danger {
    border-color: var(--danger-dark);
}

#today-line {
    position: absolute;
    top: -51px;
    bottom: 0;
    width: 2px;
    background: var(--toyota-red);
    z-index: 2;
    pointer-events: none;
}

.owner-avatar {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: #eee;
    color: #555;
    font-size: 9px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-right: 6px;
    font-weight: bold;
}

.material-icons-outlined {
    font-size: 18px;
    vertical-align: middle;
}

.btn-action .material-icons-outlined {
    font-size: 16px;
}


/* Language selector (global) */
.lang-selector { position: relative; }
.lang-btn {
    padding: 8px; background: #f5f5f5; border: 1px solid #ccc; border-radius: 4px;
    cursor: pointer; display: flex; align-items: center; gap: 6px;
}
.lang-menu {
    position: absolute; right: 0; top: 110%; background: #fff; border: 1px solid #ddd; border-radius: 6px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.12); min-width: 180px; display: none; z-index: 50;
}
.lang-menu.active { display: block; }
.lang-item { padding: 10px 12px; display: flex; align-items: center; gap: 8px; cursor: pointer; }
.lang-item:hover { background: #f7f7f7; }
.lang-item .material-icons-outlined { font-size: 18px; color: #666; }
