/* Calculator Overlay */
.calculator-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.3);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    transition: all 0.4s cubic-bezier(0.22, 0.61, 0.36, 1);
}

.calculator-overlay.open {
    display: flex !important;
}

.calculator-overlay.closing {
    opacity: 0;
    backdrop-filter: blur(0px);
    -webkit-backdrop-filter: blur(0px);
    background: rgba(0, 0, 0, 0);
}

/* Calculator Window */
.calculator-window {
    width: 340px;
    height: 580px;
    background: rgba(58, 58, 60, 0.98);
    border-radius: 10px;
    box-shadow: 
        0 25px 60px rgba(0, 0, 0, 0.4),
        0 10px 25px rgba(0, 0, 0, 0.3),
        inset 0 1px 0 rgba(255, 255, 255, 0.05);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    transition: all 0.4s cubic-bezier(0.2, 0.8, 0.2, 1);
    animation: slideUp 0.4s cubic-bezier(0.2, 0.8, 0.2, 1);
    will-change: transform, opacity;
    position: relative;
}

.calculator-window.active {
    box-shadow: 
        0 25px 60px rgba(0, 0, 0, 0.5),
        0 10px 30px rgba(0, 0, 0, 0.4),
        inset 0 1px 0 rgba(255, 255, 255, 0.08);
}

.calculator-window.inactive {
    opacity: 0.85;
    box-shadow: 
        0 15px 40px rgba(0, 0, 0, 0.3),
        0 5px 15px rgba(0, 0, 0, 0.2);
}

.calculator-window.inactive .title-bar {
    background: rgba(45, 45, 45, 0.8);
}

.calculator-window.inactive .traffic-light {
    opacity: 0.5;
}

.calculator-window.closing {
    animation: closeWindow 0.4s cubic-bezier(0.22, 0.61, 0.36, 1) forwards;
}

.calculator-window.minimized {
    animation: minimizeWindow 0.4s cubic-bezier(0.22, 0.61, 0.36, 1) forwards;
    pointer-events: none;
}

.calculator-window.maximized {
    width: 100% !important;
    height: 100% !important;
    border-radius: 0;
    left: 0 !important;
    top: 0 !important;
    transform: none !important;
}

.calculator-window.dragging {
    cursor: grabbing;
    transition: none;
}

.calculator-window.resizing {
    transition: none;
    user-select: none;
}

/* Title Bar */
.calculator-window .title-bar {
    height: 28px;
    background: linear-gradient(
        to bottom,
        rgba(60, 60, 60, 0.95) 0%,
        rgba(45, 45, 45, 0.95) 100%
    );
    backdrop-filter: blur(40px);
    -webkit-backdrop-filter: blur(40px);
    border-bottom: 1px solid rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    cursor: grab;
    user-select: none;
    transition: background 0.15s ease, backdrop-filter 0.15s ease;
}

.calculator-window .title-bar:active {
    cursor: grabbing;
}

.calculator-window .title-bar:hover {
    background: linear-gradient(
        to bottom,
        rgba(65, 65, 65, 0.95) 0%,
        rgba(50, 50, 50, 0.95) 100%
    );
}

.calculator-window .window-title {
    color: rgba(255, 255, 255, 0.85);
    font-size: 13px;
    font-weight: 500;
    letter-spacing: 0.2px;
    font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Text', 'Segoe UI', sans-serif;
}

/* Traffic Lights */
.calculator-window .traffic-lights {
    position: absolute;
    left: 10px;
    display: flex;
    gap: 8px;
    z-index: 10;
}

.calculator-window .traffic-light {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    border: none;
    cursor: pointer;
    position: relative;
    transition: all 0.15s cubic-bezier(0.2, 0.8, 0.2, 1);
    box-shadow: 
        inset 0 1px 1px rgba(255, 255, 255, 0.3),
        0 1px 2px rgba(0, 0, 0, 0.4);
}

.calculator-window .traffic-light:hover {
    filter: brightness(1.15);
    transform: scale(1.05);
}

.calculator-window .traffic-light:active {
    transform: scale(0.92);
    filter: brightness(0.95);
    transition: all 0.08s cubic-bezier(0.4, 0.0, 1, 1);
}

