/* Modern CSS Variables - Following the Design Guide */
:root {
    /* Primary Colors */
    --primary-blue: #3b82f6;
    --primary-dark: #1e40af;
    --accent-green: #10b981;
    
    /* Neutral Grays */
    --bg-primary: #f8fafc;
    --bg-secondary: #ffffff;
    --text-primary: #1f2937;
    --text-secondary: #6b7280;
    --border-light: #e5e7eb;
    
    /* Status Colors */
    --success: #10b981;
    --warning: #f59e0b;
    --error: #ef4444;
    --info: #3b82f6;
    
    /* Dark Mode */
    --dark-bg: #111827;
    --dark-surface: #1f2937;
    --dark-text: #f9fafb;
    
    /* Shadows and Effects */
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px 0 rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    
    /* Border Radius */
    --border-radius: 8px;
    --border-radius-lg: 12px;
}

[data-theme="dark"] {
    --bg-primary: var(--dark-bg);
    --bg-secondary: var(--dark-surface);
    --text-primary: var(--dark-text);
    --text-secondary: #9ca3af;
    --border-light: #374151;
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    transition: all 0.3s ease;
}

/* Header */
.header {
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border-light);
    box-shadow: var(--shadow-sm);
    position: sticky;
    top: 0;
    z-index: 100;
}

.header-content {
    max-width: 1400px;
    margin: 0 auto;
    padding: 0.25rem 0.75rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.header-logo-container {
    display: block;
    height: 115px; /* Set a fixed height for the container */
}

.header-logo-container img {
    height: 100%; /* Image will fill the container's height */
    width: auto;  /* Width will scale automatically */
}

.system-status {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

.status-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.875rem;
    color: var(--text-secondary);
}

.status-indicator {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--success);
}

.status-ready { background: var(--success); }
.status-warning { background: var(--warning); }
.status-error { background: var(--error); }

.theme-toggle {
    background: var(--bg-primary);
    border: 1px solid var(--border-light);
    padding: 0.5rem;
    border-radius: var(--border-radius);
    cursor: pointer;
    transition: all 0.2s;
    color: var(--text-secondary)    
}

.theme-toggle:hover {
    background: var(--primary-blue);
    color: white;
}

/* Main Layout - Optimized for horizontal peptides */
.main-container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 2rem 1.5rem;
    display: grid;
    grid-template-columns: 1fr 1fr;
    grid-template-rows: auto 1fr; /* First row for inputs, second for visualization */
    gap: 2rem;
    min-height: calc(100vh - 120px);
}

/* Card Styling */
.card {
    background: var(--bg-secondary);
    border-radius: var(--border-radius-lg);
    padding: 1.5rem;
    box-shadow: var(--shadow);
    border: 1px solid var(--border-light);
}

.card-title {
    font-size: 1.125rem;
    font-weight: 600;
    margin-bottom: 1rem;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

/* Input Panel */
.input-panel {
    grid-column: 1 / 2;
    grid-row: 1 / 2;
}

/* Properties Panel */
.properties-panel {
    grid-column: 2 / 3;
    grid-row: 1 / 2;
}

.properties-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 12px;
}

.property-item {
    background: var(--background);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 12px;
    transition: all 0.2s ease;
}

.property-item:hover {
    border-color: var(--primary-color);
    background: color-mix(in srgb, var(--primary-color) 5%, var(--background));
}

.property-item.loading {
    opacity: 0.7;
}

.property-item.error {
    border-color: #ff6b6b;
    background: color-mix(in srgb, #ff6b6b 5%, var(--background));
}

.property-item.empty {
    opacity: 0.6;
    border-style: dashed;
}

.property-label {
    font-size: 12px;
    color: var(--text-secondary);
    font-weight: 500;
    display: block;
    margin-bottom: 4px;
}

.property-value {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-primary);
    font-family: 'Courier New', monospace;
}

.properties-status {
    margin-top: 10px;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 11px;
    text-align: center;
}

.properties-status.success {
    background: color-mix(in srgb, green 10%, var(--background));
    color: green;
}

.properties-status.error {
    background: color-mix(in srgb, red 10%, var(--background));
    color: red;
}

