.calculator-page {
    min-height: 100vh;
    background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
    padding: 2rem 0;
    position: relative;
}

.calculator-page::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 300px;
    background: linear-gradient(135deg, rgba(37, 99, 235, 0.05) 0%, rgba(6, 182, 212, 0.05) 100%);
    z-index: 0;
}

.calculator-page > .container {
    position: relative;
    z-index: 1;
}

.calculator-header {
    margin-bottom: 3rem;
    padding: 2rem;
    background: white;
    border-radius: 1.5rem;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
}

[data-theme="dark"] .calculator-header {
    background: rgba(255, 255, 255, 0.05);
    backdrop-filter: blur(10px);
}

.calculator-header h1 {
    color: var(--primary);
    font-weight: 800;
}

/* Calculator Grid */
.calculator-grid {
    margin-bottom: 3rem;
}

.calc-card-item {
    background: white;
    border-radius: 1rem;
    padding: 1.5rem;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s ease;
    border: 2px solid var(--border-color);
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 140px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.calc-card-item:hover {
    transform: translateY(-5px);
    box-shadow: 0 8px 20px rgba(37, 99, 235, 0.2);
    border-color: var(--primary);
}

.calc-card-item.active {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    border-color: var(--primary);
    color: white;
    box-shadow: 0 8px 25px rgba(37, 99, 235, 0.4);
}

.calc-card-item.active .calc-icon {
    background: rgba(255, 255, 255, 0.2);
    color: white;
}

.calc-card-item.active h5,
.calc-card-item.active p {
    color: white !important;
}

.calc-icon {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary-light) 0%, var(--primary) 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 1rem;
    font-size: 1.5rem;
    color: var(--primary);
    transition: all 0.3s ease;
}

.calc-card-item:hover .calc-icon {
    transform: scale(1.1) rotate(5deg);
}

.calc-card-item h5 {
    font-size: 1rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
    color: var(--text-primary);
}

.calc-card-item p {
    font-size: 0.75rem;
    margin: 0;
    opacity: 0.8;
}

