/* css/style.css */
:root {
    --header-height: 60px;
    /* Increased for project controls */
    --footer-height: 40px;
    --left-toolbar-width: 70px;
    /* Increased slightly for better button sizing */
    --border-color: #ccc;
    --table-border-color: #999;
    --highlight-color: #a8d8ff;
    --table-header-bg: #e9e9e9;
    --cell-padding: 3px 5px;
    --row-height: 22px;
    --font-size-main: 13px;
    --font-size-small: 11px;
    --project-green: #2e7d32;
    --project-blue: #1976d2;
}

* {
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    font-size: var(--font-size-main);
    line-height: 1.4;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    height: 100vh;
    overflow: hidden;
    background-color: #f4f4f4;
}

.app-container {
    display: flex;
    flex-direction: column;
    width: 100%;
    height: 100%;
}

.app-header {
    padding: 8px 10px;
    background-color: #e9e9e9;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    gap: 10px;
    height: var(--header-height);
    flex-shrink: 0;
    flex-wrap: wrap;
}

/* Project Management Controls */
.project-controls {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 4px 8px;
    border: 1px solid var(--project-blue);
    border-radius: 4px;
    background-color: #f8f9ff;
}

.project-controls button {
    padding: 4px 8px;
    font-size: 11px;
    border-radius: 3px;
    border: 1px solid var(--project-blue);
    background-color: white;
    color: var(--project-blue);
    cursor: pointer;
    transition: all 0.2s ease;
}

.project-controls button:hover {
    background-color: var(--project-blue);
    color: white;
}

.project-controls button:active {
    transform: translateY(1px);
}

#projectStatus {
    font-size: 11px;
    font-weight: 500;
    margin-left: 8px;
    white-space: nowrap;
    max-width: 200px;
    overflow: hidden;
    text-overflow: ellipsis;
}

.divider {
    width: 1px;
    height: 24px;
    background-color: var(--border-color);
    margin: 0 4px;
}

.app-header label {
    margin-left: 8px;
    margin-right: 3px;
    font-size: var(--font-size-small);
}

.app-header input[type="number"] {
    width: 60px;
    padding: 4px;
    font-size: var(--font-size-small);
}

.app-header button:not(.project-controls button) {
    padding: 5px 10px;
    font-size: var(--font-size-small);
}

.main-content-area {
    display: flex;
    flex-grow: 1;
    overflow: hidden;
}

#left-toolbar {
    width: var(--left-toolbar-width);
    padding: 10px 5px;
    background-color: #f0f0f0;
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    gap: 5px;
    align-items: center;
    overflow-y: auto;
    flex-shrink: 0;
}

#left-toolbar .tool-group-title {
    font-weight: bold;
    margin-bottom: 5px;
    font-size: 0.8em;
    text-align: center;
    width: 100%;
}

#left-toolbar button {
    width: 45px;
    height: 40px;
    padding: 0;
    font-size: 1.2em;
    border-radius: 4px;
    border: 1px solid #ccc;
    background-color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

#left-toolbar button:hover {
    background-color: #e8e8e8;
    border-color: #999;
}

#left-toolbar button.active-tool {
    background-color: #4CAF50;
    color: white;
    border-color: #388E3C;
}

#left-toolbar button.active-tool:hover {
    background-color: #388E3C;
}

/* Special styling for clear drawings button */
#btnClearAllDrawings {
    background-color: #ffebee !important;
    border-color: #f44336 !important;
    color: #d32f2f !important;
}

#btnClearAllDrawings:hover {
    background-color: #f44336 !important;
    color: white !important;
}

#left-toolbar input[type="color"] {
    width: 45px;
    height: 30px;
    padding: 2px;
    border: 1px solid var(--border-color);
    cursor: pointer;
}

#left-toolbar label {
    font-size: 0.75em;
    margin-top: 8px;
    display: block;
    text-align: center;
    width: 100%;
}

#left-toolbar select {
    width: calc(100% - 10px);
    margin: 0 5px;
    padding: 3px;
    font-size: 0.8em;
}

#left-toolbar hr {
    width: 80%;
    margin: 8px auto;
    border: 0;
    border-top: 1px solid #ddd;
}

#xsheet-and-metadata-section {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    padding: 10px;
    overflow: hidden;
}