.spinner-small {
    width: 16px;
    height: 16px;
    border: 2px solid var(--border);
    border-top: 2px solid var(--primary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Visualization Panel - Full width bottom */
.visualization-panel {
    grid-column: 1 / -1;
    grid-row: 2 / 3; /* Span full width on the second row */
    display: flex;
    min-width: 0; /* THE FIX: Allows the grid item to shrink smaller than its content */
    flex-direction: column;
}

.form-label {
    display: block;
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 0.5rem;
}

.input-with-icon {
    position: relative;
}

.input-icon {
    position: absolute;
    left: 0.75rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-secondary);
}

.form-input {
    width: 100%;
    padding: 0.75rem 0.75rem 0.75rem 2.5rem;
    border: 2px solid var(--border-light);
    border-radius: var(--border-radius);
    background: var(--bg-primary);
    color: var(--text-primary);
    font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
    font-size: 0.875rem;
    transition: all 0.2s;
}

.form-input:focus {
    outline: none;
    border-color: var(--primary-blue);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.form-select {
    padding: 0.75rem;
    border: 2px solid var(--border-light);
    border-radius: var(--border-radius);
    background: var(--bg-primary);
    color: var(--text-primary);
    font-size: 0.875rem;
    width: 100%;
}

.form-hint {
    font-size: 0.75rem;
    color: var(--text-secondary);
    margin-top: 0.25rem;
}

/* Amino Acid Grid */
.amino-acid-grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 0.5rem;
    margin: 1rem 0;
}

.aa-button {
    background: var(--bg-primary);
    border: 2px solid var(--border-light);
    border-radius: var(--border-radius);
    padding: 0.75rem 0.5rem;
    font-size: 0.875rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    color: var(--text-primary);
    position: relative;
}

.aa-button:hover {
    background: var(--primary-blue);
    color: white;
    transform: translateY(-1px);
    box-shadow: var(--shadow);
    border-color: var(--primary-blue);
}

.aa-button:active {
    transform: translateY(0);
}

.aa-button::after {
    content: '';
    position: absolute;
    top: -20%;
    left: -50%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.2), transparent);
    overflow: hidden; /* Keep the animation contained */
    transition: left 0.5s;
}

.aa-button:hover::after {
    left: 100%;
}

/* Controls */
.control-group {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
    margin: 1rem 0;
}

.control-section {
    background: var(--bg-primary);
    padding: 1rem;
    border-radius: var(--border-radius);
    border: 1px solid var(--border-light);
}

.control-label {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 0.5rem;
    display: block;
}

/* pH Slider */
.ph-slider-container {
    margin: 1rem 0;
}

.ph-slider {
    width: 100%;
    height: 6px;
    border-radius: 3px;
    background: linear-gradient(to right, #ef4444, #f59e0b, #10b981, #3b82f6);
    outline: none;
    -webkit-appearance: none;
}

.ph-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: white;
    border: 3px solid var(--primary-blue);
    cursor: pointer;
    box-shadow: var(--shadow);
}

.ph-slider::-moz-range-thumb {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: white;
    border: 3px solid var(--primary-blue);
    cursor: pointer;
    box-shadow: var(--shadow);
}

.ph-value {
    font-weight: 600;
    color: var(--primary-blue);
    font-size: 1.125rem;
    text-align: center;
    margin-top: 0.5rem;
}

/* Buttons */
.btn {
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: var(--border-radius);
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    font-size: 0.875rem;
    text-decoration: none;
}

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

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

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

.btn-secondary:hover:not(:disabled) {
    background: #4b5563;
}

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

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

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

.btn-group {
    display: flex;
    gap: 0.75rem;
    margin-top: 1.5rem;
}

.btn-full {
    width: 100%;
}

/* Visualization Container */


.visualization-container {
    flex: 1;
    background: var(--bg-primary);
    border: 2px dashed var(--border-light);
    border-radius: var(--border-radius-lg);
    min-height: 400px;
    max-height: 600px;
    overflow-y: auto;
    overflow-x: hidden;
    position: relative;
    overflow: auto;
}

.visualization-container svg,
.visualization-container img {
    /* Let SVG display at its natural size */
    width: auto !important;
    height: 100% !important;
    max-width: none !important;
    max-height: 400px !important;
    display: block;
}

.visualization-placeholder {
    text-align: center;
    color: var(--text-secondary);
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
}

.loading-animation {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
}

.placeholder-icon {
    width: 80px;
    height: 80px;
    margin: 0 auto 1rem;
    opacity: 0.3;
}

.loading-animation {
    display: none;
    text-align: center;
}

