/* --- Font Imports --- */
/* For general UI elements */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');
/* For the script editor content */
@import url('https://fonts.googleapis.com/css2?family=Courier+Prime&display=swap');

/* --- Global Body & Base Styling --- */
body {
    font-family: 'Inter', 'Helvetica Neue', Arial, sans-serif; /* General UI font */
    margin: 0;
    padding: 0;
    background-color: #0A0A0A; /* Deep black background for consistency */
    color: #E0E0E0; /* Off-white for general text */
    line-height: 1.6; /* Standard line spacing for UI */
    min-height: 100vh; /* Ensure body covers full viewport height */
    display: flex;
    flex-direction: column; /* For overall page layout */
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* --- Global Header Section (consistent across app) --- */
header {
    background: linear-gradient(160deg, #1A1A1A 0%, #0A0A0A 100%); /* Dark, subtle gradient */
    color: white;
    padding: 25px 25px 20px; /* Adjusted padding */
    text-align: left;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.4);
    position: sticky; /* Make header sticky */
    top: 0;
    z-index: 990;
    border-bottom: 1px solid #282828;
    display: flex; /* Use flexbox for header content */
    justify-content: space-between; /* Space out title and right buttons */
    align-items: center;
    flex-wrap: wrap; /* Allow wrapping on smaller screens */
    gap: 15px; /* Gap for wrapped items */
}

header h1 {
    margin: 0;
    font-size: 2.2em; /* Larger, more impactful title */
    font-weight: 700;
    text-shadow: 1px 1px 3px rgba(0, 0, 0, 0.2);
    letter-spacing: -0.8px;
    flex-grow: 1; /* Allow title to take available space */
}

/* Header Navigation (specific to Editor page, integrated into global header) */
header nav {
    display: flex;
    align-items: center;
    gap: 12px; /* Adjusted gap */
    flex-wrap: wrap;
    margin-top: 0; /* Align with other header elements */
}

header nav a {
    color: #E0E0E0; /* Off-white for nav links */
    text-decoration: none;
    font-size: 1.1em; /* Slightly larger */
    font-weight: 500;
    padding: 8px 15px; /* Added padding for clickable area */
    border-radius: 8px; /* Rounded corners */
    transition: all 0.3s ease;
}

header nav a:hover {
    color: white; /* White on hover */
    background-color: #1A1A1A; /* Darker background on hover */
    transform: translateY(-2px); /* Subtle lift */
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

header nav a.active {
    color: white;
    background-color: #2E8B57; /* Kinema+ Green for active link */
    box-shadow: 0 2px 8px rgba(46, 139, 87, 0.4);
}

/* --- Global Top-Right Buttons (Profile, Share, Notification) --- */
.top-right-buttons {
    display: flex;
    justify-content: flex-end;
    gap: 15px;
    margin-left: auto; /* Push to the right if space allows */
}

.icon-btn {
    background: linear-gradient(to bottom right, #1A1A1A, #0A0A0A);
    border: 1px solid #282828;
    padding: 12px;
    border-radius: 50%;
    width: 50px;
    height: 50px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
    cursor: pointer;
    transition: all 0.3s ease;
    flex-shrink: 0; /* Prevent shrinking on small screens */
}

.icon-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 15px rgba(0, 0, 0, 0.5);
    background: linear-gradient(to bottom right, #2E8B57, #246B44); /* Kinema+ Green on hover */
}
.icon-btn:active {
    transform: translateY(0);
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.4) inset;
}

.icon-btn img {
    width: 24px;
    height: 24px;
    filter: brightness(0) invert(1); /* Makes icon white */
}
.icon-btn:hover img {
    filter: brightness(100%) invert(0); /* Removes filter to show original (white) */
}

/* User profile button in top right */
#profileBtn img {
    width: 38px; /* Slightly larger for profile */
    height: 38px;
    border-radius: 50%;
    object-fit: cover;
    border: 3px solid #2E8B57; /* Kinema+ Green border for prominence */
    box-shadow: 0 0 0 2px #1A1A1A; /* Inner dark shadow */
    transition: transform 0.2s ease;
}
#profileBtn img:hover {
    transform: scale(1.05); /* Slight scale on hover */
}


