/* Reset & Base */
:root {
    --bg-dark: #0f111a;
    --bg-panel: #1a1d2d;
    --primary: #6366f1;
    --primary-hover: #4f46e5;
    --text-main: #e2e8f0;
    --text-muted: #94a3b8;
    --border: #2d3748;
    --success: #10b981;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Inter', sans-serif;
    background-color: var(--bg-dark);
    color: var(--text-main);
    height: 100vh;
    overflow: hidden;
}

/* Layout */
.app-container {
    display: flex;
    height: 100vh;
}

/* Sidebar (Desktop Default) */
.sidebar {
    width: 260px;
    background-color: var(--bg-panel);
    border-right: 1px solid var(--border);
    padding: 24px;
    display: flex;
    flex-direction: column;
    gap: 32px;
    transition: width 0.3s cubic-bezier(0.4, 0, 0.2, 1), padding 0.3s ease;
    flex-shrink: 0;
    overflow: hidden;
    z-index: 10;
}

/* Desktop Collapsed State */
.sidebar.collapsed {
    width: 70px;
    padding: 24px 10px;
    align-items: center;
}

.brand {
    font-size: 1.5rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: space-between;
    color: #fff;
    white-space: nowrap;
    width: 100%;
    position: relative;
}

.brand > i.bxs-cloud-lightning {
    color: var(--primary);
    font-size: 1.8rem;
    min-width: 32px;
}

.sidebar.collapsed .logo-text { display: none; }
.sidebar.collapsed .brand { justify-content: center; width: 100%; }
.sidebar.collapsed .brand > i.bxs-cloud-lightning { display: none; }

.toggle-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 1.6rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color 0.2s;
}

/* Sidebar Collapsed Toggle Button */
.sidebar.collapsed .toggle-btn {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 0;
    width: 40px;
    height: 40px;
    margin: 0 auto;
    background-color: rgba(255, 255, 255, 0.05);
    border-radius: 8px;
    color: var(--text-main);
}

.toggle-btn:hover { color: white; }

.controls {
    display: flex;
    flex-direction: column;
    width: 100%;
    gap: 10px; /* Butonlar arası genel boşluk */
}

.control-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 10px;
    width: 100%;
}

.control-group label {
    font-size: 0.85rem;
    color: var(--text-muted);
    font-weight: 500;
    white-space: nowrap;
}

/* Custom Select */
.custom-select { position: relative; }

select {
    width: 100%;
    padding: 12px;
    background-color: var(--bg-dark);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text-main);
    font-family: inherit;
    appearance: none;
    cursor: pointer;
    outline: none;
    transition: all 0.2s;
}

.sidebar.collapsed .control-group { display: none; }

select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.2);
}

.custom-select i {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    pointer-events: none;
    color: var(--text-muted);
}

/* Buttons Common Style */
.run-btn, .history-btn {
    width: 100%;
    padding: 14px;
    border: none;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: all 0.2s;
    font-size: 1rem;
    white-space: nowrap;
}

.run-btn {
    background-color: var(--primary);
    color: white;
}

.run-btn:hover {
    background-color: var(--primary-hover);
    transform: translateY(-1px);
}

.history-btn {
    background-color: #2d3748;
    color: var(--text-muted);
    border: 1px solid var(--border);
}

.history-btn:hover {
    background-color: #374151;
    color: var(--text-main);
}

/* Desktop Collapsed Button Styles */
.sidebar.collapsed .run-btn,
.sidebar.collapsed .history-btn {
    padding: 12px;
    width: 44px;
    height: 44px;
    margin: 0 auto;
    border-radius: 12px;
}

.sidebar.collapsed .run-btn span,
.sidebar.collapsed .history-btn span { display: none; }
.sidebar.collapsed .run-btn i,
.sidebar.collapsed .history-btn i { font-size: 1.6rem; margin: 0; }


.status-indicator {
    margin-top: auto;
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.85rem;
    color: var(--success);
    white-space: nowrap;
    overflow: hidden;
    width: 100%;
}