.spinner {
    width: 40px;
    height: 40px;
    border: 4px solid var(--border-light);
    border-top: 4px solid var(--primary-blue);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 1rem;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.properties-grid {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.property-item {
    background: var(--bg-primary);
    padding: 0.25rem;
    border-radius: var(--border-radius);
    border: 1px solid var(--border-light);
}

.property-label {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    display: block;
    margin-bottom: 0.25rem;
}

.property-value {
    font-size: 1.00rem;
    font-weight: 700;
    color: var(--text-primary);
    transition: all 0.3s;
}

.property-unit {
    font-size: 0.875rem;
    font-weight: 400;
    color: var(--text-secondary);
}

.property-updating {
    color: var(--primary-blue);
    animation: pulse 1.5s infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.7; }
}

/* Export Section */
.export-section {
    margin-top: 1.5rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--border-light);
}

.format-selector {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.5rem;
    margin: 0.75rem 0;
}

.format-btn {
    padding: 0.5rem;
    border: 2px solid var(--border-light);
    background: var(--bg-primary);
    border-radius: var(--border-radius);
    cursor: pointer;
    transition: all 0.2s;
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-primary);
}

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

.format-btn.pro-feature {
    opacity: 0.6;
    position: relative;
}

.format-btn.pro-feature::after {
    content: '★';
    position: absolute;
    top: -4px;
    right: -4px;
    background: var(--warning);
    color: white;
    border-radius: 50%;
    width: 16px;
    height: 16px;
    font-size: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Pro Upsell */
.pro-upsell {
    text-align: center;
    margin-top: 1rem;
    padding: 0.75rem;
    background: rgba(249, 168, 0, 0.1);
    border-radius: var(--border-radius);
    border: 1px solid var(--warning);
}

.pro-upsell-text {
    font-size: 0.75rem;
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
}

/* Toast notifications */
.toast {
    position: fixed;
    top: 20px;
    right: 20px;
    padding: 1rem 1.5rem;
    border-radius: var(--border-radius);
    color: white;
    font-weight: 600;
    z-index: 1000;
    transform: translateX(100%);
    transition: transform 0.3s ease;
    box-shadow: var(--shadow-lg);
}

.toast.success { background: var(--success); }
.toast.error { background: var(--error); }
.toast.info { background: var(--info); }

/* Tooltips - Enhanced for better visibility */
.tooltip {
    position: relative;
    cursor: help;
}

.tooltip::before {
    content: attr(data-tooltip);
    position: absolute;
    bottom: 125%;
    left: 100%;
    transform: translateX(-50%);
    background: var(--text-primary);
    color: var(--bg-secondary);
    padding: 0.75rem 1rem;
    border-radius: var(--border-radius);
    font-size: 0.875rem;
    font-weight: 500;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s, transform 0.3s;
    z-index: 1000;
    box-shadow: var(--shadow-lg);
    border: 1px solid var(--border-light);
    min-width: max-content;
}

.tooltip::after {
    content: '';
    position: absolute;
    bottom: 115%;
    left: 50%;
    transform: translateX(-50%);
    border: 6px solid transparent;
    border-top-color: var(--text-primary);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s;
    z-index: 1000;
}

.tooltip:hover::before,
.tooltip:hover::after {
    opacity: 1;
    transform: translateX(-50%) translateY(-4px);
}

/* Responsive Design */
@media (max-width: 1200px) {
    .main-container {
        grid-template-columns: 1fr;
        grid-template-rows: auto auto 1fr;
    }
    
    .input-panel {
        grid-column: 1;
        grid-row: 1;
    }
    
    .properties-panel {
        grid-column: 1;
        grid-row: 3 / 4;
        max-width: none; /* Allow full width on mobile */
        justify-self: stretch;
    }
    
    .visualization-panel {
        grid-column: 1;
        grid-row: 2 / 3;
    }
}

@media (max-width: 900px) {
    .main-container {
        gap: 1.5rem;
    }
    
    .header-content {
        flex-direction: column;
        gap: 1rem;
    }
    
    .system-status {
        display: none;
    }
    
    .amino-acid-grid {
        grid-template-columns: repeat(4, 1fr);
    }
    
    .control-group {
        grid-template-columns: 1fr;
    }

    .properties-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 600px) {
    .main-container {
        padding: 1rem;
    }
    
    .amino-acid-grid {
        grid-template-columns: repeat(3, 1fr);
    }
    
    .btn-group {
        flex-direction: column;
    }
}

/* Success/Error States */
.success-state {
    border-color: var(--success) !important;
    box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.2);
}

.error-state {
    border-color: var(--error) !important;
    box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.2);
}

/* Modal styles for Pro upgrade */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0,0,0,0.5);
}

.modal-content {
    background-color: var(--bg-secondary);
    margin: 5% auto;
    padding: 2rem;
    border-radius: var(--border-radius-lg);
    width: 90%;
    max-width: 500px;
    box-shadow: var(--shadow-lg);
}

