/* Ren'py Visual Story Editor - Dark Theme */

/* Reset and Base */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    background-color: #1a1a2e;
    color: #eee;
    overflow: hidden;
}

/* Utility */
.hidden {
    display: none !important;
}

/* Header */
#header {
    height: 50px;
    background-color: #16213e;
    border-bottom: 1px solid #0f3460;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 20px;
}

#header.homepage-mode {
    justify-content: center;
}

#header.homepage-mode .header-actions {
    display: none;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 15px;
}

#header h1 {
    font-size: 18px;
    color: #e94560;
}

.story-title {
    color: #4a9eff;
    font-size: 14px;
    font-weight: 500;
    padding-left: 15px;
    border-left: 1px solid #0f3460;
}

#btn-back {
    padding: 6px 12px;
    background-color: #0f3460;
    color: #fff;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 13px;
}

#btn-back:hover {
    background-color: #e94560;
}

.header-actions {
    display: flex;
    gap: 10px;
}

.header-actions button {
    padding: 6px 14px;
    background-color: #0f3460;
    color: #fff;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 13px;
    transition: background-color 0.2s;
}

.header-actions button:hover {
    background-color: #e94560;
}

/* Homepage */
#homepage {
    min-height: calc(100vh - 50px);
    padding: 40px;
    background-color: #1a1a2e;
}

.homepage-header {
    text-align: center;
    margin-bottom: 40px;
}

.homepage-header h1 {
    font-size: 36px;
    color: #e94560;
    margin-bottom: 10px;
}

.homepage-header .subtitle {
    color: #888;
    font-size: 16px;
}

.homepage-actions {
    display: flex;
    justify-content: center;
    gap: 20px;
    margin-bottom: 50px;
}

.btn-large {
    padding: 15px 30px;
    font-size: 16px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.btn-large .icon {
    font-size: 20px;
}

.btn-primary {
    background-color: #e94560;
    color: #fff;
    border: none;
    cursor: pointer;
    transition: background-color 0.2s;
}

.btn-primary:hover {
    background-color: #ff6b6b;
}

.btn-secondary {
    background-color: #0f3460;
    color: #fff;
    border: none;
    cursor: pointer;
    transition: background-color 0.2s;
}

.btn-secondary:hover {
    background-color: #4a9eff;
}

.stories-section h2 {
    font-size: 20px;
    color: #fff;
    margin-bottom: 20px;
    padding-bottom: 10px;
    border-bottom: 1px solid #0f3460;
}

.empty-state {
    text-align: center;
    padding: 60px;
    color: #666;
}

.empty-icon {
    font-size: 64px;
    margin-bottom: 20px;
}

.stories-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 20px;
}

.story-card {
    background-color: #16213e;
    border: 1px solid #0f3460;
    border-radius: 8px;
    padding: 20px;
    cursor: pointer;
    transition: all 0.2s;
}

.story-card:hover {
    border-color: #4a9eff;
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
}

.story-card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 15px;
}

.story-card-header h3 {
    font-size: 18px;
    color: #fff;
    margin: 0;
}

.btn-delete-story {
    background: none;
    border: none;
    color: #666;
    cursor: pointer;
    font-size: 16px;
    padding: 0;
    opacity: 0;
    transition: opacity 0.2s;
}

.story-card:hover .btn-delete-story {
    opacity: 1;
}

.btn-delete-story:hover {
    color: #e94560;
}

.story-card-stats {
    display: flex;
    gap: 15px;
    margin-bottom: 15px;
}

.stat {
    color: #888;
    font-size: 13px;
}

.story-card-footer {
    color: #666;
    font-size: 12px;
}

/* Main Container */
#main-container {
    display: flex;
    height: calc(100vh - 50px);
}

/* Sidebar */
#sidebar {
    width: 250px;
    background-color: #16213e;
    border-right: 1px solid #0f3460;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
}

#sidebar section {
    padding: 15px;
    border-bottom: 1px solid #0f3460;
}

#sidebar h2 {
    font-size: 14px;
    color: #e94560;
    margin-bottom: 10px;
    text-transform: uppercase;
}

#sidebar button {
    width: 100%;
    padding: 8px;
    background-color: #0f3460;
    color: #fff;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 12px;
    margin-bottom: 10px;
}

#sidebar button:hover {
    background-color: #e94560;
}

#sidebar ul {
    list-style: none;
}

#sidebar li {
    padding: 8px;
    background-color: #1a1a2e;
    margin-bottom: 5px;
    border-radius: 4px;
    font-size: 13px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    cursor: pointer;
}

#sidebar li:hover {
    background-color: #0f3460;
}

/* Canvas Container */
#canvas-container {
    flex: 1;
    position: relative;
    overflow: hidden;
    background-color: #0f0f23;
}

