/* Container */
#dz-calc-container {
    position: fixed;
    bottom: 20px;
    right: 20px; /* Default right */
    width: 400px;
    background: white;
    border: 1px solid var(--bs-border-color);
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.15);
    z-index: 10000;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
    opacity: 0;
    transform: translateY(20px) scale(0.95);
    pointer-events: none;
    max-height: 95vh;
}
#dz-calc-container.open {
    opacity: 1;
    transform: translateY(0) scale(1);
    pointer-events: all;
}

/* Header */
.dz-calc-header {
    background: #f8f9fa;
    padding: 12px 15px;
    border-bottom: 1px solid #e9ecef;
    display: flex;
    justify-content: space-between;
    align-items: center;
    user-select: none;
}
.dz-calc-title {
    font-weight: bold;
    color: #333;
    font-size: 16px;
    margin-right: 10px;
}
.dz-calc-controls i {
    cursor: pointer;
    padding: 5px;
    color: #6c757d;
    transition: 0.2s;
    font-size: 18px;
}
.dz-calc-controls i:hover { color: #000; }

#dz-btn-minimize {
    color: #dc3545;
    font-size: 22px;
    font-weight: bold;
}
#dz-btn-minimize:hover {
    color: #b02a37;
    background-color: rgba(220, 53, 69, 0.1);
    border-radius: 4px;
}

/* Grid & Views */
.dz-tools-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
    padding: 15px;
    overflow-y: auto;
    max-height: 500px;
}
.dz-tool-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 12px;
    border: 1px solid #eee;
    border-radius: 8px;
    background: #fff;
    cursor: pointer;
    transition: all 0.2s;
    text-align: center;
    height: 100%;
}
.dz-tool-btn:hover {
    transform: translateY(-3px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.08);
    border-color: #dee2e6;
}
.dz-tool-icon {
    font-size: 22px;
    margin-bottom: 8px;
}
.dz-tool-name {
    font-size: 11px;
    font-weight: bold;
    color: #555;
    line-height: 1.2;
}

/* Tool Views Common */
.dz-tool-view {
    padding: 15px;
    overflow-y: auto;
    max-height: 500px;
    background: #fff;
}
.dz-back-btn {
    cursor: pointer;
    margin-left: 10px;
    font-size: 18px;
    color: #007bff;
}

/* Form Elements */
.dz-tool-view .form-control, .dz-tool-view .form-select {
    font-size: 14px;
    padding: 8px 12px;
    margin-bottom: 12px;
    border-radius: 6px;
}
.dz-tool-view label {
    font-size: 13px;
    margin-bottom: 6px;
    display: block;
    font-weight: 600;
    color: #495057;
}
.dz-result-box {
    background: #f8f9fa;
    padding: 12px;
    border-radius: 6px;
    text-align: center;
    margin-top: 15px;
    font-weight: bold;
    font-size: 15px;
    border: 1px solid #e9ecef;
    color: #333;
    word-wrap: break-word;
}

