:root {
    --primary-color: #6c5ce7;
    --secondary-color: #a29bfe;
    --text-color: #f5f6fa;
    --bg-color: #2d3436;
    --display-bg: rgba(45, 52, 54, 0.7);
    --btn-bg: rgba(108, 92, 231, 0.1);
    --btn-hover: rgba(108, 92, 231, 0.3);
    --highlight-color: #fd79a8;
    --shadow-color: rgba(108, 92, 231, 0.4);
    --glass-bg: rgba(255, 255, 255, 0.05);
    --glass-border: rgba(255, 255, 255, 0.1);
    --glass-shadow: 0 8px 32px 0 rgba(31, 38, 135, 0.37);
}

[data-theme="light"] {
    --primary-color: #0984e3;
    --secondary-color: #74b9ff;
    --text-color: #2d3436;
    --bg-color: #f5f6fa;
    --display-bg: rgba(245, 246, 250, 0.7);
    --btn-bg: rgba(9, 132, 227, 0.1);
    --btn-hover: rgba(9, 132, 227, 0.3);
    --highlight-color: #e84393;
    --shadow-color: rgba(9, 132, 227, 0.4);
    --glass-bg: rgba(255, 255, 255, 0.7);
    --glass-border: rgba(255, 255, 255, 0.9);
    --glass-shadow: 0 8px 32px 0 rgba(149, 175, 192, 0.37);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    transition: background-color 0.3s, color 0.3s;
}

body {
    background-color: var(--bg-color);
    color: var(--text-color);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: hidden;
    position: relative;
}

.particles-container {
    position: absolute;
    width: 100%;
    height: 100%;
    z-index: -1;
}

.calculator-container {
    width: 100%;
    max-width: 400px;
    padding: 20px;
}

.calculator-glass {
    background: var(--glass-bg);
    border-radius: 20px;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid var(--glass-border);
    box-shadow: var(--glass-shadow);
    padding: 25px;
    overflow: hidden;
    position: relative;
}

.calculator-glass::before {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: linear-gradient(
        to bottom right,
        transparent,
        transparent,
        transparent,
        var(--primary-color)
    );
    transform: rotate(0deg);
    animation: rotate 6s linear infinite;
    z-index: -1;
    opacity: 0.5;
}

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

.calculator-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding-bottom: 10px;
    border-bottom: 1px solid var(--glass-border);
}

.calculator-header h1 {
    font-size: 1.5rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 10px;
}

.theme-toggle {
    display: flex;
    align-items: center;
    gap: 5px;
}

.switch {
    position: relative;
    display: inline-block;
    width: 50px;
    height: 24px;
}

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

.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: var(--secondary-color);
    transition: .4s;
    border-radius: 34px;
}

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

input:checked + .slider {
    background-color: var(--highlight-color);
}

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

.display {
    background-color: var(--display-bg);
    border-radius: 10px;
    padding: 20px;
    margin-bottom: 20px;
    text-align: right;
    min-height: 100px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    box-shadow: inset 0 0 10px rgba(0, 0, 0, 0.1);
    position: relative;
    overflow: hidden;
}

.display::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 3px;
    background: linear-gradient(to right, var(--primary-color), var(--highlight-color));
}

.previous-operand {
    font-size: 1.2rem;
    opacity: 0.7;
    min-height: 24px;
    word-wrap: break-word;
}

.current-operand {
    font-size: 2.5rem;
    font-weight: 600;
    word-wrap: break-word;
}

.buttons-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 15px;
}

.btn {
    border: none;
    border-radius: 10px;
    padding: 15px 0;
    font-size: 1.2rem;
    font-weight: 500;
    cursor: pointer;
    background-color: var(--btn-bg);
    color: var(--text-color);
    display: flex;
    justify-content: center;
    align-items: center;
    position: relative;
    overflow: hidden;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    transition: all 0.2s ease;
}

.btn::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(
        90deg,
        transparent,
        rgba(255, 255, 255, 0.2),
        transparent
    );
    transition: 0.5s;
}

.btn:hover::before {
    left: 100%;
}

.btn:hover {
    background-color: var(--btn-hover);
    transform: translateY(-2px);
    box-shadow: 0 6px 12px var(--shadow-color);
}

.btn:active {
    transform: translateY(0);
    box-shadow: 0 2px 4px var(--shadow-color);
}

.span-2 {
    grid-column: span 2;
}

.number {
    background-color: var(--btn-bg);
}

.operator {
    background-color: var(--btn-bg);
}

.highlight {
    background-color: rgba(253, 121, 168, 0.1);
    color: var(--highlight-color);
}

.highlight:hover {
    background-color: rgba(253, 121, 168, 0.2);
}

.equals {
    background-color: var(--highlight-color);
    color: white;
}

.equals:hover {
    background-color: #e84393;
    box-shadow: 0 6px 12px rgba(232, 67, 147, 0.4);
}

@media (max-width: 480px) {
    .calculator-container {
        padding: 10px;
    }
    
    .calculator-glass {
        padding: 15px;
    }
    
    .btn {
        padding: 12px 0;
        font-size: 1rem;
    }
    
    .current-operand {
        font-size: 2rem;
    }
}
