/* ===========================
   Digital Image Processing Tool
   Stylesheet untuk Aplikasi Penelitian
   
   © 2025 Syah. All rights reserved.
   =========================== */

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

:root {
    --primary-color: #2563eb;
    --primary-dark: #1e40af;
    --secondary-color: #64748b;
    --success-color: #10b981;
    --danger-color: #ef4444;
    --bg-light: #f8fafc;
    --bg-white: #ffffff;
    --text-dark: #1e293b;
    --text-light: #64748b;
    --border-color: #e2e8f0;
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
    --radius: 8px;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: var(--bg-light);
    color: var(--text-dark);
    line-height: 1.6;
    overflow-x: hidden;
}

/* Header */
.header {
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-dark) 100%);
    color: white;
    padding: 2rem 2rem 1.5rem;
    box-shadow: var(--shadow-md);
}

.header-content {
    max-width: 1400px;
    margin: 0 auto;
}

.header h1 {
    font-size: 2rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
}

.subtitle {
    font-size: 0.95rem;
    opacity: 0.9;
    font-weight: 300;
}

/* Main Container */
.container {
    display: flex;
    max-width: 1600px;
    margin: 0 auto;
    min-height: calc(100vh - 150px);
    gap: 1.5rem;
    padding: 1.5rem;
}

/* Sidebar */
.sidebar {
    width: 320px;
    background: var(--bg-white);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    padding: 1.5rem;
    height: fit-content;
    position: sticky;
    top: 1.5rem;
    overflow-y: auto;
    max-height: calc(100vh - 3rem);
}

.sidebar-section {
    margin-bottom: 2rem;
    padding-bottom: 1.5rem;
    border-bottom: 1px solid var(--border-color);
}

.sidebar-section:last-child {
    border-bottom: none;
    margin-bottom: 0;
}

.sidebar h2 {
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: 1rem;
    color: var(--text-dark);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.sidebar h3 {
    font-size: 0.9rem;
    font-weight: 600;
    margin-bottom: 0.75rem;
    color: var(--text-dark);
}

/* Upload Area */
.upload-area {
    border: 2px dashed var(--border-color);
    border-radius: var(--radius);
    padding: 2rem 1rem;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s ease;
    background: var(--bg-light);
}

.upload-area:hover {
    border-color: var(--primary-color);
    background: #eff6ff;
}

.upload-area.dragover {
    border-color: var(--primary-color);
    background: #dbeafe;
    transform: scale(1.02);
}

.upload-area svg {
    color: var(--primary-color);
    margin-bottom: 0.5rem;
}

.upload-area p {
    font-size: 0.85rem;
    color: var(--text-light);
}

/* Image Info */
.image-info {
    background: var(--bg-light);
    padding: 1rem;
    border-radius: var(--radius);
    margin-top: 1rem;
}

.image-info p {
    font-size: 0.85rem;
    margin-bottom: 0.4rem;
    color: var(--text-dark);
}

.image-info strong {
    color: var(--text-dark);
    font-weight: 600;
}

/* Control Groups */
.control-group {
    margin-bottom: 1.25rem;
}

.control-group label {
    display: block;
    font-size: 0.85rem;
    font-weight: 500;
    margin-bottom: 0.5rem;
    color: var(--text-dark);
}

.control-group input[type="checkbox"] {
    margin-right: 0.5rem;
    cursor: pointer;
}

.control-group input[type="range"] {
    width: 100%;
    height: 6px;
    border-radius: 3px;
    background: var(--border-color);
    outline: none;
    -webkit-appearance: none;
}

.control-group input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: var(--primary-color);
    cursor: pointer;
    box-shadow: var(--shadow-sm);
}

.control-group input[type="range"]::-moz-range-thumb {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: var(--primary-color);
    cursor: pointer;
    border: none;
    box-shadow: var(--shadow-sm);
}

.control-group select {
    width: 100%;
    padding: 0.6rem;
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    font-size: 0.85rem;
    background: white;
    cursor: pointer;
    transition: border-color 0.2s;
}

.control-group select:focus {
    outline: none;
    border-color: var(--primary-color);
}

/* Buttons */
.btn {
    width: 100%;
    padding: 0.75rem 1rem;
    border: none;
    border-radius: var(--radius);
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    margin-top: 0.5rem;
}

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

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

.btn-primary:hover:not(:disabled) {
    background: var(--primary-dark);
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

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

.btn-secondary:hover:not(:disabled) {
    background: #475569;
    transform: translateY(-1px);
}

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

.btn-success:hover:not(:disabled) {
    background: #059669;
    transform: translateY(-1px);
}

/* Workspace */
.workspace {
    flex: 1;
    background: var(--bg-white);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    padding: 1.5rem;
}

.workspace-header {
    margin-bottom: 1.5rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--border-color);
}

