﻿/* ===================================
   Calculator.css - Calculator Styles
   ASP.NET MVC Calculator Application
   =================================== */

/* ===================================
   Calculator Section
   =================================== */
.calculator-section {
    padding: 2rem 0 5rem;
    min-height: 60vh;
}

/* ===================================
   Calculator Wrapper
   =================================== */
.calculator-wrapper {
    display: flex;
    flex-wrap: wrap;
    gap: 2rem;
    justify-content: center;
    align-items: flex-start;
    max-width: 1000px;
    margin: 0 auto;
}

/* ===================================
   Calculator Card
   =================================== */
.calculator-card {
    background: var(--bg-card);
    border-radius: var(--radius-2xl);
    box-shadow: var(--shadow-2xl);
    width: 100%;
    max-width: 600px;
    overflow: hidden;
    transition: transform var(--transition-normal), box-shadow var(--transition-normal);
}

.calculator-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 32px 64px rgba(0, 0, 0, 0.15);
}

/* ===================================
   Calculator Header
   =================================== */
.calc-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 1.25rem 1.5rem;
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    color: white;
}

.calc-header-icon {
    width: 44px;
    height: 44px;
    background: rgba(255, 255, 255, 0.15);
    border-radius: var(--radius-lg);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
}

.calc-header-text {
    flex: 1;
}

.calc-header-text h2 {
    font-size: 1.125rem;
    font-weight: 600;
    margin: 0;
}

.calc-header-text span {
    font-size: 0.8125rem;
    opacity: 0.8;
}

.calc-header-actions {
    display: flex;
    gap: 0.5rem;
}

.btn-calc-action {
    width: 32px;
    height: 32px;
    background: rgba(255, 255, 255, 0.1);
    border: none;
    border-radius: var(--radius-md);
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background var(--transition-fast);
}

.btn-calc-action:hover {
    background: rgba(255, 255, 255, 0.2);
}

/* ===================================
   Calculator Display
   =================================== */
.calc-display {
    background: linear-gradient(180deg, #f8fafc 0%, #f1f5f9 100%);
    padding: 1.5rem;
    min-height: 120px;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    border-bottom: 1px solid var(--border-color);
}

.display-expression {
    font-size: 1rem;
    color: var(--text-muted);
    text-align: right;
    min-height: 1.5rem;
    word-break: break-all;
    margin-bottom: 0.5rem;
    font-weight: 500;
}

.display-result {
    font-size: 2.75rem;
    font-weight: 700;
    color: var(--text-primary);
    text-align: right;
    word-break: break-all;
    line-height: 1.1;
    transition: all 0.2s ease;
    font-variant-numeric: tabular-nums;
}

.display-result.error {
    color: var(--danger);
    font-size: 1.25rem;
}

.display-result.calculating {
    animation: pulse 0.4s ease-in-out;
}

/* ===================================
   Calculator Buttons
   =================================== */
.calc-buttons {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 0.625rem;
    padding: 1.25rem;
    background: white;
}

.calc-btn {
    position: relative;
    border: none;
    border-radius: var(--radius-lg);
    font-size: 1.375rem;
    font-weight: 600;
    padding: 1.125rem;
    cursor: pointer;
    transition: all 0.15s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    -webkit-tap-highlight-color: transparent;
}

.calc-btn::before {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(180deg, rgba(255,255,255,0.2) 0%, rgba(255,255,255,0) 100%);
    opacity: 0;
    transition: opacity 0.15s ease;
}

.calc-btn:hover::before {
    opacity: 1;
}

.calc-btn:active {
    transform: scale(0.95);
}

.calc-btn:focus {
    outline: none;
}

.calc-btn:focus-visible {
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.4);
}

/* Number Buttons */
.btn-number {
    background: #f8fafc;
    color: var(--text-primary);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.04);
    border: 1px solid rgba(0, 0, 0, 0.04);
}

.btn-number:hover {
    background: #f1f5f9;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.08);
}

.btn-number:active {
    background: #e2e8f0;
}

/* Operator Buttons */
.btn-operator {
    background: linear-gradient(135deg, var(--primary-light) 0%, var(--primary) 100%);
    color: white;
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.3);
}

.btn-operator:hover {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    box-shadow: 0 6px 16px rgba(99, 102, 241, 0.4);
}

.btn-operator:active,
.btn-operator.active {
    background: var(--primary-dark);
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.2);
}

/* Function Buttons */
.btn-function {
    font-size: 1.125rem;
}