.calculator-window .traffic-light.close {
    background: linear-gradient(135deg, #ff6057 0%, #ff5f57 100%);
}

.calculator-window .traffic-light.minimize {
    background: linear-gradient(135deg, #ffbd2e 0%, #ffbe30 100%);
}

.calculator-window .traffic-light.maximize {
    background: linear-gradient(135deg, #28ca42 0%, #29c941 100%);
}

/* Show icons on hover */
.calculator-window .title-bar:hover .traffic-light.close::before {
    content: '×';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: rgba(0, 0, 0, 0.7);
    font-size: 14px;
    font-weight: bold;
    line-height: 1;
    opacity: 0;
    animation: fadeInIcon 0.2s cubic-bezier(0.2, 0.8, 0.2, 1) forwards;
}

.calculator-window .title-bar:hover .traffic-light.minimize::before {
    content: '−';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: rgba(0, 0, 0, 0.7);
    font-size: 14px;
    font-weight: bold;
    line-height: 1;
    opacity: 0;
    animation: fadeInIcon 0.2s cubic-bezier(0.2, 0.8, 0.2, 1) forwards;
}

.calculator-window .title-bar:hover .traffic-light.maximize::before {
    content: '⤢';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) rotate(45deg);
    color: rgba(0, 0, 0, 0.7);
    font-size: 10px;
    font-weight: bold;
    line-height: 1;
    opacity: 0;
    animation: fadeInIcon 0.2s cubic-bezier(0.2, 0.8, 0.2, 1) forwards;
}

@keyframes fadeInIcon {
    from {
        opacity: 0;
        transform: translate(-50%, -50%) scale(0.8);
    }
    to {
        opacity: 1;
        transform: translate(-50%, -50%) scale(1);
    }
}

/* Calculator Content */
.calculator-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    padding: 0;
    gap: 0;
}

/* Calculator Display */
.calculator-display {
    width: 100%;
    height: 110px;
    background: transparent;
    border: none;
    border-radius: 0;
    padding: 20px 20px 10px 20px;
    font-size: 72px;
    font-weight: 300;
    color: #ffffff;
    text-align: right;
    font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Display', 'Segoe UI', sans-serif;
    margin-bottom: 0;
    box-shadow: none;
    line-height: 1;
    display: flex;
    align-items: flex-end;
    justify-content: flex-end;
}

.calculator-display:focus {
    outline: none;
}

/* Calculator Button Grid */
.calculator-buttons {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 0;
    flex: 1;
}

/* Calculator Button */
.calc-btn {
    background: #505050;
    border: 0.5px solid rgba(0, 0, 0, 0.3);
    border-radius: 0;
    color: #ffffff;
    font-size: 28px;
    font-weight: 400;
    font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Display', 'Segoe UI', sans-serif;
    cursor: pointer;
    transition: all 0.1s ease;
    box-shadow: none;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 64px;
    user-select: none;
    -webkit-user-select: none;
}

.calc-btn span {
    position: static;
    transform: none;
}

.calc-btn:hover {
    background: #6c6c6c;
}

.calc-btn:active {
    background: #3a3a3a;
    filter: brightness(0.9);
}

/* Special buttons */
.calc-btn.function {
    background: #a5a5a5;
    color: #000000;
}

.calc-btn.function:hover {
    background: #d0d0d0;
}

.calc-btn.function:active {
    background: #8a8a8a;
}

.calc-btn.operator {
    background: #ff9f0a;
    color: #ffffff;
    font-size: 32px;
}

.calc-btn.operator:hover {
    background: #ffb340;
}

.calc-btn.operator:active {
    background: #cc7f08;
    filter: brightness(1.2);
}

.calc-btn.zero {
    grid-column: span 2;
    border-radius: 0;
}

.calc-btn.zero span {
    position: static;
    transform: none;
}

/* Resize Handles for Calculator */
.calculator-window .resize-handle {
    position: absolute;
    z-index: 10;
}

.calculator-window .resize-handle.top {
    top: 0;
    left: 10px;
    right: 10px;
    height: 5px;
    cursor: ns-resize;
}

.calculator-window .resize-handle.bottom {
    bottom: 0;
    left: 10px;
    right: 10px;
    height: 5px;
    cursor: ns-resize;
}

.calculator-window .resize-handle.left {
    left: 0;
    top: 10px;
    bottom: 10px;
    width: 5px;
    cursor: ew-resize;
}

.calculator-window .resize-handle.right {
    right: 0;
    top: 10px;
    bottom: 10px;
    width: 5px;
    cursor: ew-resize;
}

.calculator-window .resize-handle.top-right {
    top: 0;
    right: 0;
    width: 15px;
    height: 15px;
    cursor: nesw-resize;
}

.calculator-window .resize-handle.bottom-left {
    bottom: 0;
    left: 0;
    width: 15px;
    height: 15px;
    cursor: nesw-resize;
}

.calculator-window .resize-handle.bottom-right {
    bottom: 0;
    right: 0;
    width: 15px;
    height: 15px;
    cursor: nwse-resize;
}

/* Responsive scaling for calculator */
@media (max-width: 768px) {
    .calculator-window {
        width: 90vw;
        max-width: 360px;
        height: auto;
        min-height: 520px;
    }
    
    .calc-btn {
        font-size: 24px;
    }
    
    .calculator-display {
        font-size: 40px;
    }
}