.view-toggle {
    display: flex;
    gap: 0.5rem;
}

.toggle-btn {
    padding: 0.5rem 1rem;
    border: 1px solid var(--border-color);
    background: white;
    border-radius: var(--radius);
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.2s;
}

.toggle-btn:hover {
    background: var(--bg-light);
}

.toggle-btn.active {
    background: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
}

/* Canvas Container */
.canvas-container {
    display: flex;
    gap: 1.5rem;
    margin-bottom: 2rem;
    justify-content: center;
    flex-wrap: wrap;
}

.canvas-wrapper {
    text-align: center;
    flex: 1;
    min-width: 300px;
}

.canvas-wrapper h3 {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 0.75rem;
    color: var(--text-dark);
}

.canvas-wrapper canvas {
    max-width: 100%;
    height: auto;
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    background: #fafafa;
}

/* Single view modes */
.canvas-container.view-before #afterWrapper,
.canvas-container.view-after #beforeWrapper {
    display: none;
}

.canvas-container.view-before .canvas-wrapper,
.canvas-container.view-after .canvas-wrapper {
    max-width: 700px;
    margin: 0 auto;
}

/* Overlay mode */
.canvas-container.view-overlay {
    position: relative;
    justify-content: center;
}

.canvas-container.view-overlay #beforeWrapper {
    position: relative;
}

.canvas-container.view-overlay #afterWrapper {
    position: absolute;
    top: 0;
    left: 50%;
    transform: translateX(-50%);
}

.canvas-container.view-overlay #afterWrapper canvas {
    opacity: 0.7;
}

/* Histogram Container */
.histogram-container {
    display: flex;
    gap: 1.5rem;
    margin-bottom: 2rem;
    flex-wrap: wrap;
}

.histogram-box {
    flex: 1;
    min-width: 300px;
    text-align: center;
}

.histogram-box h3 {
    font-size: 0.95rem;
    font-weight: 600;
    margin-bottom: 0.75rem;
    color: var(--text-dark);
}

.histogram-box canvas {
    width: 100%;
    height: 150px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    background: white;
}

/* Process Log */
.process-log {
    background: var(--bg-light);
    padding: 1.5rem;
    border-radius: var(--radius);
    margin-top: 1.5rem;
}

.process-log h3 {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 1rem;
    color: var(--text-dark);
}

#logContent {
    font-family: 'Courier New', monospace;
    font-size: 0.8rem;
    color: var(--text-light);
    max-height: 200px;
    overflow-y: auto;
    line-height: 1.8;
}

.log-entry {
    padding: 0.3rem 0;
    border-bottom: 1px solid var(--border-color);
}

.log-entry:last-child {
    border-bottom: none;
}

.log-entry .timestamp {
    color: var(--primary-color);
    font-weight: 600;
}

/* Loading Overlay */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 9999;
    flex-direction: column;
}

.loading-overlay.active {
    display: flex;
}

.spinner {
    width: 50px;
    height: 50px;
    border: 4px solid rgba(255, 255, 255, 0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.loading-overlay p {
    color: white;
    margin-top: 1rem;
    font-size: 1rem;
}

/* Responsive Design */
@media (max-width: 1024px) {
    .container {
        flex-direction: column;
    }
    
    .sidebar {
        width: 100%;
        position: static;
        max-height: none;
    }
    
    .canvas-container {
        flex-direction: column;
    }
    
    .canvas-wrapper {
        min-width: 100%;
    }
}

@media (max-width: 768px) {
    .header h1 {
        font-size: 1.5rem;
    }
    
    .subtitle {
        font-size: 0.85rem;
    }
    
    .container {
        padding: 1rem;
    }
    
    .sidebar,
    .workspace {
        padding: 1rem;
    }
    
    .view-toggle {
        flex-wrap: wrap;
    }
    
    .histogram-container {
        flex-direction: column;
    }
}

/* Scrollbar Styling */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: var(--bg-light);
}

::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--secondary-color);
}

/* Footer */
.footer {
    background: var(--bg-white);
    border-top: 1px solid var(--border-color);
    padding: 2rem;
    text-align: center;
    margin-top: 2rem;
}

.footer-content {
    max-width: 1400px;
    margin: 0 auto;
}

.footer p {
    margin: 0.3rem 0;
    color: var(--text-dark);
    font-size: 0.9rem;
}

.footer strong {
    color: var(--primary-color);
    font-weight: 600;
}

.footer-subtitle {
    color: var(--text-light);
    font-size: 0.85rem;
}

