/* Editor Header */
.editor-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 20px;
    background-color: var(--bg-secondary);
    border-bottom: 1px solid var(--border-color);
    gap: 12px;
    flex-wrap: wrap;
}

.header-left,
.header-center,
.header-right {
    display: flex;
    align-items: center;
    gap: 8px;
}

.header-left {
    flex: 1;
    min-width: 200px;
}

.header-center {
    flex: 0 0 auto;
}

.header-right {
    flex: 1;
    min-width: 200px;
    justify-content: flex-end;
    flex-wrap: wrap;
}

.script-title-input {
    background: transparent;
    border: none;
    font-size: 1.1rem;
    font-weight: 500;
    color: var(--text-primary);
    padding: 4px 8px;
    border-radius: 4px;
    min-width: 200px;
}

.script-title-input:hover,
.script-title-input:focus {
    background-color: var(--bg-hover);
    outline: none;
}

.element-selector select {
    padding: 8px 12px;
    font-size: 0.875rem;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    background-color: var(--bg-primary);
    color: var(--text-primary);
    cursor: pointer;
}

.page-count {
    font-size: 0.875rem;
    color: var(--text-secondary);
    white-space: nowrap;
}

.autosave-indicator {
    font-size: 0.75rem;
    color: var(--text-muted);
    padding: 4px 8px;
    background-color: var(--bg-tertiary);
    border-radius: 4px;
}

.autosave-indicator.saving {
    color: var(--warning);
}

.autosave-indicator.saved {
    color: var(--success);
}

/* Editor Container */
.editor-container {
    flex: 1;
    display: flex;
    overflow: hidden;
    background-color: var(--bg-tertiary);
}

/* Scene Navigator */
.scene-navigator {
    width: 280px;
    background-color: var(--bg-secondary);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    transition: width 0.25s ease;
}

.scene-navigator.hidden {
    width: 0;
    overflow: hidden;
}

.navigator-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px;
    border-bottom: 1px solid var(--border-color);
}

.navigator-header h3 {
    font-size: 0.875rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
}

.scene-list {
    flex: 1;
    overflow-y: auto;
    padding: 8px;
}

.scene-item {
    padding: 12px;
    border-radius: 6px;
    cursor: pointer;
    margin-bottom: 4px;
}

.scene-item:hover {
    background-color: var(--bg-hover);
}

.scene-item .scene-number {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--accent-primary);
    margin-bottom: 4px;
}

