/* ===========================
   Modulaire Rekenmachine Styles
   =========================== */

/* Header Styles */
.app-header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-bottom: 1px solid rgba(0,0,0,0.1);
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    position: sticky;
    top: 0;
    z-index: 100;
    width: 100%;
}

.header-content {
    max-width: 100%;
    padding: 1rem 2rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 2rem;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 1.5rem;
    flex: 1;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 1rem;
    flex-shrink: 0;
}

.user-menu .user-name {
    color: rgba(255, 255, 255, 0.95);
    font-weight: 600;
}

.back-link {
    color: rgba(255,255,255,0.9);
    text-decoration: none;
    font-size: 0.875rem;
    font-weight: 500;
    transition: color 0.2s;
}

.back-link:hover {
    color: white;
}

.app-title {
    color: white;
    font-size: 1.5rem;
    font-weight: 700;
    margin: 0;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.current-file-name {
    color: rgba(255,255,255,0.8);
    font-size: 0.875rem;
    font-weight: 500;
    background: rgba(255,255,255,0.1);
    padding: 0.25rem 0.75rem;
    border-radius: 4px;
}

/* Button Styles */
.btn-primary, .btn-success, .btn-drive, .btn-secondary {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    border: none;
    border-radius: 6px;
    font-size: 0.875rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    text-decoration: none;
}

.btn-primary {
    background: rgba(255,255,255,0.2);
    color: white;
    border: 1px solid rgba(255,255,255,0.3);
}

.btn-primary:hover {
    background: rgba(255,255,255,0.3);
    border-color: rgba(255,255,255,0.5);
}

.btn-success {
    background: #28a745;
    color: white;
}

.btn-success:hover {
    background: #218838;
}

.btn-drive {
    background: #4285f4;
    color: white;
}

.btn-drive:hover {
    background: #3367d6;
}

.btn-secondary {
    background: #dc3545;
    color: white;
}

.btn-secondary:hover {
    background: #c82333;
}

.btn-secondary:active {
    background: #bd2130;
}

/* Notebook Container */
.notebook-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
}

.cells-container {
    flex: 1;
    padding: 1rem;
    overflow-y: auto;
    background: #fafafa;
    min-width: 0;
}

/* Cell Styles */
.cell {
    background: white;
    border: 1px solid #e1e5e9;
    border-radius: 8px;
    margin-bottom: 1rem;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
    transition: all 0.2s ease;
}

.cell:hover {
    border-color: #667eea;
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.15);
}

.cell.executing {
    border-color: #f39c12;
    background: #fff8e1;
}

.cell.error {
    border-color: #e74c3c;
    background: #fdf2f2;
}

/* Cell Toolbar */
.cell-toolbar {
    display: flex;
    align-items: center;
    padding: 0.5rem 1rem;
    background: #f8f9fa;
    border-bottom: 1px solid #e1e5e9;
    border-radius: 8px 8px 0 0;
    gap: 0.5rem;
}

.cell-btn {
    background: none;
    border: none;
    padding: 0.25rem;
    border-radius: 4px;
    color: #6c757d;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.cell-btn:hover {
    background: #e9ecef;
    color: #495057;
}

.cell-btn:active {
    background: #dee2e6;
}

.drag-handle {
    cursor: grab;
}

.drag-handle:active {
    cursor: grabbing;
}

.cell-type-selector {
    background: white;
    border: 1px solid #ced4da;
    border-radius: 4px;
    padding: 0.25rem 0.5rem;
    font-size: 0.875rem;
    color: #495057;
}

.cell-number {
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.875rem;
    color: #6c757d;
    min-width: 3rem;
    text-align: center;
}

.cell-actions {
    margin-left: auto;
    display: flex;
    gap: 0.25rem;
}

/* Cell Input */
.cell-input {
    padding: 1rem;
}

.cell-code {
    width: 100%;
    border: none;
    outline: none;
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.875rem;
    line-height: 1.5;
    resize: vertical;
    min-height: 1.5rem;
    background: transparent;
    color: #212529;
}

.cell-code:focus {
    outline: none;
}

.cell-code::placeholder {
    color: #adb5bd;
}

/* Cell Output */
.cell-output {
    padding: 1rem;
    border-top: 1px solid #e1e5e9;
    background: #f8f9fa;
    width: 100%;
    max-width: 100%;
    overflow-x: auto;
    overflow-y: auto;
    max-height: 320px;
    box-sizing: border-box;
}

.cell-output.markdown-cell-output {
    max-height: none !important;
    overflow-y: visible !important;
}

.output-content {
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.875rem;
    line-height: 1.5;
    color: #212529;
    white-space: pre-wrap;
    word-break: break-word;
    overflow-wrap: anywhere;
    display: block;
    width: 100%;
    max-width: 100%;
    overflow-x: auto;
    overflow-y: auto;
}