#canvas {
    width: 5000px;
    height: 5000px;
    position: relative;
    background-image: radial-gradient(#2a2a4a 1px, transparent 1px);
    background-size: 20px 20px;
}

/* Block Cards */
.block-card {
    position: absolute;
    width: 280px;
    background-color: #16213e;
    border: 2px solid #0f3460;
    border-radius: 8px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
    cursor: move;
    transition: box-shadow 0.2s, transform 0.2s;
}

.block-card:hover {
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.4);
}

.block-card.selected {
    border-color: #4a9eff;
    box-shadow: 0 0 15px rgba(74, 158, 255, 0.5);
}

.block-header {
    padding: 10px 12px;
    background-color: #0f3460;
    border-radius: 6px 6px 0 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.block-header span {
    font-weight: 600;
    font-size: 14px;
}

.block-actions {
    display: flex;
    gap: 5px;
}

.block-actions button {
    background: none;
    border: none;
    color: #aaa;
    cursor: pointer;
    font-size: 12px;
    padding: 2px 6px;
}

.block-actions button:hover {
    color: #e94560;
}

.block-content {
    padding: 10px;
    max-height: 300px;
    overflow-y: auto;
}

/* Nodes */
.node {
    padding: 8px 10px;
    margin-bottom: 8px;
    background-color: #1a1a2e;
    border-radius: 4px;
    font-size: 12px;
    line-height: 1.4;
}

.node:last-child {
    margin-bottom: 0;
}

.node-line {
    border-left: 3px solid #666;
    padding-left: 8px;
}

.node-menu {
    border-left: 3px solid #4a9eff;
    padding-left: 8px;
}

.char-tag {
    font-weight: 600;
    margin-right: 5px;
}

/* Editor Panel */
#editor-panel {
    width: 320px;
    background-color: #16213e;
    border-left: 1px solid #0f3460;
    padding: 20px;
    overflow-y: auto;
}

#editor-panel h2 {
    font-size: 16px;
    color: #e94560;
    margin-bottom: 15px;
}

.editor-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
    padding-bottom: 10px;
    border-bottom: 1px solid #0f3460;
}

.editor-header h3 {
    color: #fff;
    font-size: 16px;
}

.node-list {
    margin-bottom: 15px;
}

.empty-message {
    color: #888;
    font-style: italic;
    text-align: center;
    padding: 20px;
}

.editor-node {
    background-color: #1a1a2e;
    border: 1px solid #0f3460;
    border-radius: 4px;
    padding: 10px;
    margin-bottom: 10px;
}

.editor-node .node-info {
    margin-bottom: 8px;
}

.editor-node .node-type {
    display: inline-block;
    background-color: #0f3460;
    color: #4a9eff;
    font-size: 11px;
    padding: 2px 8px;
    border-radius: 3px;
    margin-right: 8px;
    text-transform: uppercase;
}

.editor-node .node-text {
    color: #ccc;
}

.editor-node .node-actions {
    display: flex;
    gap: 5px;
}

.editor-node .node-actions button {
    background-color: #0f3460;
    border: none;
    color: #fff;
    padding: 4px 8px;
    border-radius: 3px;
    cursor: pointer;
    font-size: 12px;
}

.editor-node .node-actions button:hover {
    background-color: #e94560;
}

.editor-node .node-actions button:disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

.editor-actions {
    display: flex;
    gap: 10px;
}

.editor-actions button {
    flex: 1;
    padding: 10px;
    background-color: #e94560;
    border: none;
    color: #fff;
    border-radius: 4px;
    cursor: pointer;
    font-size: 13px;
}

.editor-actions button:hover {
    background-color: #ff6b6b;
}

/* Choice rows in modal */
.choice-row {
    display: flex;
    gap: 10px;
    margin-bottom: 10px;
    align-items: center;
}

.choice-row input {
    flex: 1;
}

.choice-row select {
    width: 150px;
}

.choice-row button {
    background-color: #e94560;
    border: none;
    color: #fff;
    padding: 6px 10px;
    border-radius: 4px;
    cursor: pointer;
}

.choice-row button:disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

#btn-add-choice {
    width: 100%;
    padding: 8px;
    background-color: #0f3460;
    border: none;
    color: #fff;
    border-radius: 4px;
    cursor: pointer;
    margin-top: 10px;
}

#btn-add-choice:hover {
    background-color: #4a9eff;
}

/* Item actions in sidebar */
.item-actions {
    display: flex;
    gap: 5px;
}

.item-actions button {
    background: none;
    border: none;
    color: #aaa;
    cursor: pointer;
    font-size: 12px;
    padding: 2px 4px;
}

