/* Reset and Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

/* Custom Font Loading */
@font-face {
    font-family: 'SFProDisplay';
    src: url('/fonts/SFPRODISPLAYREGULAR.OTF');
}

@font-face {
    font-family: 'SFProDisplay Medium';
    src: url('/fonts/SFPRODISPLAYMEDIUM.OTF');
}

@font-face {
    font-family: 'SFProDisplay BlackItalic';
    src: url('/fonts/SFPRODISPLAYBLACKITALIC.OTF');
}

@font-face {
    font-family: 'SFProDisplay Bold';
    src: url('/fonts/SFPRODISPLAYBOLD.OTF');
}

@font-face {
    font-family: 'SFProDisplay HeavyItalic';
    src: url('/fonts/SFPRODISPLAYHEAVYITALIC.OTF');
}

@font-face {
    font-family: 'SFProDisplay LightItalic';
    src: url('/fonts/SFPRODISPLAYLIGHTITALIC.OTF');
}

@font-face {
    font-family: 'SFProDisplay SemiboldItalic';
    src: url('/fonts/SFPRODISPLAYSEMIBOLDITALIC.OTF');
}

@font-face {
    font-family: 'SFProDisplay ThinItalic';
    src: url('/fonts/SFPRODISPLAYTHINITALIC.OTF');
}

@font-face {
    font-family: 'SFProDisplay UltraLightItalic';
    src: url('/fonts/SFPRODISPLAYULTRALIGHTITALIC.OTF');
}

body {
    font-family: 'SFProDisplay', sans-serif;
    background: white;
    color: #000;
    line-height: 1.5;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 40px;
}

/* Header */
.header {
    /*margin-bottom: 20px;*/
    padding-bottom: 25px;
    /*border-bottom: 1px solid #ddd;*/
}

.header-top {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    /*margin-bottom: 40px;*/
}

.language-switcher {
    display: flex;
    border: 1px solid #ddd;
    border-radius: 4px;
    overflow: hidden;
    margin-top: 20px;
}

.lang-btn {
    /*padding: 8px 16px;*/
    background: white;
    border: none;
    cursor: pointer;
    font-family: inherit;
    font-size: 14px;
    color: #666;
    transition: all 0.2s ease;
    /*min-width: 48px;*/
    width: 36px;
    height: 36px;
}

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

.lang-btn.active {
    background: #000;
    color: white;
}

.lang-btn:first-child {
    border-right: 1px solid #ddd;
}

.lang-btn.active:first-child {
    border-right: 1px solid #000;
}

.title {
    font-family: 'SFProDisplay Bold', sans-serif;
    margin-bottom: 40px;
    color: #070707;
    font-size: 88px;
    line-height: 70px;
    letter-spacing: 1px;
}

.subtitle {
    color: #070707;
    margin-bottom: 30px;
    width: 100%;
    font-size: 36px;
    line-height: 44px;
    white-space: pre-line;
}

/*.description {*/
/*    font-size: 18px;*/
/*    color: #000;*/
/*}*/

/* Toolbar */
.toolbar {
    display: flex;
    align-items: flex-start;
    justify-content: flex-start;
    width: 100%;
    margin-bottom: 30px;
    padding-bottom: 25px;
    border-bottom: 1px solid #ddd;
    /*gap: 130px;*/
}

.story-drag {
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    align-items: flex-start;
    width: 100%;
    margin-left: 120px
}

.toolbar-title, .story-selector-title {
    font-family: 'SFProDisplay Bold', sans-serif;
    font-size: 18px;
    font-weight: 400;
    color: #070707;
    width: 100%;
    margin-bottom: 18px;
}

.shapes-row {
    display: flex;
    width: 100%;
    align-items: center;
    justify-content: flex-start;
    /*justify-content: space-between;*/
    gap: 30px;
}

.shape-tool {
    cursor: grab;
    padding: 0;
    user-select: none;
}

.shape-tool:active {
    cursor: grabbing;
}

.shape-square {
    width: 100px;
    height: 100px;
    background: #000;
}

.shape-circle {
    width: 100px;
    height: 100px;
    background: #000;
    border-radius: 50%;
}

.shape-triangle {
    width: 0;
    height: 0;
    border-left: 60px solid transparent;
    border-right: 60px solid transparent;
    border-bottom: 100px solid #000;
}

/* Main Content Layout */
.main-content {
    display: flex;
    gap: 60px;
    /*margin-bottom: 25px;*/
    padding-bottom: 30px;
    border-bottom: 1px solid #ddd;
}