.sidebar.collapsed .status-indicator { justify-content: center; }
.sidebar.collapsed .status-text { display: none; }

.dot {
    width: 10px;
    height: 10px;
    background-color: var(--success);
    border-radius: 50%;
    flex-shrink: 0;
}

/* Main Editor Area */
.editor-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    background-color: var(--bg-dark);
    overflow: hidden;
}

.editors-container {
    flex: 1;
    min-height: 100px;
    display: flex;
    overflow: hidden;
    padding: 12px 12px 0 12px;
}

#singleEditorPanel { width: 100%; height: 100%; margin: 0; }

.web-editors-grid {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 12px;
    width: 100%;
    height: 100%;
}

.panel {
    display: flex;
    flex-direction: column;
    background-color: var(--bg-panel);
    border: 1px solid var(--border);
    border-radius: 8px 8px 0 0;
    overflow: hidden;
}

.panel.output-panel {
    border-radius: 0 0 8px 8px;
    margin: 0 12px 12px 12px;
    height: 250px;
}

/* Resizer */
.resizer {
    height: 10px;
    background-color: var(--bg-dark);
    cursor: row-resize;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.resizer::after {
    content: "";
    width: 40px;
    height: 4px;
    background-color: var(--border);
    border-radius: 2px;
}

.resizer:hover::after { background-color: var(--primary); }

/* Panel Header */
.panel-header {
    padding: 8px 16px;
    background-color: rgba(0, 0, 0, 0.2);
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--border);
    height: 40px;
    flex-shrink: 0;
}