.scene-item .scene-heading {
    font-size: 0.875rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Main Editor Area */
.editor-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* Ruler */
.editor-ruler {
    height: 25px;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: center;
    flex-shrink: 0;
}

.editor-ruler.hidden {
    display: none;
}

.ruler-inner {
    width: 8.5in;
    height: 100%;
    position: relative;
    background: linear-gradient(90deg,
        var(--bg-tertiary) 0%, var(--bg-tertiary) 1in,
        var(--bg-page) 1in, var(--bg-page) 7.5in,
        var(--bg-tertiary) 7.5in, var(--bg-tertiary) 100%
    );
}

.ruler-marks {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 100%;
    display: flex;
}

.ruler-inch {
    flex: 0 0 1in;
    height: 100%;
    border-right: 1px solid var(--border-color);
    position: relative;
    font-size: 9px;
    color: var(--text-muted);
}

.ruler-inch::after {
    content: attr(data-inch);
    position: absolute;
    bottom: 2px;
    right: 4px;
}

.ruler-inch .half-mark {
    position: absolute;
    left: 50%;
    top: 50%;
    width: 1px;
    height: 8px;
    background: var(--border-color);
}

/* Margin indicators on ruler */
.ruler-margin-left,
.ruler-margin-right {
    position: absolute;
    top: 0;
    bottom: 0;
    width: 4px;
    background: var(--accent-primary);
    opacity: 0.5;
    cursor: ew-resize;
}

.ruler-margin-left {
    left: 1in;
}

.ruler-margin-right {
    right: 1in;
}

/* Editor scroll area */
.editor-scroll {
    flex: 1;
    overflow-y: auto;
    overflow-x: auto;
    display: flex;
    justify-content: center;
    padding: 40px 20px;
    background-color: var(--bg-tertiary);
}

/* Pages container */
.editor-pages {
    display: flex;
    flex-direction: column;
    gap: 40px;
}

/* Individual page - proper paper size */
.screenplay-page {
    width: 8.5in;
    min-height: 11in;
    background-color: var(--bg-page);
    box-shadow: var(--page-shadow);
    position: relative;
    flex-shrink: 0;
    box-sizing: border-box;
}

/* Screenplay Editor - proper 1 inch margins all around */
.screenplay-editor {
    font-family: 'Courier Prime', 'Courier New', monospace;
    font-size: 12pt;
    line-height: 1;
    padding: 1in;
    min-height: calc(11in - 2in);
    outline: none;
    white-space: pre-wrap;
    word-wrap: break-word;
    box-sizing: border-box;
}

.screenplay-editor:empty::before {
    content: 'Start writing your screenplay...';
    color: var(--text-muted);
    font-style: italic;
}

/* Screenplay Elements */
.screenplay-editor .element {
    margin-bottom: 1em;
    min-height: 1em;
    line-height: 1;
}

.screenplay-editor .element:focus {
    outline: none;
}

.screenplay-editor [data-type="scene-heading"] {
    text-transform: uppercase;
    font-weight: bold;
    margin-top: 1em;
}

.screenplay-editor [data-type="scene-heading"]:first-child {
    margin-top: 0;
}

.screenplay-editor [data-type="action"] {
    /* Full width */
}

.screenplay-editor [data-type="character"] {
    text-transform: uppercase;
    margin-left: 2in;
    margin-bottom: 0;
}

.screenplay-editor [data-type="dialogue"] {
    margin-left: 1in;
    margin-right: 1.5in;
    margin-top: 0;
}

.screenplay-editor [data-type="parenthetical"] {
    margin-left: 1.5in;
    margin-right: 1.9in;
    margin-top: 0;
    margin-bottom: 0;
}

.screenplay-editor [data-type="parenthetical"]::before {
    content: '(';
}

.screenplay-editor [data-type="parenthetical"]::after {
    content: ')';
}

.screenplay-editor [data-type="transition"] {
    text-transform: uppercase;
    text-align: right;
    margin-top: 1em;
}

/* Hide page gaps when setting is off */
body.hide-page-breaks .editor-pages {
    gap: 0;
}

body.hide-page-breaks .screenplay-page {
    box-shadow: none;
    border-bottom: 1px dashed var(--border-color);
}

/* Distraction Free Mode */
body.distraction-free .editor-header {
    opacity: 0;
    transition: opacity 0.25s ease;
}

body.distraction-free .editor-header:hover {
    opacity: 1;
}

body.distraction-free .scene-navigator {
    width: 0;
    overflow: hidden;
}

body.distraction-free .editor-ruler {
    display: none;
}

body.distraction-free .editor-scroll {
    padding: 60px 20px;
}

/* Print styles */
@media print {
    .editor-header,
    .scene-navigator,
    .editor-ruler,
    .page-break-indicator {
        display: none !important;
    }

    .editor-scroll {
        padding: 0;
        overflow: visible;
    }

    .screenplay-page {
        box-shadow: none;
        page-break-after: always;
    }
}

/* Responsive */
@media (max-width: 1024px) {
    .scene-navigator {
        position: absolute;
        left: 0;
        top: 0;
        height: 100%;
        z-index: 50;
        background: var(--bg-secondary);
    }
}

@media (max-width: 768px) {
    .editor-header {
        padding: 8px 12px;
    }

    .header-center {
        order: 3;
        width: 100%;
        justify-content: center;
    }

    .screenplay-page {
        width: 100%;
        min-width: 0;
    }

    .screenplay-editor {
        padding: 0.5in;
        font-size: 11pt;
    }

    .screenplay-editor [data-type="character"] {
        margin-left: 1.2in;
    }

    .screenplay-editor [data-type="dialogue"] {
        margin-left: 0.4in;
        margin-right: 0.4in;
    }

    .screenplay-editor [data-type="parenthetical"] {
        margin-left: 0.6in;
        margin-right: 0.6in;
    }

    .editor-ruler {
        display: none;
    }
}

/* File drop zone */
.drop-zone {
    border: 3px dashed var(--border-color);
    border-radius: 12px;
    padding: 40px;
    text-align: center;
    margin: 20px 0;
    transition: all 0.2s ease;
    cursor: pointer;
}

.drop-zone:hover,
.drop-zone.drag-over {
    border-color: var(--accent-primary);
    background-color: var(--accent-light);
}

.drop-zone-text {
    color: var(--text-secondary);
    font-size: 1rem;
}

.drop-zone-text strong {
    color: var(--accent-primary);
}

/* Preview Modal */
.modal-fullscreen {
    padding: 0;
}

.modal-fullscreen .modal-content {
    max-width: 100%;
    max-height: 100%;
    width: 100%;
    height: 100%;
    border-radius: 0;
    display: flex;
    flex-direction: column;
}

.modal-fullscreen .modal-content.preview-content {
    background-color: #525252;
}

.modal-fullscreen .modal-header {
    background-color: #333;
    color: white;
    border-bottom: none;
}

.modal-fullscreen .modal-header h2 {
    color: white;
}

.modal-fullscreen .close-btn {
    color: white;
    font-size: 2rem;
}

.preview-controls {
    display: flex;
    align-items: center;
    gap: 16px;
}

#preview-page-info {
    font-size: 0.875rem;
    color: #ccc;
}

