/* ===================================
   Binaria v3 - Stylesheet
   Mobile-First, Light/Dark Theme
   =================================== */

/* === CSS Variables === */
:root {
    /* Dark Theme (Default) */
    --primary: #6366f1;
    --primary-hover: #4f46e5;
    --primary-light: #818cf8;
    --bg: #0f172a;
    --card-bg: #1e293b;
    --text: #f8fafc;
    --text-light: #94a3b8;
    --text-muted: #64748b;
    --border: #334155;
    --accent: #f59e0b;
    --accent-light: #fbbf24;
    --error: #f43f5e;
    --success: #10b981;
    --warning: #f59e0b;
    --radius: 16px;
    --radius-sm: 10px;
    --shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.3);
    --shadow-lg: 0 20px 25px -5px rgba(0, 0, 0, 0.4);
    --transition: 0.3s ease;
}

[data-theme="light"] {
    --bg: #f1f5f9;
    --card-bg: #ffffff;
    --text: #0f172a;
    --text-light: #475569;
    --text-muted: #94a3b8;
    --border: #e2e8f0;
    --shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 20px 25px -5px rgba(0, 0, 0, 0.15);
}

/* === Reset & Base === */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    -webkit-tap-highlight-color: transparent;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 
                 'Helvetica Neue', Arial, sans-serif;
    background-color: var(--bg);
    color: var(--text);
    padding: 16px;
    display: flex;
    justify-content: center;
    min-height: 100vh;
    transition: background-color var(--transition), color var(--transition);
    line-height: 1.6;
}

/* === App Container === */
.app-container {
    width: 100%;
    max-width: 480px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

/* === Header === */
header {
    padding: 20px 0 10px;
}

.header-top {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
}

header h1 {
    font-size: 1.8rem;
    font-weight: 800;
    color: var(--primary);
    text-shadow: 0 0 20px rgba(99, 102, 241, 0.3);
    letter-spacing: -0.5px;
    margin-bottom: 2px;
}

.subtitle {
    font-size: 0.85rem;
    color: var(--text-light);
    font-weight: 500;
}

/* === Theme Toggle === */
.theme-toggle {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: 50%;
    width: 48px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all var(--transition);
    font-size: 1.5rem;
    box-shadow: var(--shadow);
}

.theme-toggle:hover {
    transform: scale(1.05);
    border-color: var(--primary);
}

.theme-toggle:active {
    transform: scale(0.95);
}

[data-theme="dark"] .icon-sun {
    display: none;
}

[data-theme="light"] .icon-moon {
    display: none;
}

/* === Card === */
.card {
    background: var(--card-bg);
    padding: 20px;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    box-shadow: var(--shadow);
    transition: all var(--transition);
}

/* === Controls === */
.controls {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-bottom: 20px;
}

/* === Mode Switch === */
.mode-switch {
    display: flex;
    background: var(--bg);
    padding: 4px;
    border-radius: var(--radius-sm);
    gap: 4px;
}

.mode-btn {
    flex: 1;
    padding: 12px;
    border: none;
    background: transparent;
    color: var(--text-light);
    font-weight: 700;
    font-size: 0.9rem;
    border-radius: 8px;
    cursor: pointer;
    transition: all var(--transition);
    letter-spacing: 0.5px;
}

.mode-btn:hover {
    background: rgba(99, 102, 241, 0.1);
}

.mode-btn.active {
    background: var(--primary);
    color: white;
    box-shadow: 0 4px 8px rgba(99, 102, 241, 0.3);
}

.mode-btn:active {
    transform: scale(0.98);
}

/* === Select === */
select {
    width: 100%;
    padding: 12px 14px;
    background: var(--bg);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 1rem;
    font-weight: 500;
    outline: none;
    cursor: pointer;
    transition: all var(--transition);
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%236366f1' d='M6 9L1 4h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 40px;
}

select:hover {
    border-color: var(--primary);
}

select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

/* === Hint Box === */
.hint-box {
    background: rgba(245, 158, 11, 0.1);
    border-left: 4px solid var(--accent);
    padding: 12px 14px;
    font-size: 0.85rem;
    color: var(--accent);
    margin-bottom: 15px;
    border-radius: 4px;
    line-height: 1.5;
    transition: all var(--transition);
}

[data-theme="light"] .hint-box {
    background: rgba(245, 158, 11, 0.08);
}

/* === Input Group === */
.input-group {
    margin-bottom: 15px;
}

label {
    display: block;
    font-size: 0.7rem;
    color: var(--text-light);
    text-transform: uppercase;
    margin-bottom: 8px;
    letter-spacing: 1.2px;
    font-weight: 700;
}

textarea {
    width: 100%;
    min-height: 100px;
    padding: 14px;
    background: var(--bg);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 1rem;
    resize: vertical;
    outline: none;
    transition: all var(--transition);
    font-family: inherit;
    line-height: 1.6;
}

textarea:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

textarea::placeholder {
    color: var(--text-muted);
}

/* === Character Count === */
.char-count {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 6px;
    text-align: right;
}

.char-count span {
    font-weight: 700;
    color: var(--primary);
}

/* === Output Box === */
.output-box {
    background: var(--bg);
    padding: 14px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    min-height: 100px;
    font-family: 'Courier New', Consolas, Monaco, monospace;
    word-break: break-all;
    white-space: pre-wrap;
    margin-top: 5px;
    color: var(--primary);
    font-size: 0.95rem;
    line-height: 1.8;
    transition: all var(--transition);
    max-height: 300px;
    overflow-y: auto;
}

.output-box:empty::before {
    content: 'Hasil akan muncul di sini...';
    color: var(--text-muted);
    font-family: -apple-system, system-ui, sans-serif;
}

.placeholder-text {
    color: var(--text-muted);
    font-family: -apple-system, system-ui, sans-serif;
    font-style: italic;
}

/* === Error Message === */
.error {
    color: var(--error);
    font-size: 0.75rem;
    margin-top: 6px;
    display: none;
    font-weight: 600;
}

.error::before {
    content: '⚠️ ';
}

/* === Buttons === */
.action-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin-top: 10px;
}

