:root {
    --bg-dark: #0f172a;
    --bg-panel: #1e293b;
    --bg-input: #334155;
    --primary: #38bdf8;
    --primary-glow: rgba(56, 189, 248, 0.3);
    --secondary: #818cf8;
    --accent: #f472b6;
    --text-main: #f8fafc;
    --text-muted: #94a3b8;
    --success: #4ade80;
    --warning: #fbbf24;
    --danger: #f87171;
    --border-radius: 16px;
    --font-family: 'Outfit', sans-serif;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: var(--font-family);
}

body {
    background-color: var(--bg-dark);
    color: var(--text-main);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 20px;
}

.app-container {
    width: 100%;
    max-width: 1000px;
    background: linear-gradient(145deg, #1e293b 0%, #0f172a 100%);
    border-radius: var(--border-radius);
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
    border: 1px solid rgba(255, 255, 255, 0.05);
    overflow: hidden;
    position: relative;
}

/* Ad Banner */
.ad-banner-container {
    width: 100%;
    height: 80px;
    background: linear-gradient(to right, #0f172a, #1e293b);
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 0;
}

.ad-link {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 15px;
    text-decoration: none;
    color: white;
    transition: background 0.3s;
    padding: 0 20px;
}

.ad-link:hover {
    background: rgba(255, 255, 255, 0.02);
}

.ad-highlight {
    background: var(--primary);
    color: #0f172a;
    padding: 4px 10px;
    border-radius: 4px;
    font-weight: 700;
    font-size: 0.85rem;
    text-transform: uppercase;
}

.ad-text {
    font-size: 1.1rem;
    color: var(--text-main);
}

.ad-text strong {
    color: var(--secondary);
}

.ad-cta {
    color: var(--success);
    font-weight: 600;
    font-size: 0.95rem;
    display: flex;
    align-items: center;
    gap: 5px;
}

@media (max-width: 600px) {
    .ad-link {
        flex-direction: column;
        gap: 5px;
        text-align: center;
        padding: 10px;
    }
    .ad-text {
        font-size: 0.95rem;
    }
}

header {
    padding: 30px;
    text-align: center;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

header h1 {
    font-size: 2.5rem;
    background: linear-gradient(to right, var(--primary), var(--secondary));
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    margin-bottom: 8px;
}

header p {
    color: var(--text-muted);
}

main {
    display: grid;
    grid-template-columns: 1fr 1.5fr;
    gap: 0;
}

@media (max-width: 768px) {
    main {
        grid-template-columns: 1fr;
    }
}

/* Controls Panel */
.controls-panel {
    padding: 40px;
    background: rgba(255, 255, 255, 0.02);
    border-right: 1px solid rgba(255, 255, 255, 0.05);
    display: flex;
    flex-direction: column;
    gap: 30px;
}

.control-group {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

label {
    font-weight: 500;
    color: var(--text-main);
    display: flex;
    justify-content: space-between;
}

.select-wrapper, .input-wrapper {
    position: relative;
    background: var(--bg-input);
    border-radius: 8px;
    transition: box-shadow 0.2s;
}

select, input[type="number"] {
    width: 100%;
    background: transparent;
    border: 1px solid transparent;
    color: white;
    padding: 12px 16px;
    font-size: 1rem;
    border-radius: 8px;
    outline: none;
    appearance: none;
    cursor: pointer;
}

select:focus, input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-glow);
}

.unit {
    position: absolute;
    right: 16px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    pointer-events: none;
}

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

input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 20px;
    height: 20px;
    background: var(--primary);
    border-radius: 50%;
    cursor: pointer;
    box-shadow: 0 0 10px var(--primary-glow);
    transition: transform 0.1s;
}

input[type="range"]::-webkit-slider-thumb:hover {
    transform: scale(1.1);
}

.range-markers {
    display: flex;
    justify-content: space-between;
    font-size: 0.8rem;
    color: var(--text-muted);
    padding: 0 4px;
}

.info-tooltip {
    font-size: 0.85rem;
    color: var(--text-muted);
    background: rgba(0, 0, 0, 0.2);
    padding: 10px;
    border-radius: 6px;
    border-left: 3px solid var(--secondary);
    line-height: 1.4;
}

/* Disk Manager */
.add-disk-buttons {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
}

.quick-add {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: var(--text-main);
    padding: 10px;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 500;
    transition: all 0.2s;
}

.quick-add:hover {
    background: var(--primary);
    color: #fff;
    border-color: var(--primary);
}

.custom-disk-input {
    display: flex;
    gap: 10px;
    position: relative;
}

.unit-overlay {
    position: absolute;
    left: 85px; /* Adjust based on input width */
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    font-size: 0.9rem;
    pointer-events: none;
}

.custom-disk-input input {
    flex: 1;
    max-width: 120px;
}

#add-custom-disk {
    flex: 1;
    background: var(--secondary);
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 600;
    transition: opacity 0.2s;
}

