/* CSS O'zgaruvchilari (Dark/Light Mode) */
:root {
    --bg-color: #f3f4f6;
    --text-color: #1f2937;
    --card-bg: rgba(255, 255, 255, 0.7);
    --card-border: rgba(255, 255, 255, 0.3);
    --primary: #3b82f6;
    --primary-hover: #2563eb;
    --danger: #ef4444;
    --danger-hover: #dc2626;
    --success: #10b981;
    --input-bg: rgba(255, 255, 255, 0.9);
    --input-border: #d1d5db;
    --shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.1), 0 8px 10px -6px rgba(0, 0, 0, 0.1);
    --glass-shadow: 0 8px 32px 0 rgba(31, 38, 135, 0.07);
    --preview-text: rgba(31, 41, 55, 0.6);
    --border-color: #e5e7eb;
}

[data-theme="dark"] {
    --bg-color: #111827;
    --text-color: #f9fafb;
    --card-bg: rgba(31, 41, 55, 0.7);
    --card-border: rgba(255, 255, 255, 0.1);
    --primary: #60a5fa;
    --primary-hover: #3b82f6;
    --input-bg: rgba(17, 24, 39, 0.9);
    --input-border: #374151;
    --shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.5);
    --glass-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.3);
    --preview-text: rgba(249, 250, 251, 0.5);
    --border-color: #374151;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    transition: background-color 0.3s ease, color 0.3s ease, border-color 0.3s ease, box-shadow 0.3s ease;
}

body {
    font-family: 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
    background-color: var(--bg-color);
    color: var(--text-color);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 2rem 1rem;
}

.glass {
    background: var(--card-bg);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--card-border);
    box-shadow: var(--glass-shadow);
    border-radius: 1.5rem;
}

header {
    width: 100%;
    max-width: 800px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
}

h1 {
    font-size: 1.75rem;
    font-weight: 700;
}

.theme-toggle {
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    color: var(--text-color);
    font-size: 1.5rem;
    width: 3rem;
    height: 3rem;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: var(--shadow);
    outline: none;
}
.theme-toggle:focus {
    box-shadow: 0 0 0 3px var(--primary);
}

.main-container {
    width: 100%;
    max-width: 800px;
    padding: 2rem;
    margin-bottom: 2rem;
    position: relative;
    overflow: hidden;
}

.tabs {
    display: flex;
    gap: 1rem;
    margin-bottom: 2rem;
    border-bottom: 2px solid var(--border-color);
    padding-bottom: 1rem;
}

.tab-btn {
    background: transparent;
    border: none;
    color: var(--text-color);
    font-size: 1.1rem;
    font-weight: 600;
    padding: 0.5rem 1rem;
    cursor: pointer;
    border-radius: 0.5rem;
    opacity: 0.6;
}

.tab-btn.active {
    opacity: 1;
    background: var(--primary);
    color: #fff;
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.4);
}

.input-group {
    display: flex;
    gap: 1rem;
    align-items: center;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
}

.input-wrapper {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-width: 200px;
}

label {
    font-size: 0.9rem;
    margin-bottom: 0.5rem;
    font-weight: 500;
    opacity: 0.8;
}

input[type="number"] {
    width: 100%;
    padding: 0.75rem 1rem;
    border-radius: 0.75rem;
    border: 1px solid var(--input-border);
    background: var(--input-bg);
    color: var(--text-color);
    font-size: 1.25rem;
    outline: none;
}
input[type="number"]:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.3);
}

.percent-wrapper {
    flex: 0 0 100px;
}

.operation-toggle {
    display: flex;
    background: var(--input-bg);
    border: 1px solid var(--input-border);
    border-radius: 0.75rem;
    overflow: hidden;
    margin-top: 1.4rem;
}

.op-btn {
    background: transparent;
    border: none;
    color: var(--text-color);
    padding: 0.75rem 1.25rem;
    font-size: 1.25rem;
    font-weight: bold;
    cursor: pointer;
    outline: none;
}
.op-btn.active {
    background: var(--primary);
    color: white;
}

.live-preview {
    font-size: 0.95rem;
    color: var(--preview-text);
    margin-bottom: 1.5rem;
    padding: 1rem;
    background: rgba(0,0,0,0.03);
    border-radius: 0.75rem;
    border: 1px dashed var(--border-color);
    line-height: 1.6;
}

[data-theme="dark"] .live-preview {
    background: rgba(255,255,255,0.03);
}

.preview-val {
    font-weight: bold;
    color: var(--text-color);
}

.result-card {
    background: var(--primary);
    color: white;
    padding: 2rem;
    border-radius: 1rem;
    text-align: center;
    box-shadow: 0 10px 25px rgba(59, 130, 246, 0.5);
    transform: scale(0.9);
    opacity: 0;
    visibility: hidden;
    transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    margin-bottom: 1rem;
}

.result-card.show {
    transform: scale(1);
    opacity: 1;
    visibility: visible;
}

.result-title {
    font-size: 1.25rem;
    margin-bottom: 0.5rem;
    opacity: 0.9;
}

.result-value {
    font-size: 3rem;
    font-weight: 800;
}

.history-container {
    width: 100%;
    max-width: 800px;
    padding: 2rem;
}

.history-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
}

.btn-clear {
    background: var(--danger);
    color: white;
    border: none;
    padding: 0.5rem 1rem;
    border-radius: 0.5rem;
    cursor: pointer;
    font-weight: 600;
}
.btn-clear:hover {
    background: var(--danger-hover);
}

.table-responsive {
    width: 100%;
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
    text-align: left;
}

th, td {
    padding: 1rem;
    border-bottom: 1px solid var(--border-color);
    white-space: nowrap;
}

th {
    font-weight: 600;
    opacity: 0.8;
}

tbody tr:hover {
    background: rgba(0,0,0,0.02);
}
[data-theme="dark"] tbody tr:hover {
    background: rgba(255,255,255,0.02);
}

.op-badge {
    padding: 0.25rem 0.5rem;
    border-radius: 0.25rem;
    font-size: 0.85rem;
    font-weight: bold;
}
.op-plus {
    background: rgba(16, 185, 129, 0.2);
    color: var(--success);
}
.op-minus {
    background: rgba(239, 68, 68, 0.2);
    color: var(--danger);
}

@media (max-width: 768px) {
    .result-value { font-size: 2.25rem; }
    .op-btn { padding: 0.5rem 1rem; }
    .input-group { flex-direction: column; align-items: stretch; }
    .operation-toggle { margin-top: 0; align-self: flex-start; }
    .percent-wrapper { flex: none; }
}