/* ===== Floating Calculator Button ===== */
.floating-calc-btn {
    position: fixed;
    top: 50%;
    right: 20px;
    transform: translateY(-50%);
    width: 70px;
    height: 85px;
    border-radius: 12px;
    background: linear-gradient(135deg, #6366f1, #8b5cf6);
    color: white;
    font-size: 32px;
    border: none;
    cursor: pointer;
    box-shadow: 0 4px 20px rgba(99, 102, 241, 0.4);
    transition: all 0.3s ease;
    z-index: 9998;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    padding: 8px;
    animation: pulse-float 2s ease-in-out infinite;
}

.floating-calc-btn::after {
    content: 'Calculator';
    font-size: 9px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: white;
    margin-top: 2px;
}

.floating-calc-btn:hover {
    transform: translateY(-50%) scale(1.05);
    box-shadow: 0 8px 30px rgba(99, 102, 241, 0.6);
    right: 15px;
}

.floating-calc-btn:active {
    transform: translateY(-50%) scale(0.98);
}

@keyframes pulse-float {
    0%, 100% {
        box-shadow: 0 4px 20px rgba(99, 102, 241, 0.4);
    }
    50% {
        box-shadow: 0 8px 30px rgba(99, 102, 241, 0.6);
    }
}

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

.calculator-modal.active {
    display: flex;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

.calculator-modal-content {
    background: var(--bg-primary);
    border-radius: 16px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    width: 90%;
    max-width: 340px;
    max-height: fit-content;
    overflow: hidden;
    animation: slideUp 0.3s ease;
    display: flex;
    flex-direction: column;
}

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

/* ===== Calculator Header ===== */
.calculator-header {
    background: linear-gradient(135deg, #6366f1, #8b5cf6);
    color: white;
    padding: 0.75rem 1rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.calculator-header h3 {
    margin: 0;
    font-size: 1rem;
    font-weight: 700;
    color: white;
}

.close-calc-btn {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: white;
    font-size: 1.5rem;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    line-height: 1;
}

.close-calc-btn:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: rotate(90deg);
}

/* ===== Calculator Body ===== */
.calculator-body {
    padding: 0.75rem;
    overflow: visible;
}

/* ===== Calculator Display ===== */
.calc-display {
    background: var(--bg-secondary);
    border-radius: 8px;
    padding: 0.6rem 0.75rem;
    margin-bottom: 0.75rem;
    min-height: 60px;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    border: 2px solid var(--border-color);
}

.calc-expression {
    color: var(--text-secondary);
    font-size: 0.7rem;
    min-height: 16px;
    margin-bottom: 0.3rem;
    word-wrap: break-word;
    font-family: 'Courier New', monospace;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.calc-result {
    color: var(--text-primary);
    font-size: 1.3rem;
    font-weight: 700;
    text-align: right;
    word-wrap: break-word;
    font-family: 'Courier New', monospace;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* ===== Calculator Buttons ===== */
.calc-buttons {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 0.3rem;
}

.calc-btn {
    padding: 0.5rem 0.3rem;
    border: none;
    border-radius: 6px;
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    background: var(--bg-secondary);
    color: var(--text-primary);
    border: 2px solid var(--border-color);
    min-height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
}

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

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

/* Number buttons */
.calc-number {
    background: var(--bg-primary);
    font-weight: 700;
}

.calc-number:hover {
    background: var(--bg-secondary);
    border-color: var(--primary-color);
}

/* Operator buttons */
.calc-operator {
    background: linear-gradient(135deg, #f59e0b, #f97316);
    color: white;
    border: none;
}

.calc-operator:hover {
    background: linear-gradient(135deg, #f97316, #ef4444);
}

/* Function buttons */
.calc-fn {
    background: var(--bg-tertiary);
    font-size: 0.7rem;
}

.calc-fn:hover {
    background: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
}

/* Equals button */
.calc-equals {
    background: linear-gradient(135deg, #10b981, #059669);
    color: white;
    font-size: 1.1rem;
    border: none;
}

.calc-equals:hover {
    background: linear-gradient(135deg, #059669, #047857);
}

/* ===== Mode Toggle ===== */
.calc-mode-toggle {
    margin-top: 0.6rem;
    display: flex;
    justify-content: center;
    align-items: center;
}

.calc-mode-toggle label {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    cursor: pointer;
    background: var(--bg-secondary);
    padding: 0.4rem 0.75rem;
    border-radius: 16px;
    border: 2px solid var(--border-color);
    transition: all 0.3s ease;
}

.calc-mode-toggle label:hover {
    border-color: var(--primary-color);
}

.calc-mode-toggle input[type="checkbox"] {
    width: 32px;
    height: 16px;
    appearance: none;
    background: var(--bg-tertiary);
    border-radius: 16px;
    position: relative;
    cursor: pointer;
    transition: all 0.3s ease;
}

.calc-mode-toggle input[type="checkbox"]::before {
    content: '';
    position: absolute;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: white;
    top: 2px;
    left: 2px;
    transition: all 0.3s ease;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.calc-mode-toggle input[type="checkbox"]:checked {
    background: var(--primary-color);
}

.calc-mode-toggle input[type="checkbox"]:checked::before {
    left: 18px;
}

#degRadLabel {
    font-weight: 700;
    color: var(--text-primary);
    min-width: 32px;
    font-size: 0.75rem;
}

/* ===== Responsive Design ===== */
@media (max-width: 768px) {
    .floating-calc-btn {
        width: 60px;
        height: 75px;
        font-size: 28px;
        right: 15px;
    }
    
    .floating-calc-btn::after {
        font-size: 8px;
    }
    
    .calculator-modal-content {
        width: 95%;
        max-width: 320px;
    }
    
    .calc-buttons {
        gap: 0.25rem;
    }
    
    .calc-btn {
        padding: 0.45rem 0.25rem;
        font-size: 0.75rem;
        min-height: 34px;
    }
    
    .calc-fn {
        font-size: 0.65rem;
    }
    
    .calc-result {
        font-size: 1.2rem;
    }
}

@media (max-width: 480px) {
    .floating-calc-btn {
        width: 55px;
        height: 70px;
        font-size: 26px;
        right: 10px;
    }
    
    .floating-calc-btn::after {
        font-size: 7px;
    }
    
    .calculator-modal-content {
        border-radius: 12px;
        max-width: 300px;
    }
    
    .calculator-body {
        padding: 0.6rem;
    }
    
    .calc-display {
        padding: 0.5rem 0.6rem;
        min-height: 55px;
    }
    
    .calc-btn {
        padding: 0.4rem 0.2rem;
        font-size: 0.7rem;
        min-height: 32px;
    }
    
    .calc-fn {
        font-size: 0.6rem;
    }
    
    .calc-result {
        font-size: 1.1rem;
    }
    
    .calc-expression {
        font-size: 0.65rem;
    }
    
    .calculator-header h3 {
        font-size: 0.9rem;
    }
    
    .close-calc-btn {
        width: 26px;
        height: 26px;
        font-size: 1.3rem;
    }
}

/* ===== Dark Mode Adjustments ===== */
[data-theme="dark"] .calc-display {
    background: var(--bg-tertiary);
}

[data-theme="dark"] .calc-number {
    background: var(--bg-secondary);
}

[data-theme="dark"] .calc-number:hover {
    background: var(--bg-tertiary);
}

/* ===== Print Styles ===== */
@media print {
    .floating-calc-btn,
    .calculator-modal {
        display: none !important;
    }
}
