/* Colloid Stability - DLVO Theory Visualization Styles */

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

:root {
    --primary-color: #2196F3;
    --secondary-color: #FF9800;
    --success-color: #4CAF50;
    --danger-color: #F44336;
    --warning-color: #FFC107;
    --info-color: #00BCD4;
    --dark-bg: #1a1a2e;
    --light-bg: #f5f5f5;
    --text-color: #333;
    --border-color: #ddd;
    --attraction-color: #FF9800;
    --repulsion-color: #2196F3;
    --total-color: #4CAF50;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: var(--text-color);
    line-height: 1.6;
    min-height: 100vh;
}

.colloid-stability-container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 20px;
    background: white;
    border-radius: 10px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
}

/* Header Styles */
header {
    text-align: center;
    padding: 30px 20px;
    background: linear-gradient(135deg, #2196F3 0%, #1565C0 100%);
    color: white;
    border-radius: 10px 10px 0 0;
    margin-bottom: 30px;
}

header h1 {
    font-size: 2.5em;
    margin-bottom: 10px;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.3);
}

.subtitle {
    font-size: 1.1em;
    opacity: 0.9;
    font-weight: 300;
}

/* Main Content */
main {
    padding: 0 20px 30px;
}

/* Mode Selector */
.mode-selector {
    margin-bottom: 30px;
    text-align: center;
}

.mode-selector h3 {
    color: var(--primary-color);
    margin-bottom: 15px;
    font-size: 1.3em;
}

.mode-options {
    display: flex;
    justify-content: center;
    gap: 15px;
    flex-wrap: wrap;
}

.mode-btn {
    padding: 12px 24px;
    background: white;
    border: 2px solid var(--primary-color);
    color: var(--primary-color);
    border-radius: 25px;
    cursor: pointer;
    font-size: 1em;
    font-weight: 600;
    transition: all 0.3s ease;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
}

.mode-btn:hover {
    background: var(--primary-color);
    color: white;
    transform: translateY(-2px);
    box-shadow: 0 4px 10px rgba(33, 150, 243, 0.3);
}

.mode-btn.active {
    background: var(--primary-color);
    color: white;
    box-shadow: 0 4px 15px rgba(33, 150, 243, 0.4);
}

/* Canvas Wrapper */
.canvas-wrapper {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 20px;
    margin-bottom: 30px;
}

.main-canvas-container {
    position: relative;
    background: var(--dark-bg);
    border-radius: 10px;
    overflow: hidden;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.3);
}

#mainCanvas {
    display: block;
    width: 100%;
    height: 500px;
    cursor: crosshair;
}

.canvas-overlay {
    position: absolute;
    top: 10px;
    right: 10px;
    background: rgba(0, 0, 0, 0.7);
    color: white;
    padding: 10px 15px;
    border-radius: 5px;
    font-size: 0.9em;
}

.scale-info {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

/* Statistics Panel */
.stats-panel {
    background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
    padding: 20px;
    border-radius: 10px;
    box-shadow: 0 3px 10px rgba(0, 0, 0, 0.1);
}

.stats-panel h4 {
    color: var(--primary-color);
    margin-bottom: 15px;
    font-size: 1.2em;
}

.stats-grid {
    display: grid;
    gap: 12px;
    margin-bottom: 20px;
}

.stat-item {
    background: white;
    padding: 10px;
    border-radius: 5px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.05);
}

.stat-label {
    font-weight: 600;
    color: var(--text-color);
    font-size: 0.9em;
}

.stat-value {
    font-size: 1.1em;
    font-weight: bold;
    color: var(--primary-color);
}

.stat-unit {
    font-size: 0.85em;
    color: #666;
    margin-left: 5px;
}

/* Formula Display */
.formula-display {
    background: white;
    padding: 15px;
    border-radius: 8px;
    border-left: 4px solid var(--primary-color);
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.05);
}

.formula-main {
    font-size: 1.3em;
    font-weight: bold;
    color: var(--text-color);
    margin-bottom: 10px;
    text-align: center;
}

.formula-calculation {
    font-size: 0.95em;
    color: #666;
    text-align: center;
    font-family: 'Courier New', monospace;
}

/* Controls Panel */
.controls-panel {
    background: linear-gradient(135deg, #e0eafc 0%, #cfdef3 100%);
    padding: 25px;
    border-radius: 10px;
    margin-bottom: 30px;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
}

.controls-panel h3 {
    color: var(--primary-color);
    margin-bottom: 20px;
    font-size: 1.5em;
}

.controls-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 20px;
    margin-bottom: 25px;
}

.control-group {
    background: white;
    padding: 15px;
    border-radius: 8px;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.05);
}

.control-group label {
    display: block;
    font-weight: 600;
    color: var(--text-color);
    margin-bottom: 8px;
    font-size: 0.95em;
}

.control-group input[type="range"] {
    width: 100%;
    height: 6px;
    border-radius: 3px;
    background: linear-gradient(to right, var(--primary-color), #64B5F6);
    outline: none;
    -webkit-appearance: none;
    margin: 10px 0;
}

.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: 0 2px 5px rgba(0, 0, 0, 0.2);
}

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