.html-header { border-bottom-color: #e44d2620; }
.css-header { border-bottom-color: #264de420; }
.js-header { border-bottom-color: #f7df1e20; }

.html-header i { color: #e44d26; }
.css-header i { color: #264de4; }
.js-header i { color: #f7df1e; }

.panel-title {
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    gap: 8px;
}

.file-info {
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.75rem;
    color: var(--primary);
    background: rgba(99, 102, 241, 0.1);
    padding: 2px 6px;
    border-radius: 4px;
}

.clear-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 4px;
    border-radius: 4px;
}

.clear-btn:hover {
    color: #ef4444; 
    background: rgba(239, 68, 68, 0.1);
}

.editor-wrapper {
    flex: 1;
    overflow: hidden;
    position: relative;
    background-color: #282a36;
}

.CodeMirror {
    height: 100% !important;
    font-family: 'JetBrains Mono', monospace !important;
    font-size: 13px;
    line-height: 1.5;
}

.output-content {
    flex: 1;
    background-color: #0d0f17;
    position: relative;
    display: flex;
    overflow: hidden;
}

.terminal {
    flex: 1;
    padding: 20px;
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.9rem;
    color: #e2e8f0;
    white-space: pre-wrap;
    overflow: auto;
    display: flex;
    flex-direction: column;
}

.terminal-welcome {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    color: var(--text-muted);
    font-style: italic;
    opacity: 0.7;
    gap: 10px;
    height: 100%;
}

.terminal-welcome i { font-size: 2rem; opacity: 0.5; }

#webOnizleme {
    width: 100%;
    height: 100%;
    border: none;
    background: white;
}

.hidden { display: none !important; }

/* --- MODAL (Geçmiş) --- */
.modal {
    display: none;
    position: fixed;
    z-index: 9999;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(5px);
}

.modal-content {
    background-color: var(--bg-panel);
    margin: 5% auto;
    padding: 0;
    border: 1px solid var(--border);
    width: 80%;
    max-width: 900px;
    border-radius: 12px;
    box-shadow: 0 10px 25px rgba(0,0,0,0.5);
    animation: modalSlideIn 0.3s ease;
}

@keyframes modalSlideIn {
    from {transform: translateY(-50px); opacity: 0;}
    to {transform: translateY(0); opacity: 1;}
}

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

.modal-header h2 {
    font-size: 1.2rem;
    color: var(--text-main);
    display: flex;
    align-items: center;
    gap: 10px;
}

.close-modal {
    color: var(--text-muted);
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
    transition: 0.2s;
}

.close-modal:hover { color: #ef4444; }

.modal-body {
    padding: 20px;
    overflow-x: auto;
}

.history-table {
    width: 100%;
    border-collapse: collapse;
    color: var(--text-muted);
    font-size: 0.9rem;
}

.history-table th, .history-table td {
    padding: 12px 15px;
    text-align: left;
    border-bottom: 1px solid var(--border);
}

.history-table th {
    background-color: rgba(0,0,0,0.2);
    color: var(--primary);
    font-weight: 600;
}

.history-table tr:hover {
    background-color: rgba(255,255,255,0.02);
}

.code-snippet {
    font-family: 'JetBrains Mono', monospace;
    background: rgba(0,0,0,0.3);
    padding: 4px 8px;
    border-radius: 4px;
    color: #e2e8f0;
    font-size: 0.8rem;
}

/* History Detail Styles */
.history-table tbody tr.main-row {
    cursor: pointer;
    transition: background-color 0.2s;
}

.history-table tbody tr.main-row:hover {
    background-color: rgba(99, 102, 241, 0.1); 
}

.toggle-icon {
    transition: transform 0.3s ease;
    display: inline-block;
}

.main-row.active .toggle-icon {
    transform: rotate(180deg);
}

.detail-row {
    display: none;
    background-color: rgba(0, 0, 0, 0.3);
}

.detail-row.show {
    display: table-row;
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.detail-content {
    padding: 15px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.full-code-block {
    background-color: #1a1b26;
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 12px;
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.85rem;
    color: #a9b1d6;
    white-space: pre-wrap;
    max-height: 300px;
    overflow-y: auto;
    position: relative;
}

.copy-btn-wrapper {
    display: flex;
    justify-content: flex-end;
}

.copy-code-btn {
    background-color: var(--primary);
    color: white;
    border: none;
    padding: 6px 12px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.8rem;
    display: flex;
    align-items: center;
    gap: 5px;
    transition: all 0.2s;
}

.copy-code-btn:hover { background-color: var(--primary-hover); }
.copy-code-btn.copied { background-color: var(--success); }


@media (max-width: 768px) {
    .app-container {
        flex-direction: column;
    }

    .sidebar, 
    .sidebar.collapsed {
        width: 100% !important;
        height: auto;
        flex-direction: row;
        align-items: center;
        justify-content: space-between;
        padding: 12px 16px;
        border-right: none;
        border-bottom: 1px solid var(--border);
        gap: 15px;
    }

    #toggleSidebar, .toggle-btn {
        display: none !important;
    }

    .brand {
        width: auto;
        margin-bottom: 0;
        gap: 8px;
        justify-content: flex-start;
    }

    .brand > i.bxs-cloud-lightning {
        display: block !important;
        font-size: 1.5rem;
        min-width: auto;
    }

    .logo-text {
        display: block !important;
        font-size: 1.1rem;
    }

    .controls {
        display: flex !important;
        flex-direction: row;
        width: auto;
        margin: 0;
        gap: 8px;
        align-items: center;
        margin-left: auto;
    }

    .control-group {
        display: flex !important;
        width: auto;
        margin-bottom: 0;
        min-width: 90px;
    }

    .control-group label {
        display: none; 
    }

    select {
        padding: 8px 25px 8px 10px;
        font-size: 0.85rem;
        height: 36px;
    }
    
    .custom-select i {
        right: 8px;
    }

    .run-btn, .history-btn {
        width: 36px !important;
        height: 36px !important;
        padding: 0 !important;
        margin: 0;
        border-radius: 8px;
        display: flex;
        justify-content: center;
        align-items: center;
    }

    .btn-text {
        display: none !important;
    }
    
    .run-btn i, .history-btn i {
        font-size: 1.4rem;
        margin: 0;
        display: block;
    }

    .status-indicator {
        display: none !important;
    }

    .web-editors-grid {
        grid-template-columns: 1fr;
        grid-template-rows: 1fr 1fr 1fr;
    }
}