/* Reset & base */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    display: flex;
    justify-content: center;
    align-items: center;
    background: var(--bg);
    color: var(--text);
    transition: background 0.3s, color 0.3s;
    padding: 1rem;
}

/* CSS Variables cho theme */
:root {
    --bg: #f5f7fa;
    --container-bg: #ffffff;
    --text: #1a1a2e;
    --border: #d1d5db;
    --input-bg: #ffffff;
    --input-border: #ccc;
    --btn-bg: #4a6fa5;
    --btn-hover: #3b5a8a;
    --result-bg: #f0f2f5;
    --shadow: 0 8px 20px rgba(0, 0, 0, 0.08);
    --footer-text: #6b7280;
}

body.dark {
    --bg: #1a1a2e;
    --container-bg: #2a2a3e;
    --text: #e0e0e0;
    --border: #3a3a4e;
    --input-bg: #3a3a4e;
    --input-border: #555;
    --btn-bg: #6b8fc9;
    --btn-hover: #5a7ab5;
    --result-bg: #3a3a4e;
    --shadow: 0 8px 20px rgba(0, 0, 0, 0.4);
    --footer-text: #a0a0b0;
}

.container {
    max-width: 620px;
    width: 100%;
    background: var(--container-bg);
    border-radius: 24px;
    padding: 2rem 2rem 1.5rem;
    box-shadow: var(--shadow);
    transition: background 0.3s, box-shadow 0.3s;
}

/* Header */
header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.8rem;
}

header h1 {
    font-size: 1.6rem;
    font-weight: 600;
    letter-spacing: -0.5px;
    background: linear-gradient(135deg, #4a6fa5, #6b8fc9);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

#theme-toggle {
    background: none;
    border: 2px solid var(--border);
    border-radius: 50%;
    width: 44px;
    height: 44px;
    font-size: 1.4rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s, border-color 0.2s;
    color: var(--text);
    background: var(--container-bg);
}
#theme-toggle:hover {
    background: var(--border);
}

/* Controls */
.controls {
    display: flex;
    flex-wrap: wrap;
    gap: 0.8rem;
    align-items: flex-end;
    margin-bottom: 1.8rem;
}

.input-group {
    display: flex;
    flex-direction: column;
    flex: 1 1 90px;
    min-width: 70px;
}

.input-group label {
    font-size: 0.85rem;
    font-weight: 500;
    margin-bottom: 0.2rem;
    color: var(--text);
}

.input-group input {
    padding: 0.6rem 0.8rem;
    border: 1.5px solid var(--input-border);
    border-radius: 10px;
    font-size: 1rem;
    background: var(--input-bg);
    color: var(--text);
    transition: border 0.2s, background 0.2s;
    width: 100%;
}
.input-group input:focus {
    outline: none;
    border-color: var(--btn-bg);
}

#generate-btn {
    padding: 0.6rem 1.6rem;
    background: var(--btn-bg);
    color: #fff;
    border: none;
    border-radius: 10px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s, transform 0.1s;
    flex: 0 0 auto;
    height: 44px;
}
#generate-btn:hover {
    background: var(--btn-hover);
}
#generate-btn:active {
    transform: scale(0.96);
}

/* Result area */
.result-area {
    background: var(--result-bg);
    border-radius: 18px;
    padding: 1.5rem 1.8rem;
    margin-bottom: 1.5rem;
    text-align: center;
    transition: background 0.3s;
    border: 1px solid var(--border);
}

.result-display {
    display: flex;
    align-items: baseline;
    justify-content: center;
    gap: 0.6rem;
    flex-wrap: wrap;
    margin-bottom: 0.6rem;
}

.result-label {
    font-size: 1.2rem;
    font-weight: 500;
    color: var(--text);
}

.result-number {
    font-size: 3.2rem;
    font-weight: 700;
    color: var(--btn-bg);
    line-height: 1.2;
    word-break: break-word;
    transition: color 0.3s;
}

.result-info {
    display: flex;
    justify-content: space-between;
    font-size: 0.9rem;
    color: var(--footer-text);
    border-top: 1px dashed var(--border);
    padding-top: 0.7rem;
    margin-top: 0.4rem;
    flex-wrap: wrap;
    gap: 0.3rem 1rem;
}

/* Actions */
.actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.8rem;
    justify-content: center;
    margin-bottom: 0.5rem;
}

.actions button {
    padding: 0.5rem 1.2rem;
    background: var(--container-bg);
    border: 1.5px solid var(--border);
    border-radius: 30px;
    font-size: 0.95rem;
    font-weight: 500;
    color: var(--text);
    cursor: pointer;
    transition: background 0.2s, border-color 0.2s, transform 0.1s;
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
}
.actions button:hover {
    background: var(--border);
    border-color: var(--btn-bg);
}
.actions button:active {
    transform: scale(0.96);
}

/* Footer */
footer {
    margin-top: 1.8rem;
    text-align: center;
    font-size: 0.85rem;
    color: var(--footer-text);
    border-top: 1px solid var(--border);
    padding-top: 1.2rem;
}
footer a {
    color: var(--btn-bg);
    text-decoration: none;
    font-weight: 500;
}
footer a:hover {
    text-decoration: underline;
}

/* Responsive */
@media (max-width: 480px) {
    .container {
        padding: 1.5rem 1rem;
    }
    .controls {
        gap: 0.5rem;
    }
    .input-group {
        flex: 1 1 70px;
    }
    #generate-btn {
        flex: 1 1 100%;
    }
    .result-number {
        font-size: 2.6rem;
    }
    .result-info {
        flex-direction: column;
        align-items: center;
    }
    .actions button {
        flex: 1 1 120px;
        justify-content: center;
    }
}