:root {
    --bg-color: #0b0f19;
    --card-bg: rgba(20, 27, 45, 0.6);
    --card-border: rgba(255, 255, 255, 0.08);
    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    --accent-primary: #6366f1;
    --accent-secondary: #8b5cf6;
    --accent-gradient: linear-gradient(135deg, var(--accent-primary), var(--accent-secondary));
    --error: #ef4444;
    --success: #10b981;
}

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

body {
    font-family: 'Inter', sans-serif;
    background-color: var(--bg-color);
    color: var(--text-primary);
    min-height: 100vh;
    background-image: 
        radial-gradient(at 0% 0%, rgba(99, 102, 241, 0.15) 0px, transparent 50%),
        radial-gradient(at 100% 100%, rgba(139, 92, 246, 0.15) 0px, transparent 50%);
    background-attachment: fixed;
}

.app-container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 2rem;
    display: flex;
    flex-direction: column;
    gap: 2rem;
    height: 100vh;
}

/* Header */
.header {
    text-align: center;
    padding: 1rem 0;
    animation: fadeInDown 0.8s ease-out;
}

.logo-text {
    font-family: 'Outfit', sans-serif;
    font-size: 3rem;
    font-weight: 800;
    letter-spacing: -1px;
}

.logo-text .highlight {
    background: var(--accent-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.subtitle {
    color: var(--text-secondary);
    font-size: 1.1rem;
    margin-top: 0.5rem;
}

/* Main Layout */
.main-content {
    display: grid;
    grid-template-columns: 500px 1fr;
    gap: 2rem;
    flex: 1;
    min-height: 0;
}

.left-panel {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    overflow-y: auto;
    padding-right: 0.5rem;
}

.left-panel::-webkit-scrollbar, .table-container::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}
.left-panel::-webkit-scrollbar-thumb, .table-container::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 3px;
}

.right-panel {
    display: flex;
    flex-direction: column;
    min-height: 0;
}

/* Cards */
.card {
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: 16px;
    padding: 1.5rem;
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
    animation: fadeInUp 0.5s ease-out backwards;
}

.card:nth-child(2) { animation-delay: 0.1s; }
.card:nth-child(3) { animation-delay: 0.2s; }

.card h2 {
    font-family: 'Outfit', sans-serif;
    font-size: 1.25rem;
    margin-bottom: 1.25rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    border-bottom: 1px solid var(--card-border);
    padding-bottom: 0.75rem;
}

.badge {
    font-size: 0.75rem;
    background: rgba(99, 102, 241, 0.2);
    color: var(--accent-primary);
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    font-family: 'Inter', sans-serif;
}

/* Forms & Inputs */
.input-section {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.input-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

/* Upload Zone */
.upload-zone {
    border: 2px dashed var(--card-border);
    border-radius: 8px;
    padding: 1.5rem;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s;
    background: rgba(255, 255, 255, 0.02);
    position: relative;
    overflow: hidden;
}

.upload-zone:hover {
    border-color: var(--accent-primary);
    background: rgba(255, 255, 255, 0.05);
}

.upload-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    color: var(--text-secondary);
}

.upload-subtext {
    font-size: 0.8rem;
    opacity: 0.7;
}

.image-preview {
    max-width: 100%;
    max-height: 150px;
    object-fit: contain;
    border-radius: 4px;
}

.remove-image-btn {
    position: absolute;
    top: 8px;
    right: 8px;
    background: rgba(0,0,0,0.6);
    color: white;
    border: none;
    border-radius: 4px;
    padding: 0.25rem 0.5rem;
    cursor: pointer;
    font-size: 0.8rem;
    z-index: 10;
    transition: background 0.2s;
}

.remove-image-btn:hover {
    background: var(--error);
}

.peaks-list {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.peak-chip {
    background: var(--card-border);
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    font-size: 0.85rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.peak-chip.loading {
    opacity: 0.7;
    animation: pulse 1.5s infinite;
}

.peak-remove {
    cursor: pointer;
    color: var(--text-secondary);
}

.peak-remove:hover {
    color: var(--error);
}

.input-row {
    display: grid;
    grid-template-columns: 100px 1fr;
    gap: 1rem;
}

label {
    font-size: 0.875rem;
    color: var(--text-secondary);
    font-weight: 500;
}

input[type="number"], select {
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid var(--card-border);
    color: var(--text-primary);
    padding: 0.75rem 1rem;
    border-radius: 8px;
    font-family: 'Inter', sans-serif;
    font-size: 1rem;
    transition: all 0.2s;
}

input[type="number"]:focus, select:focus {
    outline: none;
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.2);
}

select option, select optgroup {
    background: var(--bg-color);
    color: var(--text-primary);
}

.primary-btn {
    width: 100%;
    background: var(--accent-gradient);
    color: white;
    border: none;
    padding: 1rem;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
    margin-top: 0.5rem;
}

.primary-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.4);
}

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

/* Toggles */
.toggle-group {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 0.75rem;
}

.toggle {
    position: relative;
    display: inline-block;
    width: 44px;
    height: 24px;
}

.toggle input {
    opacity: 0;
    width: 0;
    height: 0;
}

.slider {
    position: absolute;
    cursor: pointer;
    top: 0; left: 0; right: 0; bottom: 0;
    background-color: rgba(255,255,255,0.1);
    transition: .3s;
    border-radius: 24px;
}