#add-custom-disk:hover {
    opacity: 0.9;
}

.disk-list-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    color: var(--text-muted);
    font-size: 0.9rem;
    padding-bottom: 5px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.text-btn {
    background: none;
    border: none;
    color: var(--danger);
    cursor: pointer;
    font-size: 0.8rem;
    text-decoration: underline;
}

.disk-list {
    max-height: 200px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding-right: 5px;
}

.disk-list::-webkit-scrollbar {
    width: 4px;
}
.disk-list::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 2px;
}

.disk-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: rgba(255, 255, 255, 0.03);
    padding: 8px 12px;
    border-radius: 6px;
    animation: slideIn 0.2s ease-out;
}

@keyframes slideIn {
    from { opacity: 0; transform: translateX(-10px); }
    to { opacity: 1; transform: translateX(0); }
}

.disk-info {
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 8px;
}

.disk-icon-small {
    font-size: 1.2rem;
}

.remove-disk {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 1.2rem;
    line-height: 1;
}

.remove-disk:hover {
    color: var(--danger);
}

.empty-state {
    text-align: center;
    color: var(--text-muted);
    font-size: 0.9rem;
    padding: 20px 0;
    font-style: italic;
}

/* Dashboard Panel */
.dashboard-panel {
    padding: 40px;
    display: flex;
    flex-direction: column;
    gap: 30px;
}

.visualization-container {
    min-height: 120px;
    padding: 20px;
    background: rgba(0, 0, 0, 0.2);
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.disks-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    justify-content: center;
}

.disk {
    width: 40px;
    height: 60px;
    background: linear-gradient(to bottom, #475569, #334155);
    border-radius: 4px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    position: relative;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.3);
    animation: popIn 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
    display: flex;
    align-items: flex-end;
    justify-content: center;
    font-size: 0.6rem;
    color: rgba(255, 255, 255, 0.5);
    padding-bottom: 2px;
}

.disk::after {
    content: '';
    position: absolute;
    top: 6px;
    right: 6px;
    width: 4px;
    height: 4px;
    background: var(--success);
    border-radius: 50%;
    box-shadow: 0 0 5px var(--success);
}

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

.stats-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px;
}

.stat-card {
    background: rgba(255, 255, 255, 0.03);
    padding: 20px;
    border-radius: 12px;
    border: 1px solid rgba(255, 255, 255, 0.05);
    transition: transform 0.2s;
    display: flex;
    flex-direction: column;
}

.stat-card:hover {
    transform: translateY(-2px);
    background: rgba(255, 255, 255, 0.05);
}

.stat-card.primary {
    grid-column: span 2;
    background: linear-gradient(135deg, rgba(56, 189, 248, 0.05), rgba(30, 41, 59, 0));
    border-color: rgba(56, 189, 248, 0.2);
}

.stat-icon {
    font-size: 1.5rem;
    margin-bottom: 10px;
}

.stat-label {
    color: var(--text-muted);
    font-size: 0.9rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    font-weight: 500;
}

.stat-value {
    font-size: 2rem;
    font-weight: 700;
    margin: 5px 0 15px 0;
    background: linear-gradient(to right, #fff, #cbd5e1);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

/* Stacked Bar */
.capacity-breakdown {
    margin-top: auto;
}

.breakdown-bar {
    height: 12px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 6px;
    display: flex;
    overflow: hidden;
    margin-bottom: 10px;
}

.bar-segment {
    height: 100%;
    transition: width 0.5s ease;
}

.bar-segment.data { background: var(--success); }
.bar-segment.protection { background: var(--primary); }
.bar-segment.unused { background: var(--text-muted); opacity: 0.3; }

.breakdown-legend {
    display: flex;
    gap: 10px;
    font-size: 0.8rem;
    color: var(--text-muted);
    flex-wrap: wrap; /* Allows items to wrap on small screens */
    margin-top: 5px;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 6px;
    white-space: nowrap; /* Prevents text from breaking within an item */
}

.dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
}
.dot.data { background: var(--success); }
.dot.protection { background: var(--primary); }
.dot.unused { background: var(--text-muted); opacity: 0.3; }

.speed-indicators {
    display: flex;
    flex-direction: column;
    gap: 15px;
    background: rgba(0, 0, 0, 0.2);
    padding: 20px;
    border-radius: 12px;
}

.speed-row {
    display: flex;
    align-items: center;
    gap: 15px;
}

.speed-row span:first-child {
    width: 60px;
    font-size: 0.9rem;
    color: var(--text-muted);
}

.progress-bar {
    flex: 1;
    height: 6px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 3px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(to right, var(--secondary), var(--primary));
    border-radius: 3px;
    transition: width 0.5s ease-out;
}

#read-speed-text, #write-speed-text {
    width: 80px;
    font-size: 0.8rem;
    text-align: right;
    color: var(--text-main);
}
