/* Calculator Widget Styles - Enhanced & Optimized */

/* ========================================= */
/* Main Widget Container                     */
/* ========================================= */

.calculator-widget {
    position: fixed;
    bottom: 30px;
    right: 30px;
    z-index: 1050;
}

/* ========================================= */
/* Toggle Button - Optimized Size           */
/* ========================================= */

.calculator-toggle {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: #FFFFFF;
    border: 3px solid #FFB700;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.1);
    color: #FFB700;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Pulse animation - stops after 10 seconds */
@keyframes pulse {
    0% {
        box-shadow: 0 4px 16px rgba(0, 0, 0, 0.1);
    }
    50% {
        box-shadow: 0 4px 24px rgba(255, 183, 0, 0.25);
    }
    100% {
        box-shadow: 0 4px 16px rgba(0, 0, 0, 0.1);
    }
}

.calculator-toggle {
    animation: pulse 2s ease-in-out 5;
}

/* Respect user's motion preferences */
@media (prefers-reduced-motion: reduce) {
    .calculator-toggle {
        animation: none;
    }
}

@keyframes bounce {
    0%, 20%, 50%, 80%, 100% {
        transform: translateY(0);
    }
    40% {
        transform: translateY(-20px);
    }
    60% {
        transform: translateY(-10px);
    }
}

.calculator-toggle i {
    font-size: 1.5rem;
    line-height: 1;
    font-weight: 600;
}

.calculator-toggle:hover {
    transform: translateY(-3px) scale(1.08);
    box-shadow: 0 6px 24px rgba(255, 183, 0, 0.3);
    background: #FFB700;
    color: #FFFFFF;
    border-color: #FFB700;
}

/* Floating label */
.calculator-toggle::after {
    content: 'Hesapla';
    position: absolute;
    bottom: -28px;
    left: 50%;
    transform: translateX(-50%);
    background: #333;
    color: white;
    padding: 4px 10px;
    border-radius: 4px;
    font-size: 0.8rem;
    white-space: nowrap;
    opacity: 0;
    transition: opacity 0.3s;
    pointer-events: none;
}

.calculator-toggle:hover::after {
    opacity: 1;
}

.calculator-toggle.active {
    background: #FFB700;
    color: #FFFFFF;
    border-color: #FFB700;
    box-shadow: 0 4px 20px rgba(255, 183, 0, 0.3);
    animation: none;
    transform: rotate(180deg);
}

/* ========================================= */
/* Calculator Panel - Enhanced               */
/* ========================================= */

.calculator-panel {
    position: absolute;
    bottom: 75px;
    right: 0;
    width: 360px;
    background: #FFFFFF !important;
    border-radius: 20px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.15);
    border: 2px solid #FFB700;
    display: none !important;
    overflow: hidden;
    animation: slideUp 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

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

.calculator-panel.show {
    display: block !important;
}

/* ========================================= */
/* Loading States                            */
/* ========================================= */

.calculator-loading {
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    background: #FFFFFF !important;
}

.skeleton {
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
    border-radius: 8px;
}

@keyframes shimmer {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

.skeleton-select {
    height: 48px;
    width: 100%;
}

.skeleton-input {
    height: 56px;
    width: 100%;
}

.skeleton-result {
    height: 80px;
    width: 100%;
}

/* ========================================= */
/* Error & Empty States                      */
/* ========================================= */

.calculator-error,
.calculator-empty {
    padding: 2rem 1.5rem;
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
    background: #FFFFFF !important;
}

.calculator-error i,
.calculator-empty i {
    font-size: 3rem;
    opacity: 0.3;
}

.calculator-error i {
    color: #dc3545;
}

.calculator-empty i {
    color: #FFB700;
}

.calculator-error p,
.calculator-empty p {
    margin: 0;
    color: #6c757d;
    font-size: 0.95rem;
}

.calculator-error .btn-retry {
    margin-top: 0.5rem;
}

/* ========================================= */
/* Header                                    */
/* ========================================= */

.calculator-header {
    background: linear-gradient(135deg, #FFB700, #FF9500);
    color: white;
    padding: 1.25rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: none;
    position: relative;
}

.calculator-header::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(90deg, transparent, #FFFFFF, transparent);
    opacity: 0.3;
}

.calculator-header h5 {
    font-size: 1.125rem;
    font-weight: 700;
    margin: 0;
    color: white;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.1);
}

.calculator-header .btn-close {
    width: 32px;
    height: 32px;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 1;
    background: rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    transition: all 0.2s;
    border: none !important;
    outline: none !important;
    box-shadow: none !important;
    cursor: pointer;
    position: relative;
}

.calculator-header .btn-close::before {
    content: '×';
    font-size: 28px;
    line-height: 1;
    color: white;
    font-weight: 300;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
}

.calculator-header .btn-close:hover {
    background: rgba(255, 255, 255, 0.4);
    transform: rotate(90deg);
}

/* ========================================= */
/* Body                                      */
/* ========================================= */

.calculator-body {
    padding: 1.5rem;
    background: #FFFFFF !important;
}

/* ========================================= */
/* Type Selector                             */
/* ========================================= */

.calc-type-selector {
    display: flex;
    gap: 6px;
    background: #F8F9FA;
    padding: 6px;
    border-radius: 12px;
    border: 2px solid #FFB700;
    box-shadow: 0 2px 8px rgba(255, 183, 0, 0.1);
}

.calc-type-btn {
    flex: 1;
    border: none;
    background: transparent;
    color: #6c757d;
    padding: 0.75rem 0.5rem;
    border-radius: 8px;
    font-size: 0.875rem;
    font-weight: 500;
    transition: all 0.2s ease;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.25rem;
    cursor: pointer;
}

.calc-type-btn:hover {
    background: rgba(255, 215, 0, 0.1);
    color: #2d3748;
}

.calc-type-btn.active {
    background: linear-gradient(135deg, #FFB700, #FF9500);
    color: white;
    box-shadow: 0 2px 8px rgba(255, 183, 0, 0.3);
    font-weight: 700;
    transform: translateY(-1px);
}

.calc-type-btn i {
    font-size: 1.25rem;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.calc-section {
    display: none;
}

.calc-section.active {
    display: block;
}

/* ========================================= */
/* Input Styling                             */
/* ========================================= */

.input-group {
    background: #f8f9fa;
    border: 2px solid transparent;
    border-radius: 12px;
    overflow: hidden;
    transition: all 0.2s ease;
}

.input-group:focus-within {
    border-color: #FFB700;
    background: #FFFFFF;
    box-shadow: 0 0 0 4px rgba(255, 215, 0, 0.1);
}

.calc-input {
    background: transparent;
    border: none;
    font-size: 1rem;
    padding: 0.75rem 1rem;
}

.calc-select {
    background: transparent;
    border: none;
    border-left: 1px solid #dee2e6;
    max-width: 120px;
    font-size: 0.875rem;
    padding: 0.75rem 1rem;
    font-weight: 500;
}

.form-control:focus,
.form-select:focus {
    border-color: transparent;
    box-shadow: none;
    outline: none;
}

/* ========================================= */
/* Result Display                            */
/* ========================================= */

.result-display {
    display: flex;
    flex-direction: column;
    gap: 0;
    background: linear-gradient(135deg, #FFFBF5 0%, #FFF4E6 100%);
    border: 1px solid rgba(255, 183, 0, 0.1);
    border-radius: 12px;
    padding: 1rem;
    margin-top: 1rem;
    position: relative;
    overflow: hidden;
}

.result-display::before {
    content: '';
    position: absolute;
    top: 0;
    right: 0;
    width: 100px;
    height: 100px;
    background: linear-gradient(135deg, #FFB700, #FF9500);
    opacity: 0.05;
    border-radius: 0 12px 0 100%;
}

.result-item {
    display: flex;
    flex-direction: row;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    padding: 0.5rem 0;
    position: relative;
    z-index: 1;
    min-height: 32px;
    border-bottom: 1px solid rgba(0, 0, 0, 0.05);
}

.result-item:last-child {
    border-bottom: none;
}

.result-label {
    color: #6c757d;
    font-size: 0.875rem;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.result-value {
    font-weight: 700;
    font-size: 1.125rem;
    color: #2d3748;
    white-space: nowrap;
    text-overflow: ellipsis;
    max-width: 60%;
    display: inline-block;
    text-align: right;
    overflow: hidden;
}

.result-value.text-primary {
    color: #E67E00 !important;
    font-weight: 800;
}

.result-value.small {
    font-size: 0.875rem;
}

/* Long number handling for crypto */
.result-value.long-number {
    font-size: 0.85rem;
}

/* ========================================= */
/* Currency Rates                            */
/* ========================================= */

.currency-rates {
    background: linear-gradient(135deg, #FFFBF5 0%, #FFF4E6 100%);
    border: 1px solid rgba(255, 183, 0, 0.1);
    border-radius: 12px;
    padding: 0.75rem;
    margin-top: 1rem;
}

.currency-rates small {
    font-weight: 600;
    color: #6c757d;
    display: block;
    margin-bottom: 0.5rem;
    text-transform: uppercase;
    font-size: 0.75rem;
    letter-spacing: 0.5px;
}

.currency-rates > div > div {
    padding: 0.25rem 0;
    transition: all 0.2s ease;
}

.currency-rates > div > div:hover {
    background: rgba(255, 215, 0, 0.1);
    border-radius: 6px;
    padding: 0.25rem 0.5rem;
    margin: 0 -0.5rem;
}

/* ========================================= */
/* Quick Access Buttons                      */
/* ========================================= */

.quick-access {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 6px;
}

.quick-access .quick-btn {
    min-width: 0;
    padding: 6px 4px;
    background: #FFFFFF;
    border: 2px solid #dee2e6;
    color: #6c757d;
    border-radius: 20px;
    font-weight: 600;
    font-size: 0.8rem;
    transition: all 0.2s ease;
    white-space: nowrap;
}

.quick-access .quick-btn:hover {
    transform: translateY(-2px);
    border-color: #FFB700;
    background: linear-gradient(135deg, #FFFBF5 0%, #FFF4E6 100%);
    color: #2d3748;
    box-shadow: 0 2px 8px rgba(255, 183, 0, 0.15);
}

/* ========================================= */
/* Swap Button                               */
/* ========================================= */

.swap-btn {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: 2px solid #dee2e6;
    background: #FFFFFF;
    color: #6c757d;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    cursor: pointer;
    font-size: 1rem;
}

.swap-btn:hover {
    border-color: #FFB700;
    color: #E67E00;
    transform: rotate(180deg);
    box-shadow: 0 2px 8px rgba(255, 183, 0, 0.2);
}

/* ========================================= */
/* Footer                                    */
/* ========================================= */

.calculator-footer {
    background: #f8f9fa;
    padding: 1rem;
    text-align: center;
    border-top: 1px solid #dee2e6;
}

/* ========================================= */
/* Mobile Responsive                         */
/* ========================================= */

@media (max-width: 576px) {
    .calculator-widget {
        bottom: 20px;
        right: 20px;
        z-index: 9999;
    }

    .calculator-toggle {
        width: 52px;
        height: 52px;
        border-width: 2px;
        box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    }

    .calculator-toggle i {
        font-size: 1.35rem;
    }

    .calculator-toggle::after {
        display: none;
    }

    /* Full screen modal on mobile */
    .calculator-panel {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        width: 100%;
        height: 100%;
        max-height: 100vh;
        border-radius: 0;
        border: none;
        display: none !important;
        flex-direction: column;
        animation: slideUpMobile 0.3s ease;
        z-index: 10000;
        pointer-events: none;
    }

    @keyframes slideUpMobile {
        from {
            transform: translateY(100%);
        }
        to {
            transform: translateY(0);
        }
    }

    .calculator-panel.show {
        display: flex !important;
        pointer-events: auto;
    }

    .calculator-header {
        padding: 1rem;
        flex-shrink: 0;
        position: sticky;
        top: 0;
        z-index: 10;
        /* Safe area for notched phones */
        padding-top: max(1rem, env(safe-area-inset-top));
    }

    .calculator-header h5 {
        font-size: 1rem;
    }

    .calculator-body {
        flex: 1;
        overflow-y: auto;
        padding: 1rem;
        -webkit-overflow-scrolling: touch;
        /* Safe area for bottom navigation */
        padding-bottom: max(1rem, env(safe-area-inset-bottom));
    }

    .calc-type-selector {
        padding: 4px;
        gap: 4px;
        margin-bottom: 1rem;
    }

    .calc-type-btn {
        padding: 0.75rem 0.5rem;
        font-size: 0.875rem;
    }

    .calc-type-btn i {
        font-size: 1.25rem;
        margin-bottom: 0.25rem;
    }

    .calc-type-btn span {
        display: block;
        font-size: 0.75rem;
    }

    /* Input improvements for mobile */
    .input-group {
        margin-bottom: 1rem;
    }

    .calc-input,
    .calc-select {
        font-size: 16px !important; /* Prevent zoom on iOS */
        padding: 0.75rem;
        height: auto;
    }

    .calc-select {
        max-width: 140px;
    }

    /* Result display mobile optimization */
    .result-display {
        padding: 1rem;
        margin: 1rem 0;
    }

    .result-item {
        padding: 0.75rem 0;
        min-height: 28px;
    }

    .result-label {
        font-size: 0.875rem;
        flex-shrink: 0;
    }

    .result-value {
        font-size: 1rem;
        max-width: 55%;
    }

    /* Crypto mobile specific */
    #cryptoCalc .result-value {
        font-size: 0.875rem;
    }

    #cryptoCalc .result-value.long-number {
        font-size: 0.75rem;
    }

    /* Currency rates mobile */
    .currency-rates {
        padding: 0.75rem;
        margin-top: 1rem;
    }

    .currency-rates small {
        font-size: 0.75rem;
    }

    /* Quick access mobile optimization */
    .quick-access {
        display: flex;
        gap: 0.5rem;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        padding: 0.5rem 0;
        margin: 0 -0.5rem;
    }

    .quick-access .quick-btn {
        flex: 0 0 auto;
        min-width: 60px;
        padding: 0.5rem;
        font-size: 0.875rem;
        white-space: nowrap;
    }

    /* Swap button mobile */
    .swap-btn {
        width: 44px;
        height: 44px;
        font-size: 1.125rem;
    }

    /* Footer mobile */
    .calculator-footer {
        padding: 0.75rem;
        flex-shrink: 0;
        position: sticky;
        bottom: 0;
        background: white;
        border-top: 2px solid #f0f0f0;
        z-index: 10;
        /* Safe area for home indicator */
        padding-bottom: max(0.75rem, env(safe-area-inset-bottom));
    }

    .calculator-footer small {
        font-size: 0.75rem;
    }
}

/* Very small devices */
@media (max-width: 374px) {
    .calculator-toggle {
        width: 48px;
        height: 48px;
    }

    .calculator-toggle i {
        font-size: 1.2rem;
    }

    .calc-type-btn {
        padding: 0.5rem 0.25rem;
    }

    .calc-type-btn span {
        font-size: 0.65rem;
    }

    .quick-access .quick-btn {
        min-width: 50px;
        padding: 0.375rem;
        font-size: 0.75rem;
    }
}

/* Landscape orientation fixes */
@media (max-height: 500px) and (orientation: landscape) {
    .calculator-panel {
        max-height: 100vh;
    }

    .calculator-header {
        padding: 0.5rem 1rem;
    }

    .calculator-body {
        padding: 0.75rem;
    }

    .calc-type-selector {
        margin-bottom: 0.5rem;
    }

    .result-display {
        padding: 0.5rem;
        margin: 0.5rem 0;
    }
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .calculator-toggle {
        border-width: 4px;
    }

    .calc-type-btn.active {
        outline: 2px solid #000;
        outline-offset: 2px;
    }
}

/* Force light theme - Calculator always uses light colors for better readability */
@media (prefers-color-scheme: dark) {
    .calculator-panel,
    .calculator-body,
    .result-display,
    .currency-rates,
    .input-group,
    .calc-type-selector {
        background: #FFFFFF !important;
    }

    .result-value,
    .calc-input,
    .calc-select,
    .result-label,
    .calc-type-btn {
        color: #2d3748 !important;
    }

    .calculator-panel {
        border-color: #FFB700 !important;
    }
}
