/* =========================================
   CALCULATOR MODULE STYLES
   ========================================= */

/* --- 1. View Toggles (Tabs) --- */
.mode-toggle {
    background: #0f172a;
    padding: 4px;
    border-radius: 8px;
    display: inline-flex;
    border: 1px solid var(--border);
    margin-bottom: 20px;
    position: relative;
    z-index: 5;
}

.mode-btn {
    background: transparent;
    color: var(--text-muted);
    border: none;
    padding: 8px 24px;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 600;
    font-size: 14px;
    transition: all 0.2s ease;
}

.mode-btn:hover { color: white; }

.mode-btn.active {
    background: var(--primary);
    color: white;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

/* --- 2. TVM Dashboard (Top Inputs) --- */
.tvm-dashboard {
    display: flex;
    justify-content: space-between; /* Distribute evenly */
    gap: 8px;
    background: var(--bg-panel);
    padding: 15px;
    border-radius: 12px;
    margin-bottom: 20px;
    border: 1px solid var(--border);
    width: 100%;
    box-sizing: border-box;
}

.tvm-group {
    display: flex;
    flex-direction: column;
    flex: 1; /* Equal width for all 5 inputs */
    min-width: 0; /* Prevent flex overflow */
}

.tvm-group label {
    font-size: 11px;
    color: var(--text-muted);
    margin-bottom: 6px;
    font-weight: bold;
    text-align: center;
    white-space: nowrap;
}

.tvm-group input {
    background: #0f172a;
    border: 1px solid var(--border);
    color: var(--primary);
    text-align: center;
    padding: 8px 4px;
    border-radius: 4px;
    width: 100%;
    box-sizing: border-box;
    font-family: 'JetBrains Mono', monospace;
    font-weight: bold;
    font-size: 13px;
}

/* Small CPT buttons under inputs */
.btn-mini {
    background: #334155;
    color: white;
    border: none;
    padding: 4px;
    border-radius: 4px;
    font-size: 10px;
    margin-top: 6px;
    cursor: pointer;
    width: 100%;
    font-weight: 600;
    transition: background 0.2s;
}
.btn-mini:hover { background: var(--primary); }

/* --- 3. Settings Bar --- */
.settings-bar {
    display: flex;
    justify-content: center;
    gap: 20px;
    background: rgba(0,0,0,0.2);
    padding: 10px;
    border-radius: 8px;
    margin-bottom: 15px;
    border: 1px solid var(--border);
}

.setting-group {
    display: flex;
    align-items: center;
    gap: 8px;
}

.setting-group label {
    font-size: 12px;
    color: var(--text-muted);
    font-weight: bold;
}

.setting-group input {
    background: #0f172a;
    border: 1px solid var(--border);
    color: #f1f5f9;
    padding: 4px 8px;
    border-radius: 4px;
    text-align: center;
    font-size: 12px;
    width: 50px;
}

.toggle-btn {
    background: #334155;
    color: white;
    border: 1px solid var(--border);
    border-radius: 4px;
    padding: 4px 12px;
    font-size: 11px;
    cursor: pointer;
    font-weight: bold;
    min-width: 50px;
}
.toggle-btn.active { background: var(--accent); border-color: var(--accent); }

/* --- 4. Calculator Keypad --- */
.calc-body {
    background: #1e293b;
    padding: 20px;
    border-radius: 20px;
    display: inline-block;
    border: 1px solid var(--border);
    width: 100%;
    max-width: 420px; /* Constrain width for readability */
    box-sizing: border-box;
    position: relative;
}

.calc-screen {
    width: 100%;
    background: #0f172a;
    color: #f1f5f9;
    font-family: 'JetBrains Mono', monospace;
    font-size: 28px;
    text-align: right;
    padding: 15px;
    margin-bottom: 20px;
    border: 1px solid var(--border);
    border-radius: 8px;
    box-sizing: border-box;
    outline: none;
}

.calc-grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 10px;
}

.calc-grid button {
    padding: 12px 0;
    border: none;
    border-radius: 8px;
    font-weight: 600;
    font-size: 16px;
    cursor: pointer;
    position: relative;
    box-shadow: 0 2px 0 rgba(0,0,0,0.2);
    font-family: 'Inter', sans-serif;
}
.calc-grid button:active { transform: translateY(2px); box-shadow: none; }