/* Sidebar */
.sidebar {
    width: 50%;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
}

/* Story Selector Styling */
.story-selector {
    width: 100%;
    margin-bottom: 30px;
    position: relative;
}

/* NEW: Story Chips Styling */
.story-chips-container {
    width: 100%;
}

.story-chips-row {
    display: flex;
    gap: 8px;
    margin-bottom: 8px;
    flex-wrap: wrap;
}

.story-chips-row:last-child {
    margin-bottom: 0;
}

.story-chip {
    min-height: 36px; /* Touch-friendly minimum */
    padding: 10px 16px;
    border: 1px solid #ccc;
    border-radius: 50px;
    background: white;
    cursor: pointer;
    font-family: inherit;
    font-size: 16px;
    color: #000;
    transition: all 0.2s ease;
    white-space: nowrap;
    outline: none;
    user-select: none;
}

.story-chip:hover {
    background: #f5f5f5;
    border-color: #999;
}

.story-chip:active {
    transform: translateY(1px);
}

.story-chip.active {
    background: #000;
    color: white;
    border-color: #000;
}

.story-chip.active:hover {
    background: #000;
    color: white;
}

/* Responsive chips layout */
@media (max-width: 768px) {
    .story-chips-container {
        width: 100%;
    }

    .story-chip {
        font-size: 13px;
        padding: 8px 12px;
        min-height: 40px;
    }
}

/* OLD: Remove dropdown styles (keeping for reference/cleanup) */
.dropdown-container {
    display: none; /* Hide old dropdown */
}

.story-dropdown {
    display: none; /* Hide old dropdown */
}

/* Updated onboarding with scrolling support */
.onboarding {
    max-height: 558px; /* Set a fixed max height */
    overflow-y: auto;  /* Add vertical scrollbar when needed */
    /*padding-right: 8px; !* Space for scrollbar *!*/
}

/* Style the scrollbar for webkit browsers */
.onboarding::-webkit-scrollbar {
    width: 6px;
}

.onboarding::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 3px;
}

.onboarding::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 3px;
}

.onboarding::-webkit-scrollbar-thumb:hover {
    background: #a1a1a1;
}

.onboarding-title {
    font-size: 20px;
    margin-bottom: 25px;
    color: #070707;
    font-family: 'SFProDisplay Medium', sans-serif;
}

.step {
    margin-bottom: 20px;
}

/* NEW: Updated step structure */
.step-title {
    position: relative;
    padding-left: 15px;
    font-size: 16px;
    font-weight: 600;
    color: #070707;
    margin-bottom: 4px;
    font-family: 'SFProDisplay Medium', sans-serif;
    line-height: 1.3;
}

.step-title:before {
    content: '•';
    position: absolute;
    left: 0;
    color: #070707;
    font-weight: bold;
}

.step-description {
    padding: 0 15px;
    font-size: 16px;
    line-height: 1.4;
    color: #8E9193;
    /*margin-bottom: 8px;*/
}

/* Optional: Different states for steps */
.step.completed .step-title:before {
    content: '✓';
    color: #4CAF50;
}

.step.active .step-title:before {
    content: '•';
    color: #070707;
}

.step.pending .step-title:before {
    content: '○';
    color: #999;
}

.step.pending .step-title {
    color: #999;
}

.step.pending .step-description {
    color: #999;
}

/* Story content styles - ENHANCED FOR READABILITY */
.story-title {
    font-size: 20px;
    margin-bottom: 25px;
    color: #070707;
    font-family: 'SFProDisplay Medium', sans-serif;
}

/* NEW: Editable Story Title Input */
.story-title-input {
    width: 100%;
    padding: 0;
    border: none;
    background: transparent;
    font-size: 20px;
    font-weight: 600;
    margin-bottom: 32px;
    color: #070707;
    font-family: 'SFProDisplay Medium', sans-serif;
    outline: none;
    resize: none;
    overflow: hidden;
    line-height: 1.2;
    transition: all 0.2s ease;
    cursor: text;
}

.story-title-input:hover {
    /*background: rgba(0, 0, 0, 0.02);*/
    /*border-radius: 4px;*/
    padding: 4px 8px;
    margin: -4px -8px 21px -8px; /* Adjust margins to maintain spacing */
}

.story-title-input:focus {
    /*background: rgba(0, 0, 0, 0.05);*/
    /*border-radius: 4px;*/
    padding: 4px 8px;
    margin: -4px -8px 21px -8px; /* Adjust margins to maintain spacing */
    /*box-shadow: 0 0 0 2px rgba(0, 0, 0, 0.1);*/
}

