/* Base Styles and CSS Variables */
:root {
    --primary-color: #4B5320;        /* Army Green */
    --secondary-color: #BDB76B;      /* Dark Khaki */
    --background-color: #F5F5DC;     /* Beige */
    --text-color: #333333;           /* Dark Gray */
    --accent-color: #8B4513;         /* Saddle Brown */
    --success-color: #4CAF50;        /* Green */
    --error-color: #F44336;          /* Red */
    --warning-color: #FFC107;        /* Amber */
    --info-color: #2196F3;           /* Blue */
    --font-main: "Fira Code", "Consolas", monospace;
    --border-width: 2px;
    --shadow-standard: 0 2px 5px rgba(0, 0, 0, 0.2);
    --transition-standard: all 0.3s ease;
}

/* Global Reset */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

/* Body Styling */
body {
    font-family: var(--font-main);
    background-color: var(--background-color);
    color: var(--text-color);
    line-height: 1.6;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    overflow-x: hidden;
}

/* Header Styling */
header {
    background-color: var(--primary-color);
    color: white;
    padding: 20px;
    text-align: center;
    box-shadow: var(--shadow-standard);
}

header h1 {
    font-size: 2.5rem;
    margin-bottom: 10px;
    text-transform: uppercase;
    letter-spacing: 1px;
}

header p {
    font-size: 1.1rem;
    opacity: 0.9;
}

/* Navigation and Main Layout */
nav#main-nav {
    background-color: var(--secondary-color);
    padding: 15px;
    display: flex;
    flex-wrap: wrap;
    justify-content: space-around;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: var(--shadow-standard);
}

.nav-section {
    padding: 8px;
    margin: 5px;
    min-width: 200px;
}

.nav-section h3 {
    color: var(--text-color);
    margin-bottom: 10px;
    font-size: 1.1rem;
    border-bottom: 1px solid var(--text-color);
    padding-bottom: 5px;
}

/* Buttons */
button {
    background-color: var(--primary-color);
    color: white;
    border: var(--border-width) solid var(--secondary-color);
    padding: 8px 15px;
    margin: 5px;
    cursor: pointer;
    font-family: var(--font-main);
    font-size: 0.9rem;
    transition: var(--transition-standard);
}

button:hover {
    background-color: var(--secondary-color);
    color: var(--text-color);
    transform: translateY(-2px);
}

button:active {
    transform: translateY(1px);
}

button:disabled {
    background-color: #cccccc;
    color: #666666;
    cursor: not-allowed;
    transform: none;
    border-color: #999999;
}

/* Main Content Area */
main {
    flex: 1;
    padding: 20px;
    max-width: 1200px;
    margin: 0 auto;
    width: 100%;
}

/* Operation Sections */
.operation-section {
    background-color: white;
    margin-bottom: 30px;
    border: var(--border-width) solid var(--secondary-color);
    box-shadow: var(--shadow-standard);
    display: none; /* Hidden by default, shown when selected */
}

.operation-section.active {
    display: block;
}

.operation-section h2 {
    background-color: var(--secondary-color);
    color: var(--text-color);
    padding: 15px;
    margin: 0;
    font-size: 1.5rem;
}

.operation-container {
    display: flex;
    flex-wrap: wrap;
    padding: 20px;
    gap: 20px;
}

.operation-controls {
    flex: 1;
    min-width: 300px;
}

.operation-result {
    flex: 1;
    min-width: 300px;
}

.operation-controls h3,
.operation-result h3 {
    color: var(--primary-color);
    margin-bottom: 15px;
    padding-bottom: 5px;
    border-bottom: 1px solid var(--secondary-color);
}

/* Form Styling */
.form-group {
    margin-bottom: 15px;
}

.form-group label {
    display: block;
    margin-bottom: 5px;
    color: var(--text-color);
    font-weight: 500;
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 10px;
    border: 1px solid var(--secondary-color);
    font-family: var(--font-main);
    background-color: #fcfcf7;
    color: var(--text-color);
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 5px rgba(75, 83, 32, 0.3);
}

.form-group textarea {
    min-height: 100px;
    resize: vertical;
}

.control-row {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 15px;
}