.preview-controls .toolbar-btn {
    background: #555;
    color: white;
    border: none;
}

.preview-controls .toolbar-btn:hover {
    background: #666;
}

.preview-body {
    flex: 1;
    overflow-y: auto;
    padding: 40px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
}

/* Preview Pages */
.preview-page {
    width: 8.5in;
    min-height: 11in;
    background-color: white;
    box-shadow: 0 4px 20px rgba(0,0,0,0.3);
    padding: 1in;
    padding-top: 0.5in;
    font-family: 'Courier Prime', 'Courier New', monospace;
    font-size: 12pt;
    line-height: 1;
    position: relative;
    color: #000;
    box-sizing: border-box;
    flex-shrink: 0;
}

.preview-page-number {
    text-align: right;
    margin-bottom: 0.5in;
    font-size: 12pt;
    color: #000;
}

/* Preview Title Page */
.preview-title-page {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    height: 100%;
    position: relative;
}

.preview-title-page .title-section {
    margin-top: 3in;
}

.preview-title-page .title {
    font-size: 24pt;
    font-weight: normal;
    text-transform: uppercase;
    margin-bottom: 36pt;
}

.preview-title-page .written-by {
    margin-bottom: 12pt;
}

.preview-title-page .author {
    margin-bottom: 48pt;
}

.preview-title-page .contact {
    position: absolute;
    bottom: 0;
    left: 0;
    text-align: left;
    font-size: 12pt;
    white-space: pre-line;
    line-height: 1.5;
}

/* Preview Content Elements */
.preview-element {
    margin-bottom: 1em;
    line-height: 1;
}

.preview-element.scene-heading {
    text-transform: uppercase;
    font-weight: bold;
    margin-top: 1em;
}

.preview-element.character {
    text-transform: uppercase;
    margin-left: 2in;
    margin-bottom: 0;
}

.preview-element.dialogue {
    margin-left: 1in;
    margin-right: 1.5in;
    margin-top: 0;
}

.preview-element.parenthetical {
    margin-left: 1.5in;
    margin-right: 2in;
    margin-top: 0;
    margin-bottom: 0;
}

.preview-element.transition {
    text-transform: uppercase;
    text-align: right;
    margin-top: 1em;
}