.slider:before {
    position: absolute;
    content: "";
    height: 18px;
    width: 18px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    transition: .3s;
    border-radius: 50%;
}

input:checked + .slider {
    background: var(--accent-gradient);
}

input:checked + .slider:before {
    transform: translateX(20px);
}

.toggle-label {
    font-size: 0.9rem;
    color: var(--text-secondary);
}

/* Elements Grid */
.elements-grid {
    display: grid;
    gap: 0.75rem;
}

.element-row {
    display: grid;
    grid-template-columns: 40px 1fr 1fr;
    gap: 0.75rem;
    align-items: center;
    background: rgba(0, 0, 0, 0.15);
    padding: 0.5rem 0.75rem;
    border-radius: 8px;
    border: 1px solid transparent;
    transition: border-color 0.2s;
}

.element-row.active {
    border-color: rgba(99, 102, 241, 0.3);
}

.element-symbol {
    font-family: 'Outfit', sans-serif;
    font-weight: 600;
    font-size: 1.1rem;
}

.element-row input[type="checkbox"] {
    width: 20px;
    height: 20px;
    cursor: pointer;
    accent-color: var(--accent-primary);
}

.element-toggle {
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.range-inputs {
    display: flex;
    gap: 0.5rem;
    align-items: center;
    opacity: 0.5;
    pointer-events: none;
    transition: opacity 0.2s;
}

.element-row.active .range-inputs {
    opacity: 1;
    pointer-events: all;
}

.range-inputs input {
    width: 100%;
    padding: 0.4rem;
    font-size: 0.9rem;
}

/* Results */
.results-section {
    flex: 1;
    display: flex;
    flex-direction: column;
}

.results-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.results-header h2 {
    margin-bottom: 0;
    border: none;
    padding: 0;
}

.results-count {
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.status-indicator {
    padding: 0.75rem;
    border-radius: 8px;
    text-align: center;
    font-size: 0.9rem;
    font-weight: 500;
    margin-bottom: 1rem;
    display: none; /* Hidden by default */
}

.status-indicator.loading {
    display: block;
    background: rgba(99, 102, 241, 0.1);
    color: var(--accent-primary);
    animation: pulse 1.5s infinite;
}

.status-indicator.error {
    display: block;
    background: rgba(239, 68, 68, 0.1);
    color: var(--error);
}

.table-container {
    flex: 1;
    overflow: auto;
    border-radius: 8px;
    border: 1px solid var(--card-border);
}

table {
    width: 100%;
    border-collapse: collapse;
    text-align: left;
}

th {
    background: rgba(0, 0, 0, 0.3);
    padding: 1rem;
    font-weight: 600;
    font-size: 0.85rem;
    color: var(--text-secondary);
    position: sticky;
    top: 0;
    z-index: 10;
}

td {
    padding: 1rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    font-size: 0.95rem;
}

tr:hover td {
    background: rgba(255, 255, 255, 0.03);
}

.formula-text {
    font-family: 'Outfit', sans-serif;
    font-weight: 600;
    color: var(--accent-primary);
    letter-spacing: 0.5px;
}

.empty-state {
    text-align: center;
    color: var(--text-secondary);
    padding: 3rem !important;
}

/* Animations */
@keyframes fadeInUp {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes fadeInDown {
    from { opacity: 0; transform: translateY(-20px); }
    to { opacity: 1; transform: translateY(0); }
}

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

/* Secondary button */
.secondary-btn {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-primary);
    border: 1px dashed var(--text-secondary);
    padding: 0.75rem;
    border-radius: 8px;
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.2s;
}

.secondary-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: var(--text-primary);
}

/* Modal */
.modal {
    display: none;
    position: fixed;
    top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0, 0, 0, 0.7);
    z-index: 100;
    backdrop-filter: blur(5px);
    justify-content: center;
    align-items: center;
}

.modal.active {
    display: flex;
}

.modal-content {
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: 16px;
    padding: 2rem;
    max-width: 95vw;
    max-height: 90vh;
    overflow-y: auto;
    position: relative;
    box-shadow: 0 10px 40px rgba(0,0,0,0.5);
}

.close-btn {
    position: absolute;
    top: 1rem; right: 1.5rem;
    font-size: 1.5rem;
    color: var(--text-secondary);
    cursor: pointer;
}

.close-btn:hover {
    color: white;
}

/* Periodic Grid */
.periodic-grid {
    display: grid;
    grid-template-columns: repeat(18, minmax(35px, 1fr));
    gap: 4px;
    margin-top: 1rem;
    overflow-x: auto;
}

.pt-element {
    background: rgba(255,255,255,0.05);
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: 4px;
    padding: 0.25rem;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 45px;
}

.pt-element:hover {
    background: var(--accent-primary);
    transform: scale(1.1);
    z-index: 2;
}

.pt-symbol {
    font-weight: bold;
    font-size: 1rem;
}

.pt-number {
    font-size: 0.55rem;
    color: var(--text-secondary);
}

.pt-element:hover .pt-number {
    color: rgba(255,255,255,0.8);
}

@media (max-width: 1024px) {
    .main-content {
        grid-template-columns: 1fr;
    }
    .app-container {
        height: auto;
        display: block;
    }
    .left-panel {
        overflow: visible;
    }
}
