:root {
    --primary: #f15524;
    --primary-hover: #d9491d;
    --text-dark: #222222;
    --text-gray: #666666;
    --bg-body: #f8f9fa;
    --bg-card: #ffffff;
    --border-color: #eaebec;
    --success: #2e7d32;
    --error: #c62828;
    --panel-bg: #f8f9fa;
}

* { margin: 0; padding: 0; box-sizing: border-box; font-family: 'Inter', sans-serif; }
body { background-color: var(--bg-body); color: var(--text-dark); -webkit-font-smoothing: antialiased; }

nav { background: var(--bg-card); border-bottom: 1px solid var(--border-color); padding: 15px 40px; display: flex; align-items: center; justify-content: space-between; }
.logo { font-size: 1.4rem; font-weight: 700; color: var(--primary); display: flex; align-items: center; gap: 10px; cursor: pointer; }

.hero { text-align: center; padding: 60px 20px 30px; }
.hero h1 { font-size: 2.8rem; font-weight: 700; margin-bottom: 10px; }
.hero p { color: var(--text-gray); font-size: 1.1rem; font-weight: 300; }

.container { max-width: 1200px; margin: 0 auto; padding: 20px; }
.converter-box { background: var(--bg-card); border-radius: 12px; box-shadow: 0 10px 40px rgba(0,0,0,0.06); padding: 40px; border: 1px solid var(--border-color); margin-bottom: 40px; }

.btn-select { background: var(--primary); color: white; font-size: 1.2rem; font-weight: 500; padding: 18px 40px; border: none; border-radius: 6px; cursor: pointer; display: flex; align-items: center; gap: 10px; box-shadow: 0 4px 14px rgba(241, 85, 36, 0.4); margin: 0 auto; transition: 0.2s; }
.btn-select:hover { background: var(--primary-hover); }