/* Result Containers */
.result-container {
    background-color: #fcfcf7;
    border: 1px solid var(--secondary-color);
    padding: 15px;
    min-height: 150px;
    max-height: 400px;
    overflow-y: auto;
    overflow-x: hidden;
    white-space: pre-wrap;
    word-break: break-word;
    font-family: var(--font-main);
}

/* Binary and Tree Visualizations */
.binary-display {
    display: flex;
    flex-direction: column;
    gap: 5px;
    font-family: var(--font-main);
    font-size: 0.9rem;
}

.binary-row {
    display: flex;
    align-items: center;
    gap: 5px;
}

.bit {
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--secondary-color);
}

.bit.one {
    background-color: var(--primary-color);
    color: white;
}

.bit.zero {
    background-color: white;
    color: var(--text-color);
}

/* Quadtree Container */
#quadtree-container {
    position: relative;
    width: 100%;
    min-height: 400px;
    border: 2px solid var(--secondary-color);
    background-color: white;
    margin-top: 15px;
}

.quadtree-cell {
    position: absolute;
    border: 1px solid var(--secondary-color);
    background-color: var(--background-color);
    display: flex;
    justify-content: center;
    align-items: center;
    font-family: var(--font-main);
    color: var(--text-color);
    text-align: center;
    cursor: pointer;
    transition: transform 0.2s ease;
}

.quadtree-cell:hover {
    transform: scale(1.05);
    box-shadow: var(--shadow-standard);
}

.cell-content {
    width: 100%;
    height: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: hidden;
}

/* Process Visualization */
.process {
    background-color: var(--background-color);
    border: 1px solid var(--secondary-color);
    padding: 10px;
    margin-bottom: 10px;
    position: relative;
}

.process-name {
    font-weight: bold;
    margin-bottom: 5px;
}

.process-progress {
    background-color: #e0e0e0;
    height: 10px;
    width: 100%;
    overflow: hidden;
}

.process-bar {
    background-color: var(--primary-color);
    height: 100%;
    width: 0%;
    transition: width 0.3s linear;
}

.process-status {
    margin-top: 5px;
    font-size: 0.8rem;
}

.process-close {
    position: absolute;
    top: 5px;
    right: 5px;
    cursor: pointer;
    color: var(--error-color);
    font-size: 1.2rem;
}

/* Database Visualization */
.database-record {
    background-color: var(--background-color);
    border: 1px solid var(--secondary-color);
    padding: 10px;
    margin-bottom: 10px;
}

.record-header {
    display: flex;
    justify-content: space-between;
    margin-bottom: 5px;
}

.record-id {
    font-weight: bold;
}

.record-controls {
    display: flex;
    gap: 5px;
}

.record-control {
    cursor: pointer;
    color: var(--primary-color);
    font-size: 0.8rem;
}

.record-content {
    padding: 5px;
    background-color: white;
}

/* File System Visualization */
#file-tree {
    list-style-type: none;
}

.file-item {
    padding: 5px;
    cursor: pointer;
}

.file-item:hover {
    background-color: var(--secondary-color);
}

.file-icon {
    margin-right: 5px;
}

.file-name {
    font-weight: bold;
}

.directory-item {
    font-weight: bold;
    cursor: pointer;
}

.directory-children {
    padding-left: 20px;
    list-style-type: none;
}

/* Memory Display */
.memory-file {
    margin-bottom: 15px;
}

.memory-file-title {
    font-weight: bold;
    padding-bottom: 5px;
    border-bottom: 1px solid var(--secondary-color);
}

.memory-slot {
    padding: 8px;
    border-bottom: 1px solid #f0f0e0;
}

.memory-slot:hover {
    background-color: #f0f0e0;
}

.memory-slot-title {
    font-weight: bold;
    margin-bottom: 5px;
}

.memory-slot-value {
    padding: 5px;
    background-color: #f8f8f8;
    border-radius: 2px;
    font-size: 0.9em;
}

/* Progress Bar */
.progress-bar {
    background-color: #e0e0e0;
    height: 20px;
    width: 100%;
    margin: 10px 0;
    overflow: hidden;
}

.progress-fill {
    background-color: var(--primary-color);
    height: 100%;
    width: 0%;
    transition: width 0.3s linear;
}

/* Canvas Styling */
#drawing-canvas {
    border: 2px solid var(--secondary-color);
    cursor: crosshair;
    background-color: white;
    width: 100%;
    max-width: 400px;
    height: 300px;
}