.control-group select {
    width: 100%;
    padding: 10px;
    border: 2px solid var(--border-color);
    border-radius: 5px;
    font-size: 1em;
    background: white;
    cursor: pointer;
    transition: border-color 0.3s;
}

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

.range-info {
    margin-top: 5px;
}

.info-text {
    font-size: 0.85em;
    color: #666;
    font-style: italic;
}

/* Button Group */
.button-group {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    margin-bottom: 25px;
}

.control-button {
    padding: 12px 20px;
    border: none;
    border-radius: 25px;
    font-size: 1em;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 3px 10px rgba(0, 0, 0, 0.2);
}

.control-button.reset {
    background: var(--danger-color);
    color: white;
}

.control-button.reset:hover {
    background: #d32f2f;
    transform: translateY(-2px);
}

.control-button.toggle {
    background: white;
    color: var(--primary-color);
    border: 2px solid var(--primary-color);
}

.control-button.toggle:hover {
    background: var(--primary-color);
    color: white;
}

.control-button.toggle.active {
    background: var(--primary-color);
    color: white;
}

.control-button.start {
    background: var(--success-color);
    color: white;
}

.control-button.pause {
    background: var(--warning-color);
    color: white;
}

/* Presets Panel */
.presets-panel {
    margin-top: 25px;
}

.presets-panel h4 {
    color: var(--primary-color);
    margin-bottom: 15px;
    font-size: 1.2em;
}

.preset-buttons {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.preset-btn {
    padding: 10px 18px;
    background: white;
    border: 2px solid var(--secondary-color);
    color: var(--secondary-color);
    border-radius: 20px;
    cursor: pointer;
    font-size: 0.9em;
    font-weight: 600;
    transition: all 0.3s ease;
}

.preset-btn:hover {
    background: var(--secondary-color);
    color: white;
    transform: translateY(-2px);
    box-shadow: 0 4px 10px rgba(255, 152, 0, 0.3);
}

/* Stability Panel */
.stability-panel {
    background: linear-gradient(135deg, #fff5e6 0%, #ffe6cc 100%);
    padding: 25px;
    border-radius: 10px;
    margin-bottom: 30px;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
}

.stability-panel h3 {
    color: var(--secondary-color);
    margin-bottom: 20px;
    font-size: 1.5em;
}

.stability-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 15px;
}

.stability-item {
    background: white;
    padding: 15px;
    border-radius: 8px;
    display: flex;
    flex-direction: column;
    gap: 5px;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.05);
}

.stability-label {
    font-weight: 600;
    color: var(--text-color);
    font-size: 0.9em;
}

.stability-value {
    font-size: 1.3em;
    font-weight: bold;
    color: var(--primary-color);
}

/* Applications Panel */
.applications-panel {
    margin-bottom: 30px;
}

.applications-panel h3 {
    color: var(--primary-color);
    margin-bottom: 20px;
    font-size: 1.8em;
    text-align: center;
}

.applications-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 20px;
}

.application-card {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 25px;
    border-radius: 10px;
    text-align: center;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.2);
}

.application-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 10px 25px rgba(102, 126, 234, 0.4);
}

.application-icon {
    font-size: 3em;
    margin-bottom: 15px;
}

.application-card h4 {
    font-size: 1.2em;
    margin-bottom: 10px;
    color: white;
}

.application-card p {
    font-size: 0.95em;
    opacity: 0.9;
    line-height: 1.5;
}

/* Explanation Section */
.explanation {
    background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
    padding: 30px;
    border-radius: 10px;
    margin-top: 30px;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
}

.explanation h2 {
    color: var(--primary-color);
    margin-bottom: 20px;
    font-size: 2em;
}

.explanation h3 {
    color: var(--primary-color);
    margin-top: 30px;
    margin-bottom: 15px;
    font-size: 1.5em;
}

.explanation p {
    line-height: 1.8;
    margin-bottom: 15px;
    text-align: justify;
}

/* Responsive Design */
@media (max-width: 968px) {
    .canvas-wrapper {
        grid-template-columns: 1fr;
    }

    #mainCanvas {
        height: 400px;
    }

    .controls-grid {
        grid-template-columns: 1fr;
    }

    header h1 {
        font-size: 2em;
    }

    .mode-options {
        flex-direction: column;
        align-items: stretch;
    }

    .mode-btn {
        width: 100%;
    }
}

@media (max-width: 600px) {
    .colloid-stability-container {
        padding: 10px;
    }

    header {
        padding: 20px 10px;
    }

    header h1 {
        font-size: 1.5em;
    }

    .subtitle {
        font-size: 0.9em;
    }

    .applications-grid {
        grid-template-columns: 1fr;
    }

    .button-group {
        flex-direction: column;
    }

    .control-button {
        width: 100%;
    }
}

/* Animation for stable state */
@keyframes pulse {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.7;
    }
}

.stable-pulse {
    animation: pulse 2s ease-in-out infinite;
}

/* Loading state */
.loading {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 3px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    border-top-color: white;
    animation: spin 1s ease-in-out infinite;
}

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