/* Calculator */
.dz-calc-display {
    background-color: #212529;
    color: #fff;
    padding: 20px;
    text-align: right;
    font-family: 'Courier New', monospace;
    font-size: 26px;
    min-height: 80px;
    word-wrap: break-word;
    position: relative;
}
.dz-calc-history-preview {
    font-size: 13px;
    color: #adb5bd;
    min-height: 20px;
    margin-bottom: 5px;
}
.dz-calc-keys {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 1px;
    background-color: #dee2e6;
    border-top: 1px solid #dee2e6;
}
.dz-calc-keys.scientific {
    grid-template-columns: repeat(5, 1fr);
}
.dz-calc-btn {
    border: none;
    padding: 15px 0;
    font-size: 18px;
    background-color: #fff;
    cursor: pointer;
    transition: background-color 0.1s;
}
.dz-calc-btn:hover { background-color: #f8f9fa; }
.dz-calc-btn:active { background-color: #e9ecef; }
.dz-calc-btn.operator { color: #0d6efd; font-weight: bold; background: #f8f9fa; }
.dz-calc-btn.equal { background-color: #0d6efd; color: white; }
.dz-calc-btn.equal:hover { background-color: #0b5ed7; }
.dz-calc-btn.clear { color: #dc3545; }
.dz-calc-btn.sci-btn { background-color: #f8f9fa; font-size: 14px; color: #6610f2; }

/* FAB (Tools Button) */
#dz-calc-fab {
    position: fixed;
    bottom: 20px;
    right: 20px;
    width: 60px;
    height: 60px;
    background-color: #0d6efd;
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 15px rgba(13, 110, 253, 0.4);
    cursor: pointer;
    z-index: 9999;
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    opacity: 0;
    transform: scale(0) rotate(-180deg);
    font-size: 24px;
}
#dz-calc-fab.visible {
    opacity: 1;
    transform: scale(1) rotate(0deg);
}
#dz-calc-fab.is-open {
    opacity: 0;
    transform: scale(0);
    pointer-events: none;
    display: none !important;
}

/* Text inside FAB */
.dz-fab-text {
    display: none;
}

/* Scrollbar */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-thumb { background: #ced4da; border-radius: 3px; }
::-webkit-scrollbar-track { background: #f1f1f1; }

/* Dark Mode Support */
[data-bs-theme="dark"] #dz-calc-container {
    background-color: #242526;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5), 0 0 0 1px rgba(255,255,255,0.1);
    border-color: var(--bs-border-color);
}
[data-bs-theme="dark"] .dz-calc-header {
    background-color: #18191a;
    border-bottom-color: #3a3b3c;
}
[data-bs-theme="dark"] .dz-calc-title {
    color: #e4e6eb;
}
[data-bs-theme="dark"] .dz-calc-controls i {
    color: #b0b3b8;
}
[data-bs-theme="dark"] .dz-calc-controls i:hover {
    color: #e4e6eb;
}
[data-bs-theme="dark"] .dz-calc-keys {
    background-color: #3a3b3c;
}
[data-bs-theme="dark"] .dz-calc-btn {
    background-color: #242526;
    color: #e4e6eb;
}
[data-bs-theme="dark"] .dz-calc-btn:hover {
    background-color: #3a3b3c;
}
[data-bs-theme="dark"] .dz-calc-btn.operator {
    background-color: #18191a;
    color: #3b82f6;
}
[data-bs-theme="dark"] .dz-calc-btn.scientific {
    background-color: #18191a;
    color: #b0b3b8;
}
[data-bs-theme="dark"] .dz-calc-history {
    background-color: #242526;
    border-bottom-color: #3a3b3c;
}
[data-bs-theme="dark"] .dz-calc-history-item {
    border-bottom-color: #3a3b3c;
    color: #b0b3b8;
}
[data-bs-theme="dark"] .dz-calc-history-item:hover {
    background-color: #3a3b3c;
}
[data-bs-theme="dark"] .dz-tool-view {
    background-color: #242526;
    color: #e4e6eb;
}
[data-bs-theme="dark"] .dz-tool-btn {
    background-color: #18191a;
    border-color: #3a3b3c;
}
[data-bs-theme="dark"] .dz-tool-btn:hover {
    background-color: #3a3b3c;
    border-color: #4a4b4c;
}
[data-bs-theme="dark"] .dz-tool-name {
    color: #e4e6eb;
}
[data-bs-theme="dark"] .dz-tool-view label {
    color: #b0b3b8;
}
[data-bs-theme="dark"] .dz-tool-view .form-control, 
[data-bs-theme="dark"] .dz-tool-view .form-select {
    background-color: #18191a;
    border-color: #3a3b3c;
    color: #e4e6eb;
}
[data-bs-theme="dark"] .dz-result-box {
    background-color: #18191a;
    border-color: #3a3b3c;
    color: #e4e6eb;
}
[data-bs-theme="dark"] .list-group-item {
    background-color: #18191a;
    border-color: #3a3b3c;
    color: #e4e6eb;
}
[data-bs-theme="dark"] .list-group-item-action:hover {
    background-color: #3a3b3c;
}

/* Responsive */
@media (max-width: 480px) {
    #dz-calc-container {
        width: auto;
        left: var(--bs-gutter-x, 0.5rem);
        right: var(--bs-gutter-x, 0.5rem);
        bottom: 10px;
        max-height: 100vh;
    }
    .dz-tools-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}