.btn-clear {
    background: linear-gradient(135deg, #f87171 0%, var(--danger) 100%);
    color: white;
    box-shadow: 0 4px 12px rgba(239, 68, 68, 0.3);
}

.btn-clear:hover {
    background: linear-gradient(135deg, var(--danger) 0%, #dc2626 100%);
    box-shadow: 0 6px 16px rgba(239, 68, 68, 0.4);
}

.btn-backspace {
    background: linear-gradient(135deg, #fef3c7 0%, #fde68a 100%);
    color: #92400e;
    box-shadow: 0 4px 12px rgba(245, 158, 11, 0.2);
}

.btn-backspace:hover {
    background: linear-gradient(135deg, #fde68a 0%, #fcd34d 100%);
}

.btn-backspace i {
    font-size: 1.125rem;
}

.btn-percent {
    background: linear-gradient(135deg, #e0e7ff 0%, #c7d2fe 100%);
    color: var(--primary-dark);
}

.btn-percent:hover {
    background: linear-gradient(135deg, #c7d2fe 0%, #a5b4fc 100%);
}

/* Decimal Button */
.btn-decimal {
    background: #e2e8f0;
    color: var(--text-primary);
    font-size: 1.5rem;
    font-weight: 700;
}

.btn-decimal:hover {
    background: #cbd5e1;
}

/* Equals Button */
.btn-equals {
    grid-column: span 2;
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    color: white;
    font-size: 2rem;
    box-shadow: 0 4px 16px rgba(99, 102, 241, 0.35);
}

.btn-equals:hover {
    background: linear-gradient(135deg, var(--primary-dark) 0%, #4338ca 100%);
    box-shadow: 0 6px 20px rgba(99, 102, 241, 0.45);
}

/* ===================================
   Calculator Footer
   =================================== */
.calc-footer {
    padding: 0.875rem 1.25rem;
    background: #f8fafc;
    border-top: 1px solid var(--border-color);
}

.keyboard-hint {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    font-size: 0.75rem;
    color: var(--text-muted);
}

.keyboard-hint i {
    font-size: 0.875rem;
}

/* ===================================
   History Card
   =================================== */
.history-card {
    background: var(--bg-card);
    border-radius: var(--radius-2xl);
    box-shadow: var(--shadow-xl);
    width: 100%;
    max-width: 360px;
    max-height: 580px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transition: transform var(--transition-normal), box-shadow var(--transition-normal);
}

.history-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 32px 64px rgba(0, 0, 0, 0.12);
}

/* History Header */
.history-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.25rem 1.5rem;
    background: linear-gradient(135deg, #f8fafc 0%, #f1f5f9 100%);
    border-bottom: 1px solid var(--border-color);
}

.history-title {
    display: flex;
    align-items: center;
    gap: 0.625rem;
}

.history-title i {
    font-size: 1.25rem;
    color: var(--primary);
}

.history-title h3 {
    font-size: 1.0625rem;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0;
}

.btn-clear-history {
    display: flex;
    align-items: center;
    gap: 0.375rem;
    background: none;
    border: 1px solid var(--border-color);
    color: var(--text-muted);
    padding: 0.5rem 0.75rem;
    border-radius: var(--radius-md);
    font-size: 0.8125rem;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.btn-clear-history:hover {
    background: #fef2f2;
    border-color: var(--danger);
    color: var(--danger);
}

/* History List */
.history-list {
    flex: 1;
    overflow-y: auto;
    padding: 1rem;
}

.history-list::-webkit-scrollbar {
    width: 6px;
}

.history-list::-webkit-scrollbar-track {
    background: #f1f5f9;
    border-radius: 3px;
}

.history-list::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 3px;
}

.history-list::-webkit-scrollbar-thumb:hover {
    background: #94a3b8;
}

/* History Item */
.history-item {
    background: #f8fafc;
    border-radius: var(--radius-lg);
    padding: 1rem;
    margin-bottom: 0.625rem;
    cursor: pointer;
    transition: all 0.2s ease;
    border: 1px solid transparent;
}

.history-item:hover {
    background: #f1f5f9;
    border-color: var(--primary-light);
    transform: translateX(4px);
}

.history-item:last-child {
    margin-bottom: 0;
}

.history-expression {
    font-size: 0.875rem;
    color: var(--text-secondary);
    margin-bottom: 0.375rem;
    word-break: break-all;
    font-weight: 500;
}

.history-result {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--primary);
    font-variant-numeric: tabular-nums;
}

/* History Empty */
.history-empty {
    text-align: center;
    padding: 3rem 1rem;
    color: var(--text-muted);
}

.history-empty-icon {
    font-size: 3rem;
    margin-bottom: 1rem;
    opacity: 0.3;
    color: var(--primary);
}

.history-empty p {
    font-size: 1rem;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 0.25rem;
}

.history-empty span {
    font-size: 0.875rem;
}

/* History Footer */
.history-footer {
    padding: 0.875rem 1rem;
    background: #f8fafc;
    border-top: 1px solid var(--border-color);
    text-align: center;
}

.history-footer small {
    font-size: 0.75rem;
    color: var(--text-muted);
}

/* ===================================
   Animations
   =================================== */
@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

@keyframes ripple {
    to {
        transform: scale(4);
        opacity: 0;
    }
}

.history-item.new {
    animation: slideIn 0.3s ease;
}

/* ===================================
   Responsive Design
   =================================== */
@media (max-width: 991.98px) {
    .calculator-wrapper {
        flex-direction: column;
        align-items: center;
    }

    .calculator-card,
    .history-card {
        max-width: 100%;
    }

    .history-card {
        max-height: 400px;
    }
}

@media (max-width: 575.98px) {
    .calculator-section {
        padding: 1rem 0 3rem;
    }

    .calculator-card {
        border-radius: var(--radius-xl);
    }

    .calc-header {
        padding: 1rem 1.25rem;
    }

    .calc-display {
        padding: 1.25rem;
        min-height: 100px;
    }

    .display-result {
        font-size: 2.25rem;
    }

    .calc-buttons {
        padding: 1rem;
        gap: 0.5rem;
    }

    .calc-btn {
        padding: 1rem;
        font-size: 1.25rem;
        border-radius: var(--radius-md);
    }

    .btn-equals {
        font-size: 1.5rem;
    }

    .calc-footer {
        display: none;
    }

    .history-card {
        border-radius: var(--radius-xl);
        max-height: 350px;
    }
}

@media (max-width: 400px) {
    .calc-buttons {
        gap: 0.375rem;
    }

    .calc-btn {
        padding: 0.875rem;
        font-size: 1.125rem;
    }
}

/* ===================================
   Dark Mode Styles
   =================================== */
[data-theme="dark"] .calculator-card,
.dark-mode .calculator-card {
    background: var(--bg-card);
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
}

[data-theme="dark"] .calculator-card:hover,
.dark-mode .calculator-card:hover {
    box-shadow: 0 32px 64px rgba(0, 0, 0, 0.4);
}

[data-theme="dark"] .calc-display,
.dark-mode .calc-display {
    background: #0f172a;
}

[data-theme="dark"] .calc-expression,
.dark-mode .calc-expression {
    color: #94a3b8;
}

[data-theme="dark"] .calc-result,
.dark-mode .calc-result {
    color: #f1f5f9;
}

[data-theme="dark"] .calc-body,
.dark-mode .calc-body {
    background: var(--bg-card);
}

[data-theme="dark"] .calc-btn,
.dark-mode .calc-btn {
    background: #334155;
    color: #f1f5f9;
    border-color: #475569;
}

[data-theme="dark"] .calc-btn:hover,
.dark-mode .calc-btn:hover {
    background: #475569;
}

[data-theme="dark"] .calc-btn:active,
.dark-mode .calc-btn:active {
    background: #1e293b;
}

[data-theme="dark"] .btn-number,
.dark-mode .btn-number {
    background: #1e293b;
}

[data-theme="dark"] .btn-number:hover,
.dark-mode .btn-number:hover {
    background: #334155;
}

[data-theme="dark"] .btn-operator,
.dark-mode .btn-operator {
    background: rgba(99, 102, 241, 0.2);
    color: #818cf8;
}

[data-theme="dark"] .btn-operator:hover,
.dark-mode .btn-operator:hover {
    background: rgba(99, 102, 241, 0.3);
}

[data-theme="dark"] .btn-function,
.dark-mode .btn-function {
    background: rgba(245, 158, 11, 0.15);
    color: #fbbf24;
}

[data-theme="dark"] .btn-function:hover,
.dark-mode .btn-function:hover {
    background: rgba(245, 158, 11, 0.25);
}

[data-theme="dark"] .btn-clear,
.dark-mode .btn-clear {
    background: rgba(239, 68, 68, 0.15);
    color: #f87171;
}

[data-theme="dark"] .btn-clear:hover,
.dark-mode .btn-clear:hover {
    background: rgba(239, 68, 68, 0.25);
}

[data-theme="dark"] .calc-footer,
.dark-mode .calc-footer {
    background: #0f172a;
    border-color: var(--border-color);
}

[data-theme="dark"] .footer-btn,
.dark-mode .footer-btn {
    color: #94a3b8;
}

[data-theme="dark"] .footer-btn:hover,
.dark-mode .footer-btn:hover {
    color: #f1f5f9;
    background: rgba(255, 255, 255, 0.1);
}

[data-theme="dark"] .history-card,
.dark-mode .history-card {
    background: var(--bg-card);
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
}

[data-theme="dark"] .history-header,
.dark-mode .history-header {
    background: linear-gradient(135deg, #312e81 0%, #1e1b4b 100%);
}

[data-theme="dark"] .history-body,
.dark-mode .history-body {
    background: var(--bg-card);
}

[data-theme="dark"] .history-item,
.dark-mode .history-item {
    background: #1e293b;
    border-color: transparent;
}

[data-theme="dark"] .history-item:hover,
.dark-mode .history-item:hover {
    background: #334155;
}

[data-theme="dark"] .history-expression,
.dark-mode .history-expression {
    color: #94a3b8;
}

[data-theme="dark"] .history-result,
.dark-mode .history-result {
    color: #f1f5f9;
}

[data-theme="dark"] .history-empty,
.dark-mode .history-empty {
    color: #64748b;
}

/* ===================================
   Print Styles
   =================================== */
@media print {
    .calculator-section {
        padding: 0;
    }

    .calculator-card,
    .history-card {
        box-shadow: none;
        border: 1px solid var(--border-color);
    }

    .calc-footer,
    .btn-clear-history {
        display: none;
    }
}