.story-title-input::placeholder {
    color: #999;
    /*font-style: italic;*/
    font-family: 'SFProDisplay', sans-serif;
}

.story-content {
    line-height: 1.6;
    max-height: 503px; /* Fixed height for consistent layout */
    overflow-y: auto; /* Enable scrolling for long texts */
    /*padding: 0 16px 0 0; !* Comfortable padding *!*/
    scroll-behavior: smooth; /* Smooth scrolling */
}

/* Enhanced scrollbar for story content */
.story-content::-webkit-scrollbar {
    width: 6px;
}

.story-content::-webkit-scrollbar-track {
    background: #f5f5f5;
    border-radius: 3px;
}

.story-content::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 3px;
}

.story-content::-webkit-scrollbar-thumb:hover {
    background: #a1a1a1;
}

.story-section {
    margin-bottom: 25px;
    padding-bottom: 15px;
    border-bottom: 1px solid #f5f5f5;
}

.story-section:last-child {
    border-bottom: none;
    margin-bottom: 15px;
}

.story-section-title {
    font-size: 14px;
    font-weight: 600;
    color: #070707;
    margin-bottom: 8px;
}

.story-text {
    font-size: 16px; /* Increased from 14px for better readability */
    color: #222; /* Darker for better contrast */
    line-height: 1.6; /* Improved line spacing */
    white-space: pre-line; /* Preserve line breaks and paragraph spacing */
    margin-bottom: 0; /* Remove bottom margin since pre-line handles spacing */
    text-align: left; /* Justified text for better appearance */
    hyphens: auto; /* Enable hyphenation for better text flow */
    padding: 0 16px 0 0; /* Comfortable padding */

}

.story-shapes {
    background: #fafafa;
    padding: 12px;
    border-radius: 4px;
    border-left: 3px solid #ddd;
}

.story-shapes strong {
    font-size: 12px;
    color: #666;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.story-shapes ul {
    list-style: none;
    padding-left: 0;
    margin: 8px 0 0 0;
}

.story-shapes li {
    font-size: 13px;
    color: #555;
    margin-bottom: 4px;
    line-height: 1.3;
}

.story-tips {
    background: #f8f9fa;
    padding: 15px;
    border-radius: 6px;
    border: 1px solid #e9ecef;
    margin-top: 20px;
}

.tips-title {
    font-size: 14px;
    font-weight: 600;
    color: #070707;
    margin-bottom: 10px;
}

.story-tips ul {
    list-style: none;
    padding-left: 0;
    margin: 0;
}

.story-tips li {
    font-size: 13px;
    color: #555;
    margin-bottom: 6px;
    line-height: 1.4;
}

/* Custom Story Editor Styles - FIXED VERSION */
.custom-story-editor {
    width: 100%;
    min-height: 300px;
    padding: 0 16px 0 0;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-family: 'SFProDisplay', sans-serif;
    font-size: 16px;
    line-height: 1.5;
    color: #333;
    background: white;
    resize: vertical;
    outline: none;
    transition: border-color 0.2s ease;
}

.custom-story-editor:focus {
    border-color: #070707;
}

.custom-story-editor::placeholder {
    color: #999;
    font-style: italic;
}

/* Story Editor Mode - FIXED VERSION */
.onboarding.story-editor-mode {
    max-height: none; /* Remove height restriction */
    flex: 1; /* Take all available height */
    display: flex;
    flex-direction: column;
    margin-bottom: 0; /* Remove bottom margin to use full height */
}

.story-editor-mode .story-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    scroll-behavior: smooth;
}

.story-editor-mode .custom-story-editor {
    height: 496px; /* Fixed height to align bottom with canvas */
    min-height: unset; /* Remove min-height */
    max-height: unset; /* Remove max-height */
    resize: none; /* Disable resize completely */
    border: none;
}

/* Canvas Area */
.canvas-area {
    flex: 1;
    max-width: 50%;
}

.frame-controls {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
    max-width: 500px;
}

.frame-controls-pagination {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 10px;
}

.frame-nav {
    display: flex;
    align-items: center;
    gap: 8px;
}

.frame-btn {
    width: 36px;
    height: 36px;
    border: 1px solid #ccc;
    background: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    color: #070707;
    font-family: inherit;
    transition: background-color 0.1s ease;
}

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

.frame-btn.active {
    border-color: #070707;
    background: #fff;
    color: #070707;
}

.frame-btn.add {
    font-size: 18px;
}