/* --- Main Editor Container --- */
.editor-container {
    display: flex;
    flex-direction: column;
    padding: 30px; /* Increased padding */
    max-width: 1000px;
    margin: 30px auto 100px auto; /* Margin for bottom nav */
    background-color: #111111; /* Dark background for main content area */
    border-radius: 18px; /* More rounded */
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5); /* Deeper shadow */
    border: 1px solid #282828; /* Subtle border */
    flex-grow: 1; /* Allows main content to fill available space */
}

/* Toolbar */
.toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: 12px; /* More space between buttons */
    padding-bottom: 20px;
    border-bottom: 1px solid #282828; /* Darker border */
    margin-bottom: 25px;
    justify-content: center;
    background-color: #1A1A1A; /* Dark background for toolbar */
    padding: 15px;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.toolbar-btn {
    background-color: #222222; /* Dark button background */
    color: #E0E0E0; /* Off-white text */
    border: 1px solid #3A3A3A; /* Subtle border */
    padding: 10px 18px; /* More padding */
    border-radius: 8px; /* Rounded corners */
    cursor: pointer;
    font-size: 0.95em;
    font-weight: 500;
    transition: background-color 0.3s ease, transform 0.2s ease, box-shadow 0.3s ease;
    flex-grow: 1;
    max-width: 160px; /* Slightly wider max width */
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
}

.toolbar-btn:hover {
    background-color: #2E8B57; /* Kinema+ Green on hover */
    color: white;
    transform: translateY(-3px);
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.3);
}
.toolbar-btn:active {
    transform: translateY(0);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3) inset;
    background-color: #246B44;
}

.toolbar-btn.active {
    background-color: #2E8B57; /* Kinema+ Green for active button */
    color: white;
    box-shadow: 0 0 0 2px #2E8B57, inset 0 0 5px rgba(0,0,0,0.3); /* Green outline and inner shadow */
    transform: translateY(0); /* Prevent lift when active */
}

.toolbar-btn.download-btn {
    background-color: #4C3C24; /* Darker orange/brown */
    border-color: #7A602B;
    color: #FFD700; /* Gold text */
}
.toolbar-btn.download-btn:hover {
    background-color: #6B5532;
    border-color: #9A7C4B;
    color: white;
}

.toolbar-btn.clear-btn {
    background-color: #5C2D2F; /* Darker red */
    border-color: #7F3C3F;
    color: #FF7070; /* Light red text */
}
.toolbar-btn.clear-btn:hover {
    background-color: #7F3E41;
    border-color: #A05C60;
    color: white;
}

/* Scenario editor area */
.scenario-editor {
    min-height: 600px; /* Taller editor */
    padding: 30px 50px; /* More generous padding */
    border: 1px solid #3A3A3A; /* Darker border */
    border-radius: 8px;
    outline: none;
    font-family: 'Courier Prime', monospace; /* Keep monospaced for script */
    font-size: 1.15em; /* Slightly larger text */
    background-color: #0F0F0F; /* Very dark background for editor */
    color: #F0F0F0; /* Off-white text for content */
    overflow-y: auto;
    white-space: pre-wrap;
    word-wrap: break-word;
    resize: vertical; /* Allow vertical resizing */
    line-height: 1.4; /* Adjusted line height for readability */
    box-shadow: inset 0 0 8px rgba(0, 0, 0, 0.4); /* Inner shadow for depth */
}

/* Scrollbar styles for dark theme */
.scenario-editor::-webkit-scrollbar {
    width: 8px;
}
.scenario-editor::-webkit-scrollbar-track {
    background: #1A1A1A;
    border-radius: 10px;
}
.scenario-editor::-webkit-scrollbar-thumb {
    background: #444;
    border-radius: 10px;
}
.scenario-editor::-webkit-scrollbar-thumb:hover {
    background: #555;
}

.scenario-editor:focus {
    border-color: #2E8B57; /* Kinema+ Green on focus */
    box-shadow: 0 0 0 3px rgba(46, 139, 87, 0.3), inset 0 0 8px rgba(0, 0, 0, 0.4); /* Green glow */
}

/* Placeholder for editable area */
.scenario-editor:empty:before {
    content: attr(placeholder);
    color: #777; /* Softer placeholder color */
    font-style: italic;
    pointer-events: none;
}

