/* calculator.css */
.advanced-calculator {
    position: fixed;
    right: 20px;
    bottom: 20px;
    width: 380px;
    background: white;
    border-radius: 10px;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.12);
    z-index: 10000;
    display: none;
    flex-direction: column;
    max-height: 90vh;
    overflow: hidden;
    border: 1px solid #d0d0d0;
}

.advanced-calculator.visible {
    display: flex;
}

.calc-header {
    background: linear-gradient(135deg, #5a99d4 0%, #4a7bb0 100%);
    color: white;
    padding: 10px 16px;
    cursor: move;
    display: flex;
    justify-content: space-between;
    align-items: center;
    user-select: none;
}

.calc-title {
    font-weight: 500;
    font-size: 14px;
    letter-spacing: 0.2px;
}

.calc-close-btn {
    background: rgba(255, 255, 255, 0.12);
    border: none;
    color: white;
    width: 26px;
    height: 26px;
    border-radius: 5px;
    cursor: pointer;
    font-size: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.calc-close-btn:hover {
    background: rgba(255, 255, 255, 0.22);
}

.calc-tabs {
    display: flex;
    background: #f5f6f7;
    border-bottom: 1px solid #e0e0e0;
}

.calc-tab {
    flex: 1;
    padding: 11px;
    background: transparent;
    border: none;
    cursor: pointer;
    font-weight: 500;
    font-size: 13px;
    color: #5a5a5a;
    transition: all 0.2s;
    position: relative;
}

.calc-tab:hover {
    background: rgba(90, 153, 212, 0.06);
    color: #4a7bb0;
}

.calc-tab.active {
    background: white;
    color: #4a7bb0;
}

.calc-tab.active::after {
    content: '';
    position: absolute;
    bottom: -1px;
    left: 0;
    right: 0;
    height: 2px;
    background: #5a99d4;
}

.calc-content {
    padding: 16px;
    overflow-y: auto;
    overflow-x: hidden;
    background: white;
    display: none;
}

.calc-content.active {
    display: block;
}

.calc-display {
    background: linear-gradient(135deg, #3a3f47 0%, #2d3238 100%);
    color: #b8f7d4;
    padding: 18px 16px;
    font-size: 26px;
    font-family: 'Segoe UI', 'Roboto', monospace;
    font-weight: 500;
    text-align: right;
    border-radius: 8px;
    margin-bottom: 12px;
    min-height: 58px;
    word-break: break-all;
    box-shadow: inset 0 2px 6px rgba(0, 0, 0, 0.15);
    letter-spacing: 0.5px;
    border: none;
    outline: none;
    width: 100%;
    box-sizing: border-box;
}

.calc-display:focus {
    box-shadow: inset 0 2px 6px rgba(0, 0, 0, 0.15), 0 0 0 2px rgba(90, 153, 212, 0.3);
}

.calc-history {
    background: #f9fafb;
    border: 1px solid #e5e7eb;
    border-radius: 7px;
    padding: 10px;
    margin-bottom: 12px;
    max-height: 110px;
    overflow-y: auto;
    overflow-x: hidden;
    font-size: 12px;
}

.history-item {
    padding: 5px 8px;
    margin-bottom: 4px;
    background: white;
    border-radius: 4px;
    color: #4a4a4a;
    font-family: 'Courier New', monospace;
    border-left: 2px solid #5a99d4;
    font-size: 11px;
    word-wrap: break-word;
}

.history-item:last-child {
    margin-bottom: 0;
}

.history-empty {
    color: #9ca3af;
    text-align: center;
    font-style: italic;
    padding: 8px;
}

.calc-buttons {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 7px;
}

.calc-btn {
    padding: 15px 8px;
    border: 1px solid #d5d5d5;
    background: #fafafa;
    border-radius: 7px;
    cursor: pointer;
    font-size: 15px;
    font-weight: 500;
    transition: all 0.15s;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.calc-btn:hover {
    background: #f0f0f0;
    transform: translateY(-1px);
    box-shadow: 0 3px 6px rgba(0, 0, 0, 0.08);
}

.calc-btn:active {
    transform: translateY(0);
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.08);
}

.calc-btn-zero {
    grid-column: span 1;
}

.calc-btn-equals {
    grid-column: span 1;
}

.calc-btn-operator {
    background: #e8f2fb;
    color: #2c5f8d;
    border-color: #c5ddef;
}

.calc-btn-operator:hover {
    background: #d6e9f7;
}

.calc-btn-danger {
    background: #fdeced;
    color: #b83c3c;
    border-color: #f5c6c6;
}

.calc-btn-danger:hover {
    background: #fbd9da;
}

.calc-btn-warning {
    background: #fef7ec;
    color: #c77a2d;
    border-color: #f5ddc0;
    font-size: 13px;
}

.calc-btn-warning:hover {
    background: #fdefd6;
}

.calc-btn-special {
    background: #ecf6ed;
    color: #3d7a42;
    font-weight: 600;
    font-size: 12px;
    border-color: #c6e5c8;
}

.calc-btn-special:hover {
    background: #daeedd;
}

.calc-btn-percent {
    background: #f6ecf8;
    color: #7a3d8f;
    border-color: #e0c6e5;
}

.calc-btn-percent:hover {
    background: #eddaf0;
}

.calc-btn-round {
    background: #ecf6ed;
    color: #3d7a42;
    font-weight: 600;
    font-size: 12px;
    border-color: #c6e5c8;
}

.calc-btn-round:hover {
    background: #fff5d6;
}

/* Конвертер */
.converter-block {
    margin-bottom: 15px;
}

.converter-block label {
    display: block;
    margin-bottom: 7px;
    font-weight: 500;
    color: #4a4a4a;
    font-size: 13px;
}

.converter-select,
.converter-input {
    width: 100%;
    padding: 12px 14px;
    border: 1px solid #d5d5d5;
    border-radius: 7px;
    font-size: 15px;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    transition: all 0.2s;
    background: #fafafa;
}

.converter-select:focus,
.converter-input:focus {
    outline: none;
    border-color: #5a99d4;
    background: white;
    box-shadow: 0 0 0 3px rgba(90, 153, 212, 0.08);
}

.converter-arrow {
    text-align: center;
    font-size: 26px;
    color: #5a99d4;
    margin: 10px 0;
    font-weight: 500;
}

.converter-rate-info {
    margin-top: 14px;
    padding: 12px;
    background: #e8f2fb;
    border-radius: 7px;
    font-size: 13px;
    color: #2c5f8d;
    border-left: 3px solid #5a99d4;
}

.converter-error {
    margin-top: 14px;
    padding: 12px;
    background: #fdeced;
    border-radius: 7px;
    font-size: 13px;
    color: #b83c3c;
    border-left: 3px solid #d84545;
}

/* Кнопка открытия */
.calc-toggle-btn {
    position: fixed;
    right: 20px;
    bottom: 20px;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: linear-gradient(135deg, #5a99d4 0%, #4a7bb0 100%);
    color: white;
    border: none;
    font-size: 30px;
    cursor: pointer;
    box-shadow: 0 5px 18px rgba(90, 153, 212, 0.35);
    z-index: 9999;
    transition: all 0.25s;
}

.calc-toggle-btn:hover {
    transform: scale(1.08);
    box-shadow: 0 6px 22px rgba(90, 153, 212, 0.42);
}

.calc-toggle-btn:active {
    transform: scale(1.02);
}

.advanced-calculator.visible~.calc-toggle-btn {
    display: none;
}

/* Скроллбар */
.calc-history::-webkit-scrollbar,
.calc-content::-webkit-scrollbar {
    width: 5px;
}

.calc-history::-webkit-scrollbar-track,
.calc-content::-webkit-scrollbar-track {
    background: #f0f0f0;
    border-radius: 10px;
}

.calc-history::-webkit-scrollbar-thumb,
.calc-content::-webkit-scrollbar-thumb {
    background: #b0b0b0;
    border-radius: 10px;
}

.calc-history::-webkit-scrollbar-thumb:hover,
.calc-content::-webkit-scrollbar-thumb:hover {
    background: #909090;
}

.converter-arrow {
    text-align: center;
    font-size: 26px;
    color: #5a99d4;
    margin: 10px 0;
    font-weight: 500;
    transition: all 0.2s;
}

.converter-arrow:hover {
    color: #4a7bb0;
    transform: scale(1.2);
}

.converter-arrow:active {
    transform: scale(1.1);
}

.history-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 6px;
    padding: 0 2px;
}

.history-title {
    font-size: 12px;
    font-weight: 600;
    color: #5a5a5a;
}

.history-clear-btn {
    background: #fef7ec;
    border: 1px solid #f5ddc0;
    color: #c77a2d;
    padding: 4px 10px;
    border-radius: 5px;
    font-size: 11px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.history-clear-btn:hover {
    background: #fdefd6;
    transform: translateY(-1px);
}

.history-clear-btn:active {
    transform: translateY(0);
}

/* Стили для вкладки курсов валют */
.rates-display {
    background: #f8f9fa;
    border-radius: 8px;
    padding: 10px;
}

.rate-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 15px;
    background: white;
    border-radius: 6px;

    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    transition: transform 0.2s;
}

.rate-item:hover {
    transform: translateX(3px);
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.15);
}

.rate-item:last-child {
    margin-bottom: 0;
}

.rate-currency {
    font-weight: 600;
    font-size: 14px;
    color: #2c3e50;
    display: flex;
    align-items: center;
}

.rate-currency::before {
    content: '';
    display: inline-block;
    width: 8px;
    height: 8px;
    background: #4CAF50;
    border-radius: 50%;
    margin-right: 10px;
}

.rate-value {
    font-size: 15px;
    font-weight: 500;
    color: #27ae60;
}

/* Стили для ошибочных/дефолтных курсов */
.rate-value.rate-error {
    color: #f44336 !important;
    font-weight: 600;
}

.rate-item:has(.rate-error) .rate-currency::before {
    background: #f44336;
    animation: pulse-error 2s infinite;
}

@keyframes pulse-error {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0.5;
    }
}

.rates-header h3 {
    color: #2c3e50;
    border-bottom: 2px solid #3498db;
    padding-bottom: 8px;
}

.historical-rates-section {
    border-top: 1px solid #e0e0e0;
    padding-top: 20px;
}

.historical-rates-section h4 {
    color: #34495e;
    font-weight: 600;
}

.date-selector label {
    font-weight: 500;
    color: #555;
}

.date-selector input[type="date"] {
    border: 1px solid #ddd;
    border-radius: 6px;
    padding: 8px;
    font-size: 14px;
}

#dateRateInfo {
    padding: 8px 12px;
    border-radius: 4px;
}

/* Адаптация кнопок калькулятора для 4 валют в ряд */
.calc-buttons {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
}

/* Кнопка с нулем занимает 2 колонки */
.calc-btn-zero {
    grid-column: span 2;
}

.calc-btn-equals {
    padding: 15px 8px;
    border: 1px solid #d5d5d5;
    background: #7c92ff;
    border-radius: 7px;
    cursor: pointer;
    font-size: 15px;
    font-weight: 500;
    transition: all 0.15s;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Стили для сообщений об ошибках в конвертере */
.converter-error {
    color: #f44336;
    background: #ffebee;
    padding: 10px;
    border-radius: 6px;
    border-left: 3px solid #f44336;
    font-size: 12px;
}