/* Card-Based Calculator Collection - Option 3 */
:root {
    --primary: #4B0082;
    --secondary: #3CB371;
    --accent: #FF4500;
    --background: #F5F5F5;
    --text: #333333;
    --shadow: rgba(0, 0, 0, 0.08);
    
    /* Card Colors */
    --card-basic: #FFD1DC;
    --card-scientific: #D1FFD1;
    --card-mortgage: #D1D1FF;
    --card-investment: #FFFFD1;
    --card-conversion: #FFD1FF;
    --card-bmi: #D1FFFF;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

body {
    background-color: var(--background);
    color: var(--text);
    min-height: 100vh;
    padding: 20px;
}

header {
    width: 100%;
    text-align: center;
    padding: 20px 0;
    background: linear-gradient(to right, var(--primary), var(--secondary), var(--accent));
    color: white;
    border-radius: 15px;
    margin-bottom: 30px;
    box-shadow: 0 5px 15px var(--shadow);
    position: relative;
    overflow: hidden;
}

header::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(45deg, 
        rgba(255,255,255,0.1) 25%, 
        transparent 25%, 
        transparent 50%, 
        rgba(255,255,255,0.1) 50%, 
        rgba(255,255,255,0.1) 75%, 
        transparent 75%, 
        transparent);
    background-size: 30px 30px;
    animation: headerAnimation 3s linear infinite;
}

@keyframes headerAnimation {
    0% { background-position: 0 0; }
    100% { background-position: 60px 30px; }
}

.calculator-dashboard {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 20px;
    margin-bottom: 80px;
}

.calculator-card {
    background-color: white;
    border-radius: 15px;
    overflow: hidden;
    box-shadow: 0 8px 20px var(--shadow);
    transition: all 0.3s ease;
    position: relative;
}

.calculator-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 12px 30px var(--shadow);
}

#basic-card {
    background-color: var(--card-basic);
}

#scientific-card {
    background-color: var(--card-scientific);
}

#mortgage-card {
    background-color: var(--card-mortgage);
}

#investment-card {
    background-color: var(--card-investment);
}

#conversion-card {
    background-color: var(--card-conversion);
}

#bmi-card {
    background-color: var(--card-bmi);
}

.card-header {
    padding: 15px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid rgba(0, 0, 0, 0.1);
}

.card-header h2 {
    font-size: 1.3rem;
    color: var(--primary);
}

.expand-btn {
    background: none;
    border: none;
    color: var(--primary);
    cursor: pointer;
    font-size: 1.2rem;
    transition: all 0.3s;
}

.expand-btn:hover {
    transform: scale(1.2);
}

.card-content {
    padding: 20px;
    background-color: rgba(255, 255, 255, 0.7);
}

.calculator-display {
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    color: white;
    padding: 15px;
    text-align: right;
    border-radius: 10px;
    margin-bottom: 15px;
    box-shadow: 0 4px 10px var(--shadow);
}

.previous-operand {
    font-size: 1rem;
    opacity: 0.8;
    height: 20px;
    overflow: hidden;
}

.current-operand {
    font-size: 2rem;
    margin-top: 5px;
    word-wrap: break-word;
    word-break: break-all;
}

.calculator-keypad {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    grid-gap: 10px;
}

.scientific-keypad {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    grid-gap: 8px;
}

button {
    padding: 12px;
    font-size: 1rem;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    background-color: white;
    color: var(--text);
    transition: all 0.2s;
    box-shadow: 0 2px 5px var(--shadow);
}

button:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 10px var(--shadow);
}

button:active {
    transform: translateY(0);
}

.number {
    background-color: white;
}

.operator {
    background-color: var(--secondary);
    color: white;
    font-weight: bold;
}

.function {
    background-color: rgba(255, 255, 255, 0.8);
    font-size: 0.9rem;
}

.equals {
    background-color: var(--accent);
    color: white;
    font-weight: bold;
}

.clear, .delete {
    background-color: rgba(255, 69, 0, 0.1);
    color: var(--accent);
}

.zero {
    grid-column: span 2;
}

.input-group {
    margin-bottom: 15px;
}

.unit-input {
    display: flex;
    gap: 10px;
}

.unit-input input {
    flex: 1;
}

label {
    display: block;
    margin-bottom: 5px;
    font-size: 0.9rem;
    color: var(--primary);
    font-weight: 500;
}

input, select {
    width: 100%;
    padding: 10px;
    border: 1px solid #ddd;
    border-radius: 8px;
    font-size: 1rem;
    background-color: rgba(255, 255, 255, 0.8);
}

input:focus, select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 2px rgba(75, 0, 130, 0.1);
}

.calculate-btn {
    width: 100%;
    background: linear-gradient(to right, var(--primary), var(--secondary));
    color: white;
    padding: 12px;
    border-radius: 8px;
    font-size: 1rem;
    cursor: pointer;
    transition: all 0.3s;
    border: none;
    margin-top: 10px;
}

.calculate-btn:hover {
    background: linear-gradient(to right, #3B0062, #2CA361);
}

.result {
    background-color: rgba(255, 255, 255, 0.8);
    padding: 15px;
    border-radius: 8px;
    margin-top: 15px;
    font-size: 1rem;
    min-height: 50px;
    white-space: pre-line;
    border-left: 3px solid var(--primary);
}

.history-btn {
    position: fixed;
    bottom: 30px;
    right: 30px;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary), var(--accent));
    color: white;
    display: flex;
    justify-content: center;
    align-items: center;
    box-shadow: 0 5px 15px var(--shadow);
    z-index: 100;
    transition: all 0.3s;
}

.history-btn:hover {
    transform: scale(1.1) rotate(15deg);
}

.history-panel {
    position: fixed;
    top: 0;
    right: -350px;
    width: 350px;
    height: 100vh;
    background-color: white;
    box-shadow: -5px 0 15px var(--shadow);
    z-index: 200;
    transition: right 0.3s ease;
    display: flex;
    flex-direction: column;
}

.history-panel.active {
    right: 0;
}

.history-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px;
    background: linear-gradient(to right, var(--primary), var(--accent));
    color: white;
}

.close-history {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: white;
    box-shadow: none;
}

.close-history:hover {
    transform: scale(1.2);
    box-shadow: none;
}

.history-content {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
}

#history-list {
    list-style: none;
}

#history-list li {
    padding: 12px;
    border-bottom: 1px solid #eee;
    transition: background-color 0.3s;
}

#history-list li:hover {
    background-color: #f9f9f9;
}

.clear-history {
    margin: 20px;
    padding: 12px;
    background-color: #f5f5f5;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s;
}

.clear-history:hover {
    background-color: #e0e0e0;
}

/* Expanded Card State */
.calculator-card.expanded {
    grid-column: 1 / -1;
    transform: scale(1.02);
    z-index: 10;
}

.calculator-card.expanded .card-content {
    max-height: none;
}

.calculator-card.expanded .expand-btn i {
    transform: rotate(180deg);
}

/* Mobile Responsiveness */
@media (max-width: 768px) {
    .calculator-dashboard {
        grid-template-columns: 1fr;
    }
    
    button {
        padding: 10px;
        font-size: 0.9rem;
    }
    
    .history-panel {
        width: 100%;
        right: -100%;
    }
    
    .history-btn {
        bottom: 20px;
        right: 20px;
        width: 50px;
        height: 50px;
    }
    
    .card-content {
        padding: 15px;
    }
}

/* Animations */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes bounce {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-5px); }
}

.calculator-card {
    animation: fadeIn 0.5s ease;
}

.calculate-btn:hover {
    animation: bounce 1s infinite;
}