.close {
    color: var(--text-secondary);
    float: right;
    font-size: 1.5rem;
    font-weight: bold;
    cursor: pointer;
}

.close:hover {
    color: var(--text-primary);
}

/* Footer Styles */
.footer {
    padding: 2rem 1.5rem;
    text-align: center;
    border-top: 1px solid var(--border-light);
    margin-top: 2rem;
    color: var(--text-secondary);
    background: var(--bg-primary);
    font-size: 0.875rem;
}

.footer-links {
    justify-content: center;
    gap: 1.5rem;
    margin-top: 0.5rem;
}

.footer-links a {
    color: var(--text-secondary);
    text-decoration: none;
    transition: color 0.2s;
}

.footer-links a:hover {
    color: var(--primary-blue);
    text-decoration: underline;
}

/* Cookie Banner Styles */
#cookie-banner {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--bg-secondary);
    color: var(--text-primary);
    padding: 20px;
    box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.15);
    z-index: 9999;
    display: none;
    animation: slideUp 0.4s ease-out;
    border-top: 1px solid var(--border-light);
}

@keyframes slideUp {
    from {
        transform: translateY(100%);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

#cookie-banner.show {
    display: block;
}

.cookie-container {
    max-width: 1200px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    gap: 20px;
    flex-wrap: wrap;
}

.cookie-icon {
    font-size: 40px;
    flex-shrink: 0;
}

.cookie-content {
    flex: 1;
    min-width: 300px;
}

.cookie-title {
    font-size: 18px;
    font-weight: 600;
    margin-bottom: 8px;
}

.cookie-text {
    font-size: 14px;
    line-height: 1.5;
    opacity: 0.95;
}

.cookie-text a {
    color: var(--primary-blue);
    text-decoration: underline;
    font-weight: 500;
}

.cookie-text a:hover {
    opacity: 0.8;
}

.cookie-buttons {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
}

.cookie-btn {
    padding: 12px 24px;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    white-space: nowrap;
}

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

.cookie-btn-accept:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.cookie-btn-settings {
    background: var(--bg-primary);
    color: var(--text-primary);
    border: 2px solid var(--border-light);
}

.cookie-btn-settings:hover {
    background: var(--border-light);
}

.cookie-btn-reject {
    background: transparent;
    color: var(--text-secondary);
    text-decoration: underline;
    padding: 12px 16px;
}

.cookie-btn-reject:hover {
    opacity: 0.8;
}

/* Cookie Settings Modal */
#cookie-settings-modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    z-index: 10000;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

#cookie-settings-modal.show {
    display: flex;
}

#cookie-settings-modal .modal-content {
    background: var(--bg-secondary);
    border-radius: 16px;
    max-width: 600px;
    width: 100%;
    max-height: 80vh;
    overflow-y: auto;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    animation: modalFadeIn 0.3s ease-out;
}

@keyframes modalFadeIn {
    from {
        opacity: 0;
        transform: scale(0.9);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

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

.modal-title {
    font-size: 24px;
    font-weight: 700;
    color: var(--text-primary);
}

.modal-close {
    background: none;
    border: none;
    font-size: 28px;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 0;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    transition: background 0.2s;
}

.modal-close:hover {
    background: var(--bg-primary);
}

.modal-body {
    padding: 24px;
    color: var(--text-secondary);
}

.cookie-category {
    margin-bottom: 24px;
    padding: 16px;
    background: var(--bg-primary);
    border-radius: 12px;
}

.category-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}

.invalid-input-flash {
    animation: invalidFlash 0.2s ease;
}

@keyframes invalidFlash {
    0%, 100% { background-color: var(--bg-primary); }
    50% { background-color: rgba(255, 107, 107, 0.2); }
}

.empty-state {
    border-color: var(--border-light) !important;
}

.success-state {
    border-color: var(--success) !important;
    background-color: rgba(16, 185, 129, 0.05);
}

.warning-state {
    border-color: var(--warning) !important;
    background-color: rgba(251, 191, 36, 0.05);
}

.error-state {
    border-color: var(--error) !important;
    background-color: rgba(239, 68, 68, 0.05);
}

.aa-button-clicked {
    transform: scale(0.95);
    background-color: var(--primary-blue) !important;
    color: white !important;
}

@keyframes slideIn {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

@keyframes slideOut {
    from {
        transform: translateX(0);
        opacity: 1;
    }
    to {
        transform: translateX(100%);
        opacity: 0;
    }
}