.item-actions button:hover {
    color: #e94560;
}

/* Assets Section */
.collapsible-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    cursor: pointer;
    padding: 5px;
    border-radius: 4px;
    transition: background-color 0.2s;
}

.collapsible-header:hover {
    background-color: #0f3460;
}

.assets-summary {
    font-size: 11px;
    color: #888;
    font-weight: normal;
}

.collapse-btn {
    background: none;
    border: none;
    color: #aaa;
    cursor: pointer;
    font-size: 12px;
    padding: 2px 5px;
}

.assets-content-wrapper {
    transition: max-height 0.3s ease;
    max-height: 1000px;
    overflow: hidden;
}

.assets-content-wrapper.collapsed {
    max-height: 0;
}

.assets-tabs {
    display: flex;
    gap: 5px;
    margin-bottom: 10px;
}

.tab-btn {
    flex: 1;
    padding: 6px;
    background-color: #1a1a2e;
    border: 1px solid #0f3460;
    color: #888;
    border-radius: 4px;
    cursor: pointer;
    font-size: 11px;
}

.tab-btn.active {
    background-color: #0f3460;
    color: #fff;
}

.tab-btn:hover:not(.active) {
    background-color: #0f3460;
    color: #ccc;
}

.assets-content {
    min-height: 100px;
}

.assets-content button {
    margin-bottom: 10px;
}

.btn-delete-asset {
    background: none;
    border: none;
    color: #666;
    cursor: pointer;
    font-size: 14px;
    padding: 0 4px;
    opacity: 0;
    transition: opacity 0.2s;
}

#sidebar li:hover .btn-delete-asset {
    opacity: 1;
}

.btn-delete-asset:hover {
    color: #e94560;
}

/* Line Asset Controls */
.line-asset-controls {
    margin-top: 15px;
    padding-top: 15px;
    border-top: 1px solid #0f3460;
}

.asset-control {
    margin-bottom: 15px;
}

.asset-control label {
    display: block;
    margin-bottom: 5px;
    color: #888;
    font-size: 12px;
}

.sprite-toggles {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.sprite-toggle {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    font-size: 13px;
}

.sprite-toggle input[type="checkbox"] {
    width: auto;
    margin: 0;
}

.no-assets {
    color: #666;
    font-style: italic;
    font-size: 12px;
}

/* Modals */
#modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0.7);
    z-index: 1000;
}

#modal-container {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background-color: #16213e;
    border: 1px solid #0f3460;
    border-radius: 8px;
    padding: 25px;
    min-width: 400px;
    max-width: 600px;
    max-height: 80vh;
    overflow-y: auto;
    z-index: 1001;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
}

#modal-content h3 {
    margin-bottom: 15px;
    color: #e94560;
}

#modal-content label {
    display: block;
    margin-bottom: 5px;
    font-size: 13px;
    color: #aaa;
}

#modal-content input,
#modal-content textarea,
#modal-content select {
    width: 100%;
    padding: 8px 12px;
    background-color: #1a1a2e;
    border: 1px solid #0f3460;
    border-radius: 4px;
    color: #fff;
    font-size: 13px;
    margin-bottom: 15px;
}

#modal-content input:focus,
#modal-content textarea:focus,
#modal-content select:focus {
    outline: none;
    border-color: #4a9eff;
}

#modal-content textarea {
    resize: vertical;
    min-height: 80px;
}

.modal-actions {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
    margin-top: 20px;
}

.modal-actions button {
    padding: 8px 20px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 13px;
}

.modal-actions .btn-primary {
    background-color: #e94560;
    color: #fff;
}

.modal-actions .btn-primary:hover {
    background-color: #ff6b6b;
}

.modal-actions .btn-secondary {
    background-color: #0f3460;
    color: #fff;
}

.modal-actions .btn-secondary:hover {
    background-color: #1a4a7a;
}

/* Toast Notifications */
#toast-container {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 2000;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.toast {
    padding: 12px 20px;
    border-radius: 4px;
    color: #fff;
    font-size: 13px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
    animation: slideIn 0.3s ease;
}

@keyframes slideIn {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

.toast.info {
    background-color: #0f3460;
}

.toast.success {
    background-color: #2ecc71;
}

.toast.warning {
    background-color: #f39c12;
}

.toast.error {
    background-color: #e94560;
}

/* Connection Styling (jsPlumb) */
.jtk-connector {
    z-index: 10;
}

.jtk-connector path {
    stroke: #4a9eff !important;
    stroke-width: 2px;
}

.jtk-endpoint {
    z-index: 11;
}

.jtk-endpoint circle {
    fill: #4a9eff;
}

.connection-label {
    background-color: #16213e;
    color: #4a9eff;
    padding: 2px 6px;
    border-radius: 3px;
    font-size: 11px;
    border: 1px solid #0f3460;
}

/* Scrollbar Styling */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: #1a1a2e;
}