#metadata-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 5px 10px;
    margin-bottom: 10px;
    font-size: var(--font-size-small);
}

#metadata-grid div {
    border: 1px solid var(--table-border-color);
    padding: 3px 5px;
    background-color: #fff;
    display: flex;
    align-items: center;
}

#metadata-grid span {
    font-weight: bold;
    margin-right: 5px;
    white-space: nowrap;
}

#metadata-grid input {
    border: none;
    width: 100%;
    flex-grow: 1;
    margin-left: 5px;
    background: transparent;
    padding: 2px;
    font-size: var(--font-size-small);
}

#metadata-grid input[type="date"] {
    width: auto;
    flex-grow: 0;
}

#xsheet-container {
    flex-grow: 1;
    overflow: auto;
    position: relative;
    border: 1px solid var(--table-border-color);
    background-color: #fff;
}

#xsheetTable {
    width: 100%;
    border-collapse: collapse;
    table-layout: fixed;
    font-size: var(--font-size-small);
}

#xsheetTable thead {
    position: sticky;
    top: 0;
    z-index: 10;
    background-color: var(--table-header-bg);
}

#xsheetTable th,
#xsheetTable td {
    border: 1px solid var(--table-border-color);
    padding: var(--cell-padding);
    vertical-align: top;
    height: var(--row-height);
    line-height: calc(var(--row-height) - 2 * 3px - 2px);
    box-sizing: border-box;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

#xsheetTable th {
    font-weight: bold;
    text-align: center;
}

/* Column classes (match LOGICAL_COLUMNS in xsheet.js) */
.action-col {
    width: 20%;
}

.frame-col {
    width: 4%;
    text-align: center;
    background-color: #f0f0f0;
}

.waveform-col {
    width: 10%;
    padding: 0 !important;
}

.dialogue-col {
    width: 12%;
    text-align: left;
}

/* UPDATED: Changed to fixed 100px width */
.sound-col {
    width: 100px;
    text-align: left;
}

/* UPDATED: Changed to fixed 100px width */
.technical-col {
    width: 100px;
}

/* NEW: Three new extra columns at 100px each */
.extra1-col,
.extra2-col,
.extra3-col {
    width: 100px;
    text-align: left;
}

.camera-col {
    width: 14%;
}

/* Row styling */
#xsheetTable tr.even-row td:not(.frame-col) {
    background-color: #f9f9f9;
}

#xsheetTable tr.highlighted-frame td {
    background-color: var(--highlight-color) !important;
}

#xsheetTable tr.major-second-tick {
    border-bottom: 2px solid #777;
}

#xsheetTable tr.eighth-frame-tick {
    border-bottom: 1px dashed #bbb;
}

#xsheetTable td.frame-col.major-second-tick,
#xsheetTable tr.bold-frame-row td.frame-col {
    font-weight: bold;
}

#xsheetTable tr:first-child td.frame-col {
    background-color: #c8e6c9;
}

#xsheetTable td[contenteditable="true"] {
    white-space: pre-wrap;
    min-height: var(--row-height);
}

#xsheetTable td[contenteditable="true"]:focus {
    outline: 1px solid blue;
    background-color: #e6f7ff;
}

#xsheetTable td[contenteditable="true"]:empty:before {
    content: attr(data-placeholder);
    color: #aaa;
    font-style: italic;
}

/* NEW: Enhanced column header styling for renameable columns */
#xsheetTable th[data-column-key] {
    position: relative;
    transition: all 0.2s ease;
}

#xsheetTable th[title*="Right-click"] {
    background-color: #f8f9fa !important;
    border-color: #007bff !important;
    position: relative;
}

#xsheetTable th[title*="Right-click"]:hover {
    background-color: #e3f2fd !important;
    border-color: #0056b3 !important;
    box-shadow: 0 1px 3px rgba(0, 123, 255, 0.2);
}

/* Context menu styling */
#column-context-menu {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif !important;
    user-select: none;
}

/* Overlays */
#verticalWaveformCanvas {
    position: absolute;
    pointer-events: auto;
    z-index: 5;
}

#drawingCanvasOverlay {
    position: absolute;
    pointer-events: none;
    z-index: 20;
}