.calculator-card {
    background: white;
    border-radius: 1.5rem;
    padding: 2.5rem;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.1);
    margin-bottom: 2rem;
    border: 1px solid var(--border-color);
    animation: fadeInUp 0.5s ease;
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.calculator-title {
    color: var(--primary);
    font-weight: 700;
    margin-bottom: 2rem;
    padding-bottom: 1rem;
    border-bottom: 3px solid var(--primary-light);
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.calculator-title i {
    font-size: 1.5rem;
    background: linear-gradient(135deg, var(--primary) 0%, var(--secondary) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.form-group {
    margin-bottom: 1.5rem;
}

.form-group label {
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 0.75rem;
    display: block;
    font-size: 0.95rem;
}

.form-group label i {
    margin-left: 0.5rem;
    color: var(--primary);
}

.form-control,
.form-select {
    border: 2px solid var(--border-color);
    border-radius: 0.5rem;
    padding: 0.75rem 1rem;
    transition: all 0.3s ease;
}

.form-control:focus,
.form-select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 0.2rem rgba(37, 99, 235, 0.25);
}

.result-box {
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
    border-radius: 1.25rem;
    padding: 2.5rem;
    border: 2px solid var(--primary-light);
    box-shadow: inset 0 2px 8px rgba(0, 0, 0, 0.05);
    animation: fadeIn 0.5s ease;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.result-box h4 {
    color: var(--primary);
    font-weight: 700;
    margin-bottom: 1.5rem;
}

.result-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.25rem;
    margin-bottom: 1rem;
    background: white;
    border-radius: 0.75rem;
    border-right: 4px solid var(--primary);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
    transition: all 0.3s ease;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

.result-item:hover {
    transform: translateX(-5px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
}

.result-label {
    font-weight: 600;
    color: var(--text-secondary);
    flex-shrink: 1;
    min-width: 0;
    margin-left: 1rem;
}

.result-value {
    font-weight: 700;
    color: var(--primary);
    font-size: 1.25rem;
    text-align: left;
    direction: ltr;
    font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
    word-break: break-word;
    overflow-wrap: break-word;
    flex-shrink: 0;
    min-width: 0;
}

.result-value.large {
    font-size: 2.5rem;
    font-weight: 800;
    background: linear-gradient(135deg, var(--primary) 0%, var(--secondary) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    border: none;
    padding: 0.875rem 2.5rem;
    border-radius: 0.75rem;
    font-weight: 600;
    transition: all 0.3s ease;
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.3);
    position: relative;
    overflow: hidden;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
    user-select: none;
}

.btn-primary::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.3);
    transform: translate(-50%, -50%);
    transition: width 0.6s, height 0.6s;
}

.btn-primary:hover::before {
    width: 300px;
    height: 300px;
}

.btn-primary:hover {
    transform: translateY(-3px);
    box-shadow: 0 6px 20px rgba(37, 99, 235, 0.5);
}

.btn-primary:active {
    transform: translateY(-1px);
}

.progress {
    border-radius: 1rem;
    overflow: hidden;
}

.progress-bar {
    transition: width 1s ease;
}

.alert {
    border-radius: 0.5rem;
    border: none;
    padding: 1rem;
    font-weight: 500;
}

/* Dark Theme Support */
[data-theme="dark"] .calculator-page {
    background: linear-gradient(135deg, #0B1220 0%, #1a1f29 100%);
}

[data-theme="dark"] .calculator-card,
[data-theme="dark"] .calc-card-item {
    background: rgba(255, 255, 255, 0.05);
    backdrop-filter: blur(10px);
    border: 1px solid var(--border-color);
}

[data-theme="dark"] .calc-card-item.active {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
}

[data-theme="dark"] .calc-card-item:hover {
    background: rgba(255, 255, 255, 0.08);
}

[data-theme="dark"] .result-box {
    background: rgba(255, 255, 255, 0.03);
    border-color: var(--border-color);
}

[data-theme="dark"] .result-item {
    background: rgba(255, 255, 255, 0.05);
}

[data-theme="dark"] .form-control,
[data-theme="dark"] .form-select {
    background: rgba(255, 255, 255, 0.05);
    border-color: var(--border-color);
    color: var(--text-primary);
}

/* Smooth Scroll */
html {
    scroll-behavior: smooth;
}

/* Ensure results are visible */
.result-box[style*="display: none"] {
    display: none !important;
}

.result-box[style*="display: block"] {
    display: block !important;
}

/* Better visibility for results */
.result-box {
    animation: slideInUp 0.4s ease-out;
}

@keyframes slideInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Ensure buttons are clickable */
.btn-primary:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    pointer-events: none;
}

/* Better form input visibility */
.form-control:invalid,
.form-select:invalid {
    border-color: #dc3545;
}

.form-control:valid:not(:placeholder-shown),
.form-select:valid:not(:placeholder-shown) {
    border-color: #28a745;
}

/* Improve readability */
.calculator-card p {
    line-height: 1.7;
    color: var(--text-secondary);
}

.result-item .result-label {
    line-height: 1.6;
}

/* Loading Animation */
@keyframes pulse {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.5;
    }
}

.calculator-card.loading {
    position: relative;
    pointer-events: none;
}

.calculator-card.loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 40px;
    height: 40px;
    margin: -20px 0 0 -20px;
    border: 4px solid var(--primary-light);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Responsive */
@media (max-width: 992px) {
    .calculator-grid .row {
        gap: 1rem;
    }
    
    .calculator-card {
        padding: 2rem;
    }
    
    .result-box {
        padding: 2rem;
    }
}

@media (max-width: 768px) {
    .calculator-page {
        padding: 1rem 0;
    }
    
    .calculator-header {
        padding: 1.5rem;
        margin-bottom: 2rem;
    }
    
    .calculator-header h1 {
        font-size: 1.75rem;
    }
    
    .calc-card-item {
        min-height: 120px;
        padding: 1.25rem;
    }
    
    .calc-icon {
        width: 50px;
        height: 50px;
        font-size: 1.25rem;
    }
    
    .calc-card-item h5 {
        font-size: 0.9rem;
    }
    
    .calculator-card {
        padding: 1.5rem;
        border-radius: 1rem;
        margin-bottom: 1.5rem;
    }
    
    .calculator-title {
        font-size: 1.5rem;
        margin-bottom: 1.5rem;
        padding-bottom: 0.75rem;
    }
    
    .form-group {
        margin-bottom: 1.25rem;
    }
    
    .form-group label {
        font-size: 0.9rem;
        margin-bottom: 0.5rem;
    }
    
    .form-control,
    .form-select {
        padding: 0.875rem 1rem;
        font-size: 1rem;
        min-height: 48px; /* Better touch target */
    }
    
    .btn-primary {
        padding: 1rem 2rem;
        font-size: 1rem;
        min-height: 48px; /* Better touch target */
        width: 100%;
        margin-top: 0.5rem;
    }
    
    .result-box {
        padding: 1.5rem;
        border-radius: 1rem;
        margin-top: 1.5rem;
    }
    
    .result-box h4 {
        font-size: 1.25rem;
        margin-bottom: 1.25rem;
    }
    
    .result-item {
        padding: 1rem;
        flex-direction: column;
        align-items: flex-start;
        gap: 0.75rem;
        margin-bottom: 0.875rem;
        border-radius: 0.625rem;
    }
    
    .result-label {
        font-size: 0.95rem;
        width: 100%;
        margin-bottom: 0.25rem;
    }
    
    .result-value {
        font-size: 1.15rem;
        width: 100%;
        text-align: right;
        direction: rtl;
        word-break: break-word;
    }
    
    .result-value.large {
        font-size: 2rem;
        line-height: 1.2;
        margin: 0.5rem 0;
    }
    
    .alert {
        padding: 0.875rem;
        font-size: 0.9rem;
        margin-top: 1rem;
    }
    
    .progress {
        margin-top: 1rem;
        height: 25px;
    }
    
    .progress-bar {
        font-size: 0.85rem;
        display: flex;
        align-items: center;
        justify-content: center;
    }
}

@media (max-width: 480px) {
    .calculator-page {
        padding: 0.5rem 0;
    }
    
    .calculator-header {
        padding: 1.25rem;
        margin-bottom: 1.5rem;
    }
    
    .calculator-header h1 {
        font-size: 1.5rem;
    }
    
    .calculator-card {
        padding: 1.25rem;
        border-radius: 0.875rem;
    }
    
    .calculator-title {
        font-size: 1.25rem;
        margin-bottom: 1.25rem;
    }
    
    .form-group {
        margin-bottom: 1rem;
    }
    
    .form-control,
    .form-select {
        padding: 0.75rem;
        font-size: 0.95rem;
        min-height: 44px; /* iOS recommended touch target */
    }
    
    .btn-primary {
        padding: 0.875rem 1.5rem;
        font-size: 0.95rem;
        min-height: 44px; /* iOS recommended touch target */
    }
    
    .result-box {
        padding: 1.25rem;
    }
    
    .result-box h4 {
        font-size: 1.15rem;
        margin-bottom: 1rem;
    }
    
    .result-item {
        padding: 0.875rem;
        flex-direction: column;
        align-items: flex-start;
    }
    
    .result-label {
        margin-left: 0;
        margin-bottom: 0.5rem;
        width: 100%;
    }
    
    .result-value {
        font-size: 1.05rem;
        width: 100%;
        text-align: right;
    }
    
    .result-value.large {
        font-size: 1.75rem;
        text-align: center;
        width: 100%;
    }
    
    .alert {
        padding: 0.75rem;
        font-size: 0.85rem;
        line-height: 1.6;
    }
    
    /* Ensure text is readable */
    .result-box,
    .calculator-card {
        font-size: 0.95rem;
        line-height: 1.6;
    }
}

/* Print styles */
@media print {
    .calculator-page {
        background: white;
    }
    
    .btn-primary,
    .calculator-header {
        display: none;
    }
    
    .result-box {
        page-break-inside: avoid;
    }
}