/* Specific scenario elements (Studiovity-like) */
.scenario-editor p {
    margin-top: 1em;
    margin-bottom: 0.5em;
    padding: 0;
    text-align: left;
    white-space: pre-wrap;
    word-break: break-word;
    color: #E0E0E0; /* Default text color for elements */
}

/* 1. Scene Heading */
.scene-heading {
    text-transform: uppercase;
    font-weight: bold;
    margin-top: 2.2em; /* More space above */
    margin-bottom: 0.6em;
    text-align: left;
    color: #F0F0F0; /* Slightly brighter for headings */
    letter-spacing: 0.5px;
}

/* 2. Action */
.action {
    text-align: left;
    margin-left: 0;
    margin-right: 0;
}

/* 3. Character */
.character {
    text-align: center;
    margin-top: 1.2em;
    margin-bottom: 0.3em;
    text-transform: uppercase;
    font-weight: bold;
    color: #8BC34A; /* Brighter Kinema+ Green for characters */
    letter-spacing: 0.8px;
}

/* 4. Dialogue */
.dialogue {
    margin-left: 1.5in; /* ~144px */
    margin-right: 1.5in; /* ~144px */
    text-align: left;
    margin-top: 0.3em;
    margin-bottom: 0.3em;
    color: #E8E8E8; /* Slightly brighter for dialogue */
}

/* 5. Parenthetical */
.parenthetical {
    margin-left: 2in; /* More indented */
    margin-right: 2in;
    text-align: left;
    font-style: italic;
    margin-top: 0.2em;
    margin-bottom: 0.2em;
    color: #A0A0A0; /* Softer gray for parentheticals */
}

/* 6. Transition */
.transition {
    text-align: right;
    text-transform: uppercase;
    margin-top: 1.5em;
    margin-bottom: 1.5em;
    font-weight: bold;
    color: #F0F0F0; /* Slightly brighter */
    letter-spacing: 0.5px;
}

/* --- Global Bottom Navigation --- */
footer {
    text-align: center;
    padding: 25px; /* More padding */
    margin-top: auto; /* Pushes footer to the bottom */
    background-color: #111111; /* Dark background */
    color: #A0A0A0; /* Softer gray text */
    box-shadow: 0 -5px 15px rgba(0, 0, 0, 0.4); /* Deeper shadow */
    border-top: 1px solid #282828; /* Subtle top border */
    font-size: 0.95em;
}

.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background-color: #111111; /* Dark background */
    display: flex;
    justify-content: space-around;
    padding: 12px 0;
    z-index: 999;
    box-shadow: 0 -8px 20px rgba(0, 0, 0, 0.4);
    border-top-left-radius: 20px;
    border-top-right-radius: 20px;
    border-top: 1px solid #282828;
}

.bottom-nav .nav-item {
    color: #888888; /* Muted gray for inactive items */
    text-align: center;
    text-decoration: none;
    display: flex;
    flex-direction: column;
    align-items: center;
    font-size: 12px;
    padding: 8px 5px;
    border-radius: 12px;
    transition: all 0.3s ease;
    flex-grow: 1;
    max-width: 90px;
}

.bottom-nav .nav-item img {
    filter: invert(70%); /* Grayish filter for inactive icons */
    margin-bottom: 5px;
    width: 26px;
    height: 26px;
    transition: filter 0.3s ease;
}

.bottom-nav .nav-item span {
    font-size: 0.9em;
    font-weight: 500;
}

.bottom-nav .nav-item:hover {
    background-color: #1A1A1A; /* Darker background on hover */
    color: #E0E0E0;
    transform: translateY(-3px);
}
.bottom-nav .nav-item:hover img {
    filter: invert(100%);
}

.bottom-nav .nav-item.active {
    background-color: #2E8B57; /* Kinema+ Green for active item */
    color: #fff;
    transform: translateY(-5px);
    box-shadow: 0 -5px 15px rgba(46, 139, 87, 0.3);
}
.bottom-nav .nav-item.active img {
    filter: invert(0%) brightness(100%);
}