/* Transaction History */
#transaction-history {
    margin-top: 10px;
    font-size: 0.9rem;
    max-height: 150px;
    overflow-y: auto;
}

.transaction-item {
    padding: 3px 5px;
    margin: 2px 0;
    background-color: #f0f0e0;
}

/* Modal Styling */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.7);
    overflow: auto;
}

.modal-content {
    background-color: white;
    margin: 5% auto;
    padding: 20px;
    border: 1px solid var(--secondary-color);
    width: 80%;
    max-width: 600px;
    box-shadow: var(--shadow-standard);
    position: relative;
}

.close-btn {
    color: var(--secondary-color);
    position: absolute;
    top: 10px;
    right: 15px;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
}

.close-btn:hover {
    color: var(--primary-color);
}

/* Status Messages */
.status-message {
    padding: 10px;
    margin: 10px 0;
    border-radius: 4px;
}

.status-success {
    background-color: rgba(76, 175, 80, 0.2);
    border: 1px solid var(--success-color);
    color: var(--success-color);
}

.status-error {
    background-color: rgba(244, 67, 54, 0.2);
    border: 1px solid var(--error-color);
    color: var(--error-color);
}

.status-warning {
    background-color: rgba(255, 193, 7, 0.2);
    border: 1px solid var(--warning-color);
    color: var(--warning-color);
}

.status-info {
    background-color: rgba(33, 150, 243, 0.2);
    border: 1px solid var(--info-color);
    color: var(--info-color);
}

/* Compression Stats Display */
#compression-stats {
    margin-top: 10px;
    padding: 10px;
    background-color: #f0f0e0;
    border: 1px solid var(--secondary-color);
}

/* Footer Styling */
footer {
    background-color: var(--primary-color);
    color: white;
    text-align: center;
    padding: 15px;
    margin-top: 30px;
    font-size: 0.9rem;
}

/* Responsive Design */
@media (max-width: 992px) {
    .operation-container {
        flex-direction: column;
    }
    
    .operation-controls, 
    .operation-result {
        width: 100%;
    }
    
    .nav-section {
        width: 100%;
    }
    
    .modal-content {
        width: 95%;
    }
}

@media (max-width: 768px) {
    header h1 {
        font-size: 2rem;
    }
    
    .control-row {
        flex-direction: column;
    }
    
    .control-row button {
        width: 100%;
    }
}

@media (max-width: 480px) {
    body {
        font-size: 14px;
    }
    
    header h1 {
        font-size: 1.8rem;
    }
    
    .operation-section h2 {
        font-size: 1.2rem;
    }
}

/* Animations */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.fade-in {
    animation: fadeIn 0.5s ease forwards;
}

@keyframes pulse {
    0% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.05);
    }
    100% {
        transform: scale(1);
    }
}

.pulse {
    animation: pulse 1s infinite;
}

/* Utility Classes */
.hidden {
    display: none !important;
}

.text-center {
    text-align: center;
}

.text-right {
    text-align: right;
}

.mt-10 {
    margin-top: 10px;
}

.mb-10 {
    margin-bottom: 10px;
}

.mt-20 {
    margin-top: 20px;
}

.mb-20 {
    margin-bottom: 20px;
}

.flex-row {
    display: flex;
}

.justify-between {
    justify-content: space-between;
}

.align-center {
    align-items: center;
}

/* Session persistence styling */
.persistence-controls {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.persistence-controls button {
    width: 100%;
    padding: 8px;
    font-size: 0.9rem;
}

.notification {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 9999;
    background-color: white;
    border: 2px solid var(--secondary-color);
    border-left: 5px solid var(--primary-color);
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
    padding: 15px;
    max-width: 350px;
    font-size: 0.9rem;
    animation: slideIn 0.3s ease-out;
}

.success-notification {
    border-left: 5px solid var(--success-color);
}

.notification-content p {
    margin: 0 0 10px 0;
}

.notification-actions {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
}

.notification-actions button {
    padding: 5px 10px;
    font-size: 0.8rem;
    background-color: var(--primary-color);
    color: white;
    border: none;
    cursor: pointer;
}

.notification-actions button:last-child {
    background-color: var(--secondary-color);
}

.fade-out {
    opacity: 0;
    transition: opacity 0.3s;
}

@keyframes slideIn {
    from {
        transform: translateX(100px);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}