:root {
    --primary-color: #4361ee;
    --secondary-color: #3a0ca3;
    --accent-color: #4cc9f0;
    --background-color: #f8f9fa;
    --text-color: #212529;
    --card-color: #fff;
    --border-color: #dee2e6;
    --shadow-color: rgba(0, 0, 0, 0.1);
    --success-color: #2ecc71;
    --error-color: #e74c3c;
    --font-main: 'Inter', system-ui, -apple-system, sans-serif;
    --font-mono: 'Fira Code', 'Courier New', monospace;
}

[data-theme="dark"] {
    --primary-color: #3a86ff;
    --secondary-color: #8338ec;
    --accent-color: #00b4d8;
    --background-color: #121212;
    --text-color: #f8f9fa;
    --card-color: #1e1e1e;
    --border-color: #333;
    --shadow-color: rgba(0, 0, 0, 0.3);
    --success-color: #27ae60;
    --error-color: #e74c3c;
}

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');
@import url('https://fonts.googleapis.com/css2?family=Fira+Code:wght@400;500&display=swap');

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: var(--font-main);
    transition: all 0.3s ease;
}

body {
    background-color: var(--background-color);
    color: var(--text-color);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 20px;
    line-height: 1.6;
}

.calculator-container {
    background-color: var(--card-color);
    border-radius: 16px;
    box-shadow: 0 8px 30px var(--shadow-color);
    width: 100%;
    max-width: 850px;
    overflow: hidden;
    transform: translateY(-10px);
    opacity: 0;
    animation: fadeInUp 0.5s forwards;
}

@keyframes fadeInUp {
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.header {
    padding: 24px;
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    color: white;
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: relative;
    overflow: hidden;
}

.header::before {
    content: '';
    position: absolute;
    top: -50%;
    right: -50%;
    width: 200%;
    height: 200%;
    background: radial-gradient(circle, rgba(255,255,255,0.1) 0%, transparent 70%);
    transform: rotate(30deg);
}

.header h1 {
    font-size: 28px;
    font-weight: 700;
    letter-spacing: -0.5px;
    position: relative;
    text-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.version {
    font-size: 14px;
    opacity: 0.8;
    font-weight: 400;
    margin-left: 8px;
}

.theme-toggle {
    display: flex;
    align-items: center;
    gap: 12px;
    position: relative;
    z-index: 1;
}

.theme-toggle i {
    font-size: 18px;
    transition: transform 0.3s ease;
}

.theme-toggle:hover i {
    transform: scale(1.1);
}

.switch {
    position: relative;
    display: inline-block;
    width: 60px;
    height: 30px;
}

.switch 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.3);
    transition: .4s;
    border-radius: 34px;
}

.slider:before {
    position: absolute;
    content: "";
    height: 22px;
    width: 22px;
    left: 4px;
    bottom: 4px;
    background-color: white;
    transition: .4s;
    border-radius: 50%;
    box-shadow: 0 2px 5px rgba(0,0,0,0.2);
}

input:checked + .slider {
    background-color: var(--accent-color);
}

input:checked + .slider:before {
    transform: translateX(30px);
}

/* Tab styles */
.tabs {
    display: flex;
    border-bottom: 1px solid var(--border-color);
    position: relative;
}

.tabs::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    height: 2px;
    width: 25%;
    background: var(--primary-color);
    transition: all 0.3s ease;
    transform: translateX(0);
}

.tabs[data-active-tab="bitwise"]::after {
    transform: translateX(100%);
}

.tabs[data-active-tab="strings"]::after {
    transform: translateX(200%);
}

.tabs[data-active-tab="arrays"]::after {
    transform: translateX(300%);
}

.tab-btn {
    flex: 1;
    padding: 16px 0;
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text-color);
    font-weight: 600;
    font-size: 15px;
    letter-spacing: 0.2px;
    position: relative;
    overflow: hidden;
    transition: all 0.3s ease;
}

.tab-btn::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 50%;
    width: 0;
    height: 3px;
    background-color: var(--primary-color);
    transition: all 0.3s ease;
    transform: translateX(-50%);
}

.tab-btn:hover {
    color: var(--primary-color);
    background-color: rgba(0, 0, 0, 0.03);
}

.tab-btn:hover::after {
    width: 40%;
}

.tab-btn.active {
    color: var(--primary-color);
}

.tab-btn.active::after {
    width: 70%;
}