::-webkit-scrollbar-thumb {
    background: #0f3460;
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: #4a9eff;
}

/* Mobile Sidebar Toggle */
#mobile-menu-toggle {
    display: none;
    position: fixed;
    bottom: 20px;
    left: 20px;
    width: 50px;
    height: 50px;
    border-radius: 50%;
    background-color: #e94560;
    color: #fff;
    border: none;
    font-size: 20px;
    cursor: pointer;
    z-index: 100;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
}

#mobile-menu-toggle:hover {
    background-color: #ff6b6b;
}

/* Touch Action for Canvas */
#canvas-container {
    touch-action: none;
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    user-select: none;
}

.block-card {
    touch-action: none;
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    user-select: none;
}

/* Mobile Responsive Styles */
@media (max-width: 768px) {
    /* Header adjustments */
    #header {
        padding: 0 10px;
        height: 45px;
    }
    
    #header h1 {
        font-size: 14px;
    }
    
    .story-title {
        font-size: 12px;
        padding-left: 10px;
        max-width: 120px;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }
    
    .header-actions button {
        padding: 5px 8px;
        font-size: 11px;
    }
    
    /* Homepage mobile */
    #homepage {
        padding: 20px;
    }
    
    .homepage-header h1 {
        font-size: 24px;
    }
    
    .homepage-actions {
        flex-direction: column;
        gap: 10px;
    }
    
    .btn-large {
        padding: 12px 20px;
        font-size: 14px;
    }
    
    .stories-grid {
        grid-template-columns: 1fr;
    }
    
    /* Main container - stack vertically */
    #main-container {
        flex-direction: column;
        position: relative;
    }
    
    /* Sidebar as overlay */
    #sidebar {
        position: fixed;
        top: 45px;
        left: 0;
        width: 280px;
        height: calc(100vh - 45px);
        z-index: 50;
        transform: translateX(-100%);
        transition: transform 0.3s ease;
        background-color: #16213e;
    }
    
    #sidebar.mobile-open {
        transform: translateX(0);
    }
    
    /* Sidebar overlay backdrop */
    #sidebar-backdrop {
        display: none;
        position: fixed;
        top: 45px;
        left: 0;
        right: 0;
        bottom: 0;
        background-color: rgba(0, 0, 0, 0.5);
        z-index: 40;
    }
    
    #sidebar-backdrop.visible {
        display: block;
    }
    
    /* Mobile menu toggle button */
    #mobile-menu-toggle {
        display: flex;
        align-items: center;
        justify-content: center;
    }
    
    /* Canvas takes full width */
    #canvas-container {
        flex: 1;
        width: 100%;
    }
    
    /* Editor panel as overlay from right */
    #editor-panel {
        position: fixed;
        top: 45px;
        right: 0;
        width: 100%;
        max-width: 320px;
        height: calc(100vh - 45px);
        z-index: 50;
        transform: translateX(100%);
        transition: transform 0.3s ease;
    }
    
    #editor-panel.mobile-open {
        transform: translateX(0);
    }
    
/* Touch-friendly adjustments */
    #sidebar button,
    .editor-actions button,
    .modal-actions button {
        min-height: 44px;
    }
    
    /* Mobile close button for editor */
    .mobile-close-btn {
        display: flex !important;
        align-items: center;
        justify-content: center;
        width: 36px;
        height: 36px;
        background-color: #e94560;
        border: none;
        border-radius: 4px;
        color: #fff;
        font-size: 18px;
        cursor: pointer;
    }
    
    .mobile-close-btn:hover {
        background-color: #ff6b6b;
    }
    
    #sidebar li {
        min-height: 44px;
        padding: 12px 8px;
    }
    
    .item-actions button {
        padding: 8px;
        font-size: 14px;
    }
    
    /* Block cards adjustments */
    .block-card {
        width: 260px;
    }
    
    .block-header {
        padding: 12px;
    }
    
    .block-actions button {
        padding: 8px;
    }
    
    /* Modal adjustments */
    #modal-container {
        min-width: auto;
        width: 90%;
        max-width: 400px;
        padding: 20px;
    }
    
    /* Toast notifications */
    #toast-container {
        left: 10px;
        right: 10px;
        bottom: 80px;
    }
    
    .toast {
        width: 100%;
    }
}

/* Tablet adjustments (769px - 1024px) */
@media (min-width: 769px) and (max-width: 1024px) {
    #sidebar {
        width: 200px;
    }
    
    #editor-panel {
        width: 280px;
    }
    
    .block-card {
        width: 250px;
    }
}