.cell-output.markdown-cell-output .output-content,
.output-content.markdown-output {
    overflow-y: visible !important;
    max-height: none !important;
}

.output-content.error {
    color: #dc3545;
}

.output-content.success {
    color: #198754;
}

/* Variables Panel */
.variables-panel {
    width: 300px;
    background: white;
    border-left: 1px solid #e1e5e9;
    padding: 1rem;
    overflow-y: auto;
}

.variables-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid #e1e5e9;
}

.variables-title {
    font-size: 1rem;
    font-weight: 600;
    color: #495057;
}

.variables-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.variable-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.5rem;
    background: #f8f9fa;
    border-radius: 4px;
    border: 1px solid #e9ecef;
}

.variable-name {
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.875rem;
    font-weight: 600;
    color: #495057;
}

.variable-value {
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.875rem;
    color: #6c757d;
}

/* Tips Panel */
.tips-panel {
    width: 300px;
    background: white;
    border-left: 1px solid #e1e5e9;
    padding: 1rem;
    overflow-y: auto;
}

.tips-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid #e1e5e9;
}

.tips-title {
    font-size: 1rem;
    font-weight: 600;
    color: #495057;
}

.tips-content {
    font-size: 0.875rem;
    line-height: 1.5;
    color: #6c757d;
}

.tip-item {
    margin-bottom: 1rem;
    padding: 0.75rem;
    background: #f8f9fa;
    border-radius: 6px;
    border-left: 3px solid #667eea;
}

.tip-title {
    font-weight: 600;
    color: #495057;
    margin-bottom: 0.25rem;
}

.tip-description {
    color: #6c757d;
}

/* Main Layout */
.calculator-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
}

.calculator-container {
    flex: 1;
    display: flex;
    min-height: 0;
}

.info-panel {
    width: 300px;
    background: white;
    border-right: 1px solid #e1e5e9;
    padding: 1rem;
    overflow-y: auto;
}

.info-panel h3 {
    font-size: 1rem;
    font-weight: 600;
    color: #495057;
    margin-bottom: 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid #e1e5e9;
}

.info-panel ul {
    list-style: none;
    padding: 0;
    margin: 0;
}

.info-panel li {
    margin-bottom: 0.75rem;
    padding: 0.5rem;
    background: #f8f9fa;
    border-radius: 4px;
    font-size: 0.875rem;
    line-height: 1.4;
}

.info-panel code {
    background: #e9ecef;
    padding: 0.125rem 0.25rem;
    border-radius: 3px;
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.8em;
    color: #495057;
}

.empty-message {
    color: #6c757d;
    font-style: italic;
    text-align: center;
    padding: 1rem;
}

/* Modulus Settings Bar */
.modulus-settings-bar {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-bottom: 1px solid rgba(0,0,0,0.1);
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    position: sticky;
    top: 64px;
    z-index: 90;
}

.settings-content {
    max-width: 100%;
    padding: 1rem 2rem;
    display: flex;
    align-items: center;
    gap: 2rem;
    flex-wrap: wrap;
}