/* Tab content styles */
.tab-content {
    display: none;
    padding: 24px;
    animation: fadeIn 0.4s ease;
}

@keyframes fadeIn {
    from { opacity: 0.5; transform: translateY(5px); }
    to { opacity: 1; transform: translateY(0); }
}

.tab-content.active {
    display: block;
}

.input-group {
    margin-bottom: 24px;
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
}

input, select, textarea, button {
    padding: 14px 18px;
    border-radius: 8px;
    border: 1px solid var(--border-color);
    background-color: var(--card-color);
    color: var(--text-color);
    font-size: 15px;
    transition: all 0.2s ease;
    outline: none;
}

input:focus, select:focus, textarea:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(67, 97, 238, 0.2);
}

select {
    flex: 1 1 100%;
    appearance: none;
    background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6 9 12 15 18 9'%3e%3c/polyline%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: right 14px center;
    background-size: 18px;
    cursor: pointer;
}

input, textarea {
    flex: 1;
    min-width: 200px;
}

textarea {
    resize: vertical;
    min-height: 120px;
    line-height: 1.6;
}

button {
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    color: white;
    border: none;
    cursor: pointer;
    font-weight: 600;
    padding: 14px 24px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    position: relative;
    overflow: hidden;
}

button::after {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, rgba(255,255,255,0.1), rgba(255,255,255,0.3), rgba(255,255,255,0.1));
    transition: all 0.4s ease;
}

button:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 12px rgba(0, 0, 0, 0.15);
}

button:hover::after {
    left: 100%;
}

button:active {
    transform: translateY(0);
}

#convert-btn::before, #bitwise-btn::before, 
#string-btn::before, #array-btn::before {
    content: '';
    display: inline-block;
    width: 18px;
    height: 18px;
    background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='white'%3e%3cpath stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M13 10V3L4 14h7v7l9-11h-7z'/%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: center;
    filter: brightness(0) invert(1);
    transition: transform 0.3s ease;
}

button:hover::before {
    transform: scale(1.2);
}

/* Result styles */
.results {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 18px;
    margin-top: 16px;
}

.result-box {
    background-color: rgba(0, 0, 0, 0.05);
    padding: 20px;
    border-radius: 12px;
    border-left: 4px solid var(--primary-color);
    transition: all 0.3s ease;
}

.result-box:hover {
    transform: translateY(-3px);
    box-shadow: 0 6px 12px rgba(0, 0, 0, 0.08);
}

.result-box h3 {
    margin-bottom: 12px;
    font-size: 16px;
    font-weight: 600;
    color: var(--primary-color);
    display: flex;
    align-items: center;
    gap: 8px;
}

.result-box h3::before {
    content: '';
    display: inline-block;
    width: 12px;
    height: 12px;
    background-color: var(--primary-color);
    border-radius: 3px;
}

#conversion-result, #binary-representation, #bitwise-result, 
#string-result, #array-result {
    font-family: var(--font-mono);
    word-break: break-all;
    line-height: 1.7;
    white-space: pre-wrap;
    font-size: 15px;
}

.success-result {
    color: var(--success-color);
    animation: pulse 0.5s ease;
}

.error-result {
    color: var(--error-color);
    animation: shake 0.5s ease;
}

@keyframes pulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.02); }
    100% { transform: scale(1); }
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-5px); }
    75% { transform: translateX(5px); }
}

/* Footer styles */
.footer {
    padding: 18px;
    text-align: center;
    font-size: 14px;
    color: var(--text-color);
    opacity: 0.8;
    border-top: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.footer i {
    color: var(--error-color);
    animation: heartbeat 1.5s ease infinite;
}

@keyframes heartbeat {
    0% { transform: scale(1); }
    25% { transform: scale(1.1); }
    50% { transform: scale(1); }
    75% { transform: scale(1.1); }
    100% { transform: scale(1); }
}

/* Responsive styles */
@media (max-width: 768px) {
    .header {
        flex-direction: column;
        gap: 18px;
        text-align: center;
    }
    
    .tabs {
        flex-direction: column;
    }
    
    .tabs::after {
        display: none;
    }
    
    .tab-btn {
        text-align: center;
        border-bottom: 1px solid var(--border-color);
    }
    
    .tab-btn.active {
        border-bottom: 2px solid var(--primary-color);
    }
    
    .tab-btn::after {
        display: none;
    }
    
    input, textarea {
        min-width: 100%;
    }
    
    .results {
        grid-template-columns: 1fr;
    }
}