.btn {
    padding: 12px 16px;
    border-radius: var(--radius-sm);
    border: none;
    font-weight: 700;
    font-size: 0.9rem;
    cursor: pointer;
    transition: all var(--transition);
    text-align: center;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}

.btn:active {
    transform: scale(0.98);
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn-primary {
    background: var(--primary);
    color: white;
    width: 100%;
    margin-top: 10px;
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.3);
}

.btn-primary:hover:not(:disabled) {
    background: var(--primary-hover);
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(99, 102, 241, 0.4);
}

.btn-outline {
    background: transparent;
    border: 1.5px solid var(--border);
    color: var(--text);
}

.btn-outline:hover:not(:disabled) {
    border-color: var(--primary);
    background: rgba(99, 102, 241, 0.05);
    color: var(--primary);
}

.btn-icon {
    font-size: 1rem;
}

/* === History Section === */
.history-section {
    margin-top: 10px;
}

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

.history-title {
    font-size: 0.75rem;
    color: var(--text-light);
    text-transform: uppercase;
    letter-spacing: 1.2px;
    font-weight: 700;
}

.btn-clear-all {
    background: transparent;
    border: none;
    color: var(--error);
    font-size: 0.75rem;
    cursor: pointer;
    font-weight: 600;
    padding: 4px 8px;
    border-radius: 6px;
    transition: all var(--transition);
}

.btn-clear-all:hover {
    background: rgba(244, 63, 94, 0.1);
}

.history-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.history-empty {
    text-align: center;
    color: var(--text-muted);
    font-size: 0.85rem;
    padding: 20px;
    font-style: italic;
}

.history-card {
    background: var(--card-bg);
    padding: 12px 14px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    font-size: 0.85rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
    transition: all var(--transition);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

.history-card:hover {
    border-color: var(--primary);
    transform: translateX(4px);
}

.history-content {
    flex: 1;
    min-width: 0;
}

.history-type {
    display: inline-block;
    background: var(--primary);
    color: white;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 0.65rem;
    font-weight: 700;
    text-transform: uppercase;
    margin-bottom: 4px;
    letter-spacing: 0.5px;
}

.history-text {
    color: var(--text);
    font-family: 'Courier New', monospace;
    font-size: 0.75rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.history-time {
    font-size: 0.65rem;
    color: var(--text-muted);
    margin-top: 4px;
}

.btn-delete-history {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--error);
    padding: 6px 10px;
    border-radius: 6px;
    font-size: 0.7rem;
    font-weight: 700;
    cursor: pointer;
    transition: all var(--transition);
    flex-shrink: 0;
}

.btn-delete-history:hover {
    background: var(--error);
    color: white;
    border-color: var(--error);
}

/* === Footer === */
.footer-info {
    text-align: center;
    padding: 20px 0;
    color: var(--text-muted);
    font-size: 0.75rem;
    line-height: 1.8;
}

.footer-info p:first-child {
    margin-bottom: 4px;
}

.version {
    color: var(--primary);
    font-weight: 700;
}

/* === Toast === */
#toast {
    position: fixed;
    bottom: 40px;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    background: var(--primary);
    color: white;
    padding: 12px 28px;
    border-radius: 50px;
    opacity: 0;
    transition: all var(--transition);
    pointer-events: none;
    font-weight: 700;
    font-size: 0.9rem;
    box-shadow: 0 8px 16px rgba(99, 102, 241, 0.4);
    z-index: 1000;
}

#toast.show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

/* === Scrollbar Styling === */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: var(--bg);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--primary);
}

/* === Responsive === */
@media (max-width: 400px) {
    header h1 {
        font-size: 1.5rem;
    }
    
    .card {
        padding: 16px;
    }
    
    .btn {
        padding: 10px 12px;
        font-size: 0.85rem;
    }
}

@media (min-width: 481px) {
    .app-container {
        max-width: 600px;
    }
    
    .card {
        padding: 28px;
    }
}

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

.history-card {
    animation: slideIn 0.3s ease;
}