.config-row { display: none; width: 100%; background: #fcfcfc; border: 1px solid var(--border-color); border-radius: 8px; padding: 25px; margin-top: 20px; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 20px; }
.file-tag { font-size: 1.1rem; font-weight: 600; display: flex; align-items: center; gap: 10px; }
.ext-badge { background: #e2e8f0; padding: 4px 8px; border-radius: 4px; font-size: 0.8rem; text-transform: uppercase; }

.cc-select { padding: 10px 15px; font-size: 1rem; border: 1px solid #ccc; border-radius: 6px; outline: none; background: white; cursor: pointer; }
.btn-convert { background: var(--text-dark); color: white; border: none; padding: 12px 35px; border-radius: 6px; font-size: 1.1rem; font-weight: 600; cursor: pointer; }

.result-area { display: flex; justify-content: space-between; align-items: center; background: #f0fdf4; border: 1px solid #bbf7d0; padding: 25px; border-radius: 8px; }
.btn-download { background: var(--success); color: white; padding: 12px 25px; border-radius: 6px; text-decoration: none; font-weight: 600; display: flex; align-items: center; gap: 8px; }

/* Format Matrix Styles */
.format-matrix { margin-top: 60px; }
.matrix-title { text-align: center; font-size: 2rem; margin-bottom: 30px; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 20px; }
.format-card { background: var(--bg-card); border: 1px solid var(--border-color); padding: 20px; border-radius: 8px; transition: 0.2s; }
.format-card:hover { box-shadow: 0 4px 12px rgba(0,0,0,0.05); border-color: #ccc; }
.format-icon { color: var(--primary); font-size: 1.5rem; margin-bottom: 12px; }
.format-card h3 { font-size: 1.1rem; margin-bottom: 8px; text-transform: capitalize; }
.format-card p { font-size: 0.85rem; color: var(--text-gray); line-height: 1.4; }

.system-bar { background: var(--text-dark); color: white; padding: 12px; border-radius: 8px; display: flex; justify-content: space-around; font-size: 0.8rem; margin-top: 30px; }
.sys-ok { color: #69f0ae; } .sys-fail { color: #ff5252; }

.loader-overlay { position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(255,255,255,0.95); display: none; flex-direction: column; justify-content: center; align-items: center; z-index: 1000; }
.spinner { border: 4px solid #f3f3f3; border-top: 4px solid var(--primary); border-radius: 50%; width: 50px; height: 50px; animation: spin 1s linear infinite; }
@keyframes spin { 0% { transform: rotate(0deg); } 100% { transform: rotate(360deg); } }
.loader-text { margin-top: 15px; font-weight: 600; font-size: 1.2rem; }

.portal-btn { background: none; border: 1px solid var(--border-color); padding: 8px 15px; border-radius: 6px; cursor: pointer; color: var(--text-gray); }

/* Live Preview Editor */
.editor-container {
    display: none;
    margin-top: 20px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    overflow: hidden;
}
.editor-header {
    background: var(--panel-bg);
    padding: 15px 20px;
    border-bottom: 1px solid var(--border-color);
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 8px;
}
.editor-content {
    display: flex;
    flex-wrap: wrap;
    gap: 20px;
    padding: 20px;
}
.image-preview-container {
    flex: 1;
    min-width: 300px;
}
.controls-container {
    flex: 1;
    min-width: 300px;
}
.image-preview {
    width: 100%;
    max-height: 400px;
    object-fit: contain;
    border: 1px solid #ddd;
    border-radius: 4px;
    background: 
        linear-gradient(45deg, #ddd 25%, transparent 25%), 
        linear-gradient(-45deg, #ddd 25%, transparent 25%),
        linear-gradient(45deg, transparent 75%, #ddd 75%),
        linear-gradient(-45deg, transparent 75%, #ddd 75%);
    background-size: 20px 20px;
    background-position: 0 0, 0 10px, 10px -10px, -10px 0px;
}
.control-group {
    margin-bottom: 20px;
}
.control-label {
    display: block;
    margin-bottom: 8px;
    font-weight: 500;
}
.control-row {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 10px;
}
.color-picker {
    width: 50px;
    height: 30px;
    border: 1px solid #ccc;
    border-radius: 4px;
    cursor: pointer;
}
.hex-input {
    flex: 1;
    padding: 5px 10px;
    border: 1px solid #ccc;
    border-radius: 4px;
}
.slider-control {
    width: 100%;
}
.value-display {
    width: 50px;
    text-align: center;
    font-size: 0.9rem;
}
.checkbox-control {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
}
.checkbox-control input {
    width: auto;
}
.btn-apply {
    background: var(--primary);
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 500;
    width: 100%;
    margin-top: 10px;
}
.btn-apply:hover {
    background: var(--primary-hover);
}
.loading-indicator {
    display: none;
    text-align: center;
    padding: 10px;
    color: var(--primary);
}
.loading-spinner {
    border: 2px solid #f3f3f3;
    border-top: 2px solid var(--primary);
    border-radius: 50%;
    width: 20px;
    height: 20px;
    animation: spin 1s linear infinite;
    display: inline-block;
    margin-right: 10px;
}
.currency-selector {
    margin: 15px 0;
    padding: 10px;
    background: #f8f9fa;
    border-radius: 6px;
}

.currency-selector label {
    display: block;
    margin-bottom: 5px;
    font-weight: 500;
}

.currency-selector select {
    width: 100%;
    padding: 8px;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    background: white;
}

.pricing-card .btn-convert {
    margin: 15px 0;
}

.preview-error {
    color: var(--error);
    padding: 10px;
    background: #ffebee;
    border-radius: 4px;
    margin-top: 10px;
    display: none;
}
.instructions {
    font-size: 0.85rem;
    color: var(--text-gray);
    margin-top: 5px;
    line-height: 1.4;
}

/* --- Dashboard & API Additions --- */
.dashboard-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 20px; margin-top: 20px; }
.dash-card { background: var(--bg-card); border: 1px solid var(--border-color); padding: 30px; border-radius: 12px; box-shadow: 0 4px 12px rgba(0,0,0,0.03); }
.dash-card.full-width { grid-column: 1 / -1; }
.dash-card h3 { font-size: 2rem; margin: 10px 0 5px; color: var(--text-dark); }
.dash-card p { color: var(--text-gray); font-size: 0.95rem; }
.stat-icon { font-size: 2rem; margin-bottom: 15px; }
.text-success { color: var(--success); }
.text-error { color: var(--error); }
.text-primary { color: var(--primary); }

.btn-btc { background: #f7931a; color: white; border: none; padding: 12px 25px; border-radius: 6px; font-size: 1rem; font-weight: 600; cursor: pointer; display: flex; align-items: center; gap: 10px; box-shadow: 0 4px 14px rgba(247, 147, 26, 0.4); transition: 0.2s; }
.btn-btc:hover { background: #e08316; }

.nav-links { display: flex; align-items: center; gap: 15px; }
.api-key-display { background: #e6fffa; border: 1px solid #bbf7d0; border-radius: 6px; padding: 15px; margin-top: 15px; font-family: monospace; font-size: 1.1rem; color: var(--success); word-break: break-all; }
.key-label { display: block; margin-bottom: 5px; font-weight: 600; color: var(--text-dark); }
.free-tier-note { text-align: center; margin: 20px auto; padding: 15px; max-width: 600px; background: #fff9db; border: 1px solid #ffd97d; border-radius: 6px; color: #74510a; }

/* Dashboard History Table Styling */
.table-responsive { overflow-x: auto; margin-top: 15px; }
.history-table { width: 100%; border-collapse: collapse; text-align: left; }
.history-table th, .history-table td { padding: 12px 15px; border-bottom: 1px solid var(--border-color); font-size: 0.95rem; }
.history-table th { background: #f8f9fa; font-weight: 600; color: var(--text-gray); font-size: 0.9rem; text-transform: uppercase; }
.history-table tr:hover { background: #fafafa; }
.engine-badge { background: #e2e8f0; padding: 4px 10px; border-radius: 12px; font-size: 0.8rem; color: #475569; font-weight: 600; }
.status-badge { padding: 4px 10px; border-radius: 4px; font-size: 0.85rem; font-weight: 600; display: inline-flex; align-items: center; gap: 5px; }
.status-badge.success { background: #dcfce7; color: #166534; }
.status-badge.fail { background: #fee2e2; color: #991b1b; }

/* Dashboard API Syntax Highlighting Tabs */
.api-tabs { display: flex; gap: 8px; margin-bottom: 15px; flex-wrap: wrap; }
.api-tab-btn { background: #f1f5f9; border: 1px solid var(--border-color); padding: 8px 18px; border-radius: 6px; cursor: pointer; color: var(--text-gray); transition: 0.2s; font-weight: 600; font-size: 0.9rem; }
.api-tab-btn:hover, .api-tab-btn.active { background: var(--text-dark); color: white; border-color: var(--text-dark); }
.api-tab-content { display: none; background: #1e1e1e; border-radius: 8px; padding: 18px; overflow-x: auto; }
.api-tab-content pre { margin: 0; color: #d4d4d4; font-family: 'Consolas', 'Monaco', monospace; font-size: 0.9rem; line-height: 1.5; }
.api-tab-content code { font-family: inherit; }
.api-tab-content.active { display: block; }