/* --- Responsive Adjustments --- */
@media (max-width: 992px) {
    header {
        padding: 20px;
    }
    header h1 {
        font-size: 2em;
    }
    header nav {
        gap: 10px;
    }
    header nav a {
        padding: 7px 12px;
        font-size: 1em;
    }
    .top-right-buttons {
        gap: 10px;
    }
    .icon-btn {
        width: 45px;
        height: 45px;
        padding: 10px;
    }
    .icon-btn img {
        width: 22px;
        height: 22px;
    }
    #profileBtn img {
        width: 35px;
        height: 35px;
    }

    .editor-container {
        padding: 25px;
        margin: 25px auto 90px auto;
    }
    .toolbar {
        gap: 10px;
        padding: 12px;
        margin-bottom: 20px;
    }
    .toolbar-btn {
        padding: 9px 15px;
        font-size: 0.9em;
        max-width: 150px;
    }
    .scenario-editor {
        min-height: 550px;
        padding: 25px 40px;
        font-size: 1.1em;
    }
    .dialogue, .parenthetical {
        margin-left: 1.2in;
        margin-right: 1.2in;
    }
    footer {
        padding: 20px;
        font-size: 0.9em;
    }
    .bottom-nav {
        padding: 10px 0;
    }
    .bottom-nav .nav-item {
        font-size: 11px;
    }
}

@media (max-width: 768px) {
    header {
        flex-direction: column;
        gap: 10px;
        padding: 15px;
    }
    header h1 {
        font-size: 1.8em;
        text-align: center;
    }
    header nav {
        width: 100%;
        justify-content: center;
        margin-top: 10px;
    }
    .top-right-buttons {
        position: relative;
        top: auto;
        right: auto;
        margin-top: 15px;
        width: 100%;
        justify-content: center;
    }
    .icon-btn {
        width: 45px;
        height: 45px;
        padding: 10px;
    }
    .icon-btn img {
        width: 22px;
        height: 22px;
    }
    #profileBtn img {
        width: 32px;
        height: 32px;
    }

    .editor-container {
        padding: 20px;
        margin: 20px 15px 80px 15px;
        border-radius: 12px;
    }
    .toolbar {
        flex-direction: row;
        justify-content: center; /* Center buttons */
        gap: 8px;
        padding: 10px;
        margin-bottom: 20px;
    }
    .toolbar-btn {
        flex-grow: 1;
        max-width: none; /* Allow full width */
        width: auto;
        padding: 8px 12px;
        font-size: 0.85em;
    }
    .scenario-editor {
        min-height: 450px;
        padding: 20px 30px;
        font-size: 1em;
    }
    .dialogue, .parenthetical {
        margin-left: 0.8in; /* Reduce indentation on mobile */
        margin-right: 0.8in;
    }
    footer {
        padding: 15px;
        font-size: 0.85em;
    }
    .bottom-nav {
        padding: 10px 0;
        border-top-left-radius: 15px;
        border-top-right-radius: 15px;
    }
    .bottom-nav .nav-item {
        font-size: 10px;
        padding: 5px 3px;
        max-width: 80px;
    }
    .bottom-nav .nav-item img {
        width: 22px;
        height: 22px;
    }
}

@media (max-width: 480px) {
    header {
        padding: 15px;
    }
    header h1 {
        font-size: 1.5em;
    }
    header nav a {
        padding: 6px 10px;
        font-size: 0.9em;
    }
    .icon-btn {
        width: 40px;
        height: 40px;
        padding: 8px;
    }
    .icon-btn img {
        width: 20px;
        height: 20px;
    }
    #profileBtn img {
        width: 30px;
        height: 30px;
    }

    .editor-container {
        padding: 15px;
        margin: 15px 10px 70px 10px;
    }
    .toolbar {
        gap: 6px;
        padding: 8px;
        margin-bottom: 15px;
    }
    .toolbar-btn {
        padding: 6px 10px;
        font-size: 0.8em;
    }
    .scenario-editor {
        min-height: 350px;
        padding: 15px 20px;
        font-size: 0.95em;
    }
    .dialogue, .parenthetical {
        margin-left: 0.5in;
        margin-right: 0.5in;
    }
    footer {
        padding: 12px;
        font-size: 0.75em;
    }
    .bottom-nav {
        padding: 8px 0;
    }
    .bottom-nav .nav-item {
        font-size: 9px;
        padding: 4px 2px;
    }
    .bottom-nav .nav-item img {
        width: 20px;
        height: 20px;
    }
}