/* Button Colors */
.btn-num { background: #334155; color: white; }
.btn-num:hover { background: #475569; }

.btn-op { background: #0f172a; color: var(--primary); font-size: 18px; }
.btn-op:hover { background: #1e293b; }

/* Function Keys (N, I/Y, etc) */
.btn-func {
    background: #1e293b;
    color: var(--accent);
    border: 1px solid var(--border);
    font-size: 14px;
}
.btn-func:hover { border-color: var(--accent); }

.btn-submit { background: var(--primary); color: white; }
.btn-submit:hover { background: var(--primary-hover); }

.btn-danger { background: rgba(239, 68, 68, 0.2); color: var(--danger); }
.btn-danger:hover { background: rgba(239, 68, 68, 0.3); }

/* --- 5. Notification Toast (Graceful Errors) --- */
.toast-container {
    position: absolute;
    top: -60px; /* Hidden initially */
    left: 50%;
    transform: translateX(-50%);
    width: 90%;
    transition: top 0.3s ease-out;
    z-index: 100;
}

.toast-message {
    background: #ef4444;
    color: white;
    padding: 12px;
    border-radius: 8px;
    font-size: 13px;
    text-align: center;
    box-shadow: 0 4px 12px rgba(0,0,0,0.3);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.toast-message.info { background: var(--primary); }
.toast-message.success { background: var(--success); }

/* Show Toast */
.calc-body.has-toast .toast-container { top: 10px; }

/* --- 6. Analysis Styles --- */
.panel-grid { display: flex; justify-content: center; width: 100%; }
.panel { background: var(--bg-panel); border: 1px solid var(--border); padding: 25px; border-radius: 12px; width: 100%; max-width: 500px; text-align: left; }
.row-group { display: flex; gap: 20px; margin-bottom: 15px; }
.form-group { flex: 1; }
.form-group label { display: block; font-size: 12px; color: var(--text-muted); margin-bottom: 5px; font-weight: bold; }
.form-group input { width: 100%; background: #0f172a; border: 1px solid var(--border); padding: 10px; color: white; border-radius: 6px; box-sizing: border-box; }
.amort-table { width: 100%; border-collapse: collapse; font-size: 13px; margin-top: 20px; }
.amort-table th, .amort-table td { border-bottom: 1px solid var(--border); padding: 10px; text-align: right; color: var(--text-main); }

/* --- Info Icon --- */
.info-icon {
    display: inline-flex; align-items: center; justify-content: center;
    width: 14px; height: 14px; background: var(--accent); color: white;
    border-radius: 50%; font-size: 10px; font-weight: bold; cursor: help;
    margin-left: 6px; position: relative;
}
.info-icon:hover::after {
    content: attr(data-tooltip);
    position: absolute; bottom: 130%; left: 50%; transform: translateX(-50%);
    background: #334155; color: #fff; padding: 8px; border-radius: 6px;
    font-size: 12px; width: 180px; text-align: left; z-index: 200;
    pointer-events: none; border: 1px solid var(--border);
}

/* Calculator Specific CSS */

/* --- 1. Dashboard (Top Inputs) --- */
.tvm-dashboard {
    display: flex; justify-content: center; gap: 10px; flex-wrap: wrap;
    background: var(--bg-panel); padding: 20px; border-radius: 12px; 
    margin-bottom: 25px; border: 1px solid var(--border); 
    width: 100%; box-sizing: border-box;
    position: relative; z-index: 10;
}

.tvm-group { display: flex; flex-direction: column; width: 80px; position: relative; }
.tvm-group label { 
    font-size: 11px; color: var(--text-muted); 
    margin-bottom: 5px; font-weight: bold; 
    display: flex; align-items: center; justify-content: center; 
}
.tvm-group input {
    background: #0f172a; border: 1px solid var(--border); color: var(--primary);
    text-align: center; padding: 6px; border-radius: 4px; width: 100%; box-sizing: border-box;
    font-family: 'JetBrains Mono', monospace; font-weight: bold;
    transition: background-color 0.3s;
}
.tvm-group input.updated { background-color: rgba(16, 185, 129, 0.2); border-color: var(--success); }

.btn-mini { 
    background: #334155; color: white; border: none; padding: 4px; 
    border-radius: 4px; font-size: 10px; margin-top: 5px; 
    cursor: pointer; width: 100%; font-weight: 600; 
}
.btn-mini:hover { background: var(--primary); }

/* --- 2. Keypad Layout --- */
.calc-body { 
    background: #1e293b; padding: 20px; border-radius: 20px; 
    display: inline-block; border: 1px solid var(--border); 
    max-width: 100%; box-sizing: border-box;
    position: relative; 
    overflow: hidden; /* Critical: Hides the toast when it slides up */
}

.calc-screen {
    width: 100%; background: #0f172a; color: #f1f5f9; 
    font-family: 'JetBrains Mono', monospace; font-size: 24px; 
    text-align: right; padding: 15px; margin-bottom: 15px; 
    border: 1px solid var(--border); border-radius: 8px; 
    box-sizing: border-box; outline: none;
}

.calc-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; }
.calc-grid button { 
    padding: 15px 0; border: none; border-radius: 8px; 
    font-weight: 600; font-size: 16px; cursor: pointer; 
    font-family: 'Inter', sans-serif; position: relative;
}
.calc-grid button:active { transform: scale(0.95); }

.btn-num { background: #334155; color: white; }
.btn-op { background: #0f172a; color: var(--primary); }
.btn-submit { background: var(--primary); color: white; }
.btn-danger { background: #451a1a; color: var(--danger); }

/* --- 3. Notification Toast (Graceful Errors) --- */
.toast-container {
    position: absolute;
    top: -100px; /* Hidden above the container */
    left: 0; right: 0;
    padding: 0 20px;
    transition: top 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 100;
    pointer-events: none; /* Let clicks pass through when hidden */
}

.toast-message {
    background: #ef4444; color: white; padding: 10px;
    border-radius: 8px; font-size: 12px; text-align: center;
    box-shadow: 0 4px 12px rgba(0,0,0,0.5); border: 1px solid rgba(255,255,255,0.1);
}
.toast-message.info { background: var(--primary); }
.toast-message.success { background: var(--success); }

/* Class added by JS to slide it down */
.calc-body.has-toast .toast-container { top: 20px; }

/* --- 4. Settings & Panels --- */
.settings-bar {
    display: flex; justify-content: center; gap: 15px;
    background: rgba(0,0,0,0.2); padding: 10px; border-radius: 8px; 
    margin-bottom: 15px; border: 1px solid var(--border);
}
.setting-group { display: flex; flex-direction: column; width: 60px; }
.setting-group label { font-size: 10px; color: var(--text-muted); margin-bottom: 4px; text-align: center; }
.setting-group input { 
    background: #0f172a; border: 1px solid var(--border); color: #f1f5f9; 
    padding: 5px; border-radius: 4px; text-align: center; font-size: 12px; width: 100%; 
}
.toggle-btn { background: #334155; color: white; border: 1px solid var(--border); border-radius: 4px; padding: 5px; font-size: 11px; cursor: pointer; width: 100%; }
.toggle-btn.active { background: var(--accent); border-color: var(--accent); }

.mode-toggle { background: #0f172a; padding: 4px; border-radius: 8px; display: inline-flex; border: 1px solid var(--border); margin-bottom: 20px; }
.mode-btn { background: transparent; color: var(--text-muted); border: none; padding: 8px 20px; border-radius: 6px; cursor: pointer; font-weight: 600; font-size: 14px; }
.mode-btn.active { background: var(--primary) !important; color: white !important; }
.center-margin { margin: 0 auto 25px auto; display: flex; justify-content: center; }

.panel-grid { display: flex; flex-wrap: wrap; justify-content: center; gap: 20px; width: 100%; }
.panel { background: var(--bg-panel); border: 1px solid var(--border); padding: 25px; border-radius: 12px; width: 100%; max-width: 500px; }
.row-group { display: flex; gap: 20px; justify-content: center; margin-bottom: 15px; }
.form-group { flex: 1; }
.amort-table { width: 100%; border-collapse: collapse; font-size: 13px; margin-top: 20px; }
.amort-table th, .amort-table td { border-bottom: 1px solid var(--border); padding: 10px; text-align: right; color: var(--text-main); }

/* Info Icon */
.info-icon { display: inline-flex; align-items: center; justify-content: center; width: 16px; height: 16px; background: var(--accent); color: white; border-radius: 50%; font-size: 11px; font-weight: bold; cursor: help; margin-left: 5px; position: relative; }
.info-icon:hover::after { content: attr(data-tooltip); position: absolute; bottom: 135%; left: 50%; transform: translateX(-50%); background: #334155; color: #f1f5f9; padding: 10px; border-radius: 6px; font-size: 12px; white-space: pre-wrap; width: 180px; z-index: 1000; text-align: left; border: 1px solid var(--border); }