/* Special cursor for eraser tool */
#drawingCanvasOverlay[data-tool="eraser"] {
    cursor: url('data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMjQiIGhlaWdodD0iMjQiIHZpZXdCb3g9IjAgMCAyNCAyNCIgZmlsbD0ibm9uZSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj4KPGF0aCBkPSJNMTIgMkwxMCA0TDIwIDE0TDEyIDIyTDEwIDIwTDIgMTJMMTAgNEwxMiAyWiIgZmlsbD0iI2ZmZiIgc3Ryb2tlPSIjMDAwIiBzdHJva2Utd2lkdGg9IjIiLz4KPC9zdmc+Cg==') 12 12, crosshair;
}

.app-footer {
    padding: 5px 10px;
    background-color: #e0e0e0;
    border-top: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    gap: 10px;
    height: var(--footer-height);
    flex-shrink: 0;
    font-size: var(--font-size-small);
}

#audio-playback-controls {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-grow: 1;
}

#audioInfo {
    margin: 0 10px;
    white-space: nowrap;
}

#audioScrubSlider {
    flex-grow: 1;
    min-width: 100px;
    max-width: 300px;
    margin: 0 5px;
}

#statusBar {
    text-align: right;
    min-width: 150px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Export container styles - for the clean export page */
#export-container {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background-color: #ffffff;
    color: #000000;
}

#export-container table {
    border-collapse: collapse;
    width: 100%;
}

#export-container th,
#export-container td {
    border: 1px solid #999;
    padding: 3px 5px;
    font-size: 11px;
    height: 22px;
    vertical-align: top;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

#export-container th {
    background-color: #e9e9e9;
    font-weight: bold;
    text-align: center;
}

#export-container .frame-col {
    background-color: #f0f0f0;
    text-align: center;
}

#export-container tr:first-child .frame-col {
    background-color: #c8e6c9;
}

#export-container tr:nth-child(even) td:not(.frame-col) {
    background-color: #f9f9f9;
}

/* Responsive adjustments for project controls */
@media (max-width: 1200px) {
    .app-header {
        flex-wrap: wrap;
        height: auto;
        min-height: var(--header-height);
        padding: 8px 5px;
        gap: 6px;
    }

    .project-controls {
        order: -1;
        width: 100%;
        justify-content: flex-start;
        margin-bottom: 4px;
    }

    #projectStatus {
        max-width: 150px;
    }
}

@media (max-width: 800px) {
    .project-controls button {
        padding: 3px 6px;
        font-size: 10px;
    }

    #projectStatus {
        font-size: 10px;
        max-width: 120px;
    }

    .app-header button:not(.project-controls button) {
        padding: 4px 8px;
        font-size: 11px;
    }

    .app-header input[type="number"] {
        width: 50px;
    }

    #left-toolbar {
        width: 60px;
    }

    #left-toolbar button {
        width: 40px;
        height: 35px;
        font-size: 1em;
    }

    #left-toolbar input[type="color"] {
        width: 40px;
        height: 25px;
    }
}

/* Enhanced print styles for the new export approach */
@media print {
    body * {
        visibility: hidden;
    }

    #export-container,
    #export-container * {
        visibility: visible;
    }

    #export-container {
        position: absolute !important;
        left: 0 !important;
        top: 0 !important;
        width: 100% !important;
        height: auto !important;
        padding: 0.2in !important;
        background: white !important;
        font-size: 10pt !important;
    }

    #export-container table {
        page-break-inside: auto;
        border-collapse: collapse !important;
        width: 100% !important;
    }

    #export-container thead {
        display: table-header-group !important;
    }

    #export-container tbody {
        display: table-row-group !important;
    }

    #export-container tr {
        page-break-inside: avoid;
        display: table-row !important;
    }

    #export-container th,
    #export-container td {
        display: table-cell !important;
        page-break-inside: avoid;
        border: 1px solid #999 !important;
        font-size: 8pt !important;
    }

    #export-container canvas {
        display: block !important;
        position: absolute !important;
        image-rendering: crisp-edges !important;
    }

    @page {
        size: letter portrait;
        margin: 0.4in;
    }

    #export-container .frame-col {
        background-color: #f5f5f5 !important;
    }

    #export-container tr:first-child .frame-col {
        background-color: #e0e0e0 !important;
    }

    #export-container tr:nth-child(even) td:not(.frame-col) {
        background-color: #f9f9f9 !important;
    }
}