.setting-group {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.setting-group label {
    font-size: 0.875rem;
    font-weight: 600;
    color: white;
    white-space: nowrap;
}

.modulus-input {
    width: 100px;
    padding: 0.5rem 0.75rem;
    border: 2px solid rgba(255,255,255,0.3);
    border-radius: var(--radius-md);
    font-size: 1rem;
    font-weight: 600;
    text-align: center;
    background: rgba(255,255,255,0.9);
    color: #667eea;
    transition: all 0.2s;
}

.modulus-input:focus {
    outline: none;
    border-color: white;
    background: white;
    box-shadow: 0 0 0 3px rgba(255,255,255,0.3);
}

.representation-select {
    padding: 0.5rem 0.75rem;
    border: 2px solid rgba(255,255,255,0.3);
    border-radius: var(--radius-md);
    font-size: 0.875rem;
    font-weight: 500;
    background: rgba(255,255,255,0.9);
    color: #667eea;
    cursor: pointer;
    transition: all 0.2s;
}

.representation-select:focus {
    outline: none;
    border-color: white;
    background: white;
}

.polynomial-var-input {
    width: 80px;
    padding: 0.5rem;
    border: 2px solid rgba(255,255,255,0.3);
    border-radius: var(--radius-md);
    font-size: 0.875rem;
    font-weight: 600;
    font-family: 'JetBrains Mono', monospace;
    background: rgba(255,255,255,0.9);
    color: #667eea;
    text-align: center;
    transition: all 0.2s;
}

.polynomial-var-input:focus {
    outline: none;
    border-color: white;
    background: white;
    box-shadow: 0 0 0 3px rgba(255,255,255,0.3);
}

.polynomial-var-preview {
    display: inline-block;
    margin-left: 0.5rem;
    padding: 0.375rem 0.75rem;
    background: rgba(255,255,255,0.9);
    border-radius: var(--radius-md);
    font-size: 1.25rem;
    color: #667eea;
    min-width: 30px;
    text-align: center;
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.875rem;
    font-weight: 500;
    color: white;
    cursor: pointer;
    user-select: none;
}

.checkbox-label input[type="checkbox"] {
    width: 18px;
    height: 18px;
    cursor: pointer;
    accent-color: white;
}

.modulus-title-display {
    margin-left: auto;
    font-size: 1.25rem;
    font-weight: 600;
    color: white;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.modulus-title-display span {
    display: inline-block;
}

.table-buttons-group {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

/* Table Buttons (Small, in settings bar) */
.btn-table-small {
    background: rgba(255, 255, 255, 0.2);
    color: white;
    border: 1px solid rgba(255, 255, 255, 0.3);
    padding: 0.375rem 0.875rem;
    border-radius: var(--radius-md);
    font-weight: 500;
    cursor: pointer;
    font-size: 0.8125rem;
    white-space: nowrap;
    transition: all 0.2s;
}

.btn-table-small:hover {
    background: rgba(255, 255, 255, 0.3);
    border-color: white;
    transform: translateY(-1px);
}

.btn-table-small:active {
    transform: translateY(0);
}

/* Modular Number Display */
.mod-number {
    display: inline-block;
    padding: 0.125rem 0.5rem;
    background: rgba(102, 126, 234, 0.1);
    border-radius: var(--radius-sm);
    font-weight: 600;
    color: #667eea;
}

/* Override calculator styles for modular context */
.modular-calculator .output-content {
    font-family: 'JetBrains Mono', monospace;
}

/* Context Menu */
.cell-context-menu {
    position: fixed;
    background: white;
    border: 1px solid #e1e5e9;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    z-index: 1000;
    min-width: 200px;
    padding: 0.5rem 0;
    display: none;
}

.context-menu-item {
    width: 100%;
    padding: 0.75rem 1rem;
    border: none;
    background: none;
    text-align: left;
    font-size: 0.875rem;
    color: #495057;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    transition: background-color 0.2s;
}

.context-menu-item:hover {
    background: #f8f9fa;
}

.context-menu-item:active {
    background: #e9ecef;
}

.context-menu-divider {
    margin: 0.5rem 0;
    border: none;
    border-top: 1px solid #e1e5e9;
}

/* Responsive */
@media (max-width: 768px) {
    .settings-content {
        padding: 1rem;
        gap: 1rem;
    }
    
    .modulus-title-display {
        margin-left: 0;
        width: 100%;
        justify-content: center;
        margin-top: 0.5rem;
    }
    
    .calculator-container {
        flex-direction: column;
    }
    
    .info-panel,
    .variables-panel {
        width: 100%;
        border-right: none;
        border-bottom: 1px solid #e1e5e9;
    }
    
    .variables-panel {
        border-left: none;
        border-top: 1px solid #e1e5e9;
    }
    
    .cell-toolbar {
        flex-wrap: wrap;
        gap: 0.25rem;
    }
    
    .cell-actions {
        margin-left: 0;
        width: 100%;
        justify-content: flex-end;
    }
}

/* Markdown Cell Styles */
.cell.markdown-cell.executed .cell-toolbar {
    display: none !important;
}

.cell.markdown-cell.executed {
    border: none;
    box-shadow: none;
    background: transparent;
}

.cell.markdown-cell.executed .cell-output {
    border: none;
    background: transparent;
    padding: 0;
    position: relative;
}

.markdown-output {
    position: relative;
}

.markdown-cell-buttons {
    display: flex;
    gap: 0.5rem;
    margin-top: 0.5rem;
}

.markdown-output .markdown-edit-btn,
.markdown-output .markdown-delete-btn {
    background: rgba(255, 255, 255, 0.9);
    border: 1px solid #dee2e6;
    border-radius: 4px;
    padding: 0.25rem 0.5rem;
    cursor: pointer;
    opacity: 0;
    transition: opacity 0.2s;
    font-size: 0.75rem;
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

.markdown-output:hover .markdown-edit-btn,
.markdown-output:hover .markdown-delete-btn {
    opacity: 1;
}

.markdown-edit-btn:hover {
    background: #f8f9fa;
}

.markdown-delete-btn:hover {
    background: #fee2e2;
    border-color: #fca5a5;
    color: #dc2626;
}

.markdown-edit-btn svg,
.markdown-delete-btn svg {
    width: 14px;
    height: 14px;
}

@media (max-width: 480px) {
    .settings-content {
        flex-direction: column;
        align-items: stretch;
    }
    
    .setting-group {
        justify-content: space-between;
    }
    
    .modulus-input {
        width: 80px;
    }
    
    .cell-input,
    .cell-output {
        padding: 0.75rem;
    }
    
    .info-panel,
    .variables-panel {
        padding: 0.75rem;
    }
}