.nav-arrow {
    width: 36px;
    height: 36px;
    border: 1px solid #ccc;
    background: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #666;
    font-family: inherit;
    font-size: 1.2rem;
    transition: background-color 0.1s ease;
}

.nav-arrow:hover {
    background: #f5f5f5;
}

.nav-arrow:disabled {
    opacity: 0.3;
    cursor: not-allowed;
    background: white;
}

.nav-arrow:disabled:hover {
    background: white;
}

.play-btn {
    padding: 8px 16px;
    border: 1px solid #ccc;
    background: white;
    cursor: pointer;
    font-size: 0.9rem;
    color: #070707;
    margin-left: 16px;
    font-family: inherit;
    transition: background-color 0.1s ease;
}

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

.play-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.canvas-container {
    width: 502px;  /* 500px canvas + 2px for borders */
    height: 502px;
    border: 1px solid #C1C3C4;
    background: white;
    position: relative;
    overflow: visible; /* Changed from hidden to visible */
    box-sizing: border-box;
}

.empty {
    display: flex;
    flex-direction: column;
}
.empty-img {
    position: absolute;
    top: 30%;
    left: 35%;
    pointer-events: none;
}

.empty-state-text {
    position: absolute;
    top: 57%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: #CDD2DA;
    font-size: 14px;
    pointer-events: none;
}

/* Contextual Toolbar */
.contextual-toolbar {
    position: absolute;
    background: white;
    border-radius: 4px;
    padding: 4px;
    display: none;
    gap: 2px;
    z-index: 1000;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25) !important; /* Force shadow with !important */
}

.contextual-toolbar.visible {
    display: flex;
}

.context-btn {
    width: 28px;
    height: 28px;
    border: none;
    background: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8rem;
    font-family: inherit;
    border-radius: 2px;
    transition: background-color 0.1s ease;
}

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

/* Fabric.js Canvas Adjustments - Force remove ALL borders */
.canvas-container canvas {
    display: block;
    border: none !important;
    outline: none !important;
    box-shadow: none !important;
}

/* Remove borders from ALL elements inside canvas container (except contextual toolbar) */
.canvas-container *:not(.contextual-toolbar) {
    border: none !important;
    outline: none !important;
    box-shadow: none !important;
}

/* Story Timeline */
.story-timeline {
    margin-top: 8px;
}

.timeline-container {
    margin-bottom: 10px;
}

.timeline-title {
    font-size: 14px;
    font-weight: 500;
    color: #070707;
    margin-bottom: 15px;
}


.timeline-frames {
    display: flex;
    gap: 10px;
    overflow-x: auto;
    padding-bottom: 5px;
    padding-top: 5px;
}

.timeline-frames::-webkit-scrollbar {
    height: 6px;
}

.timeline-frames::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 3px;
}

.timeline-frames::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 3px;
}

.timeline-frames::-webkit-scrollbar-thumb:hover {
    background: #a1a1a1;
}

.timeline-frame {
    min-width: 120px;
    height: 120px;
    border: 1px solid #ddd;
    border-radius: 1px;
    background: white;
    cursor: pointer;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    overflow: hidden;
    object-fit: cover;
    image-rendering: crisp-edges;
    backface-visibility: hidden;
    transform: translateZ(0);
}

.timeline-frame:hover {
    border-color: #999;
    transform: translateY(-2px);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.timeline-frame.active {
    border-color: #070707;
    border-width: 1px;
}

.timeline-frame.empty {
    background: #f9f9f9;
    border-style: dashed;
    color: #ccc;
    font-size: 12px;
}

.timeline-frame img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 2px;
}

.timeline-frame-number {
    position: absolute;
    top: 2px;
    left: 4px;
    background: rgba(0, 0, 0, 0.7);
    color: white;
    font-size: 10px;
    padding: 1px 4px;
    border-radius: 2px;
    font-weight: 500;
}

/* Mobile responsiveness for story content */
@media (max-width: 768px) {
    .onboarding {
        max-height: 300px;
    }

    .onboarding.story-editor-mode {
        max-height: none; /* Keep full height on mobile too */
    }

    .story-text {
        font-size: 13px;
    }

    .story-shapes li {
        font-size: 12px;
    }

    .custom-story-editor {
        min-height: 250px;
    }

    .story-editor-mode .custom-story-editor {
        height: 350px; /* Adjusted fixed height for mobile */
        min-height: unset;
        max-height: unset;
        resize: none;
    }

    .story-title-input {
        font-size: 18px;
    }

    .step-title {
        font-size: 15px;
    }

    .step-description {
        font-size: 15px;
    }
}