/* === Variables & Theme === */
:root {
    --bg-primary: #f0f2f5;
    --bg-secondary: #ffffff;
    --bg-card: #ffffff;
    --text-primary: #1a1a2e;
    --text-secondary: #555;
    --accent: #4361ee;
    --accent-hover: #3a56d4;
    --danger: #e63946;
    --danger-hover: #c5303c;
    --success: #2a9d8f;
    --warning: #e9c46a;
    --border: #e0e0e0;
    --shadow: 0 2px 12px rgba(0,0,0,0.08);
    --radius: 12px;
    --radius-sm: 8px;
    --transition: 0.3s ease;
}

[data-theme="dark"] {
    --bg-primary: #0f0f1a;
    --bg-secondary: #1a1a2e;
    --bg-card: #16213e;
    --text-primary: #e0e0e0;
    --text-secondary: #a0a0a0;
    --accent: #4cc9f0;
    --accent-hover: #3db8dd;
    --border: #2a2a4a;
    --shadow: 0 2px 12px rgba(0,0,0,0.3);
}

/* === Reset & Base === */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
    transition: background var(--transition), color var(--transition);
}

/* === App Container === */
.app-container {
    max-width: 520px;
    margin: 0 auto;
    padding: 20px;
}

/* === Header === */
header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
}

header h1 {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--accent);
}

header h1 i {
    margin-right: 8px;
}

.btn-icon {
    background: none;
    border: 2px solid var(--border);
    color: var(--text-primary);
    width: 40px;
    height: 40px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition);
    font-size: 1rem;
}

.btn-icon:hover {
    border-color: var(--accent);
    color: var(--accent);
}


@keyframes fadeIn {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

/* === Forms === */
.form-group {
    margin-bottom: 16px;
}

.form-group label {
    display: block;
    font-weight: 600;
    font-size: 0.85rem;
    margin-bottom: 6px;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

textarea, input[type="text"], select {
    width: 100%;
    padding: 12px 14px;
    border: 2px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg-secondary);
    color: var(--text-primary);
    font-size: 0.95rem;
    transition: border-color var(--transition);
    font-family: inherit;
}

textarea:focus, input[type="text"]:focus, select:focus {
    outline: none;
    border-color: var(--accent);
}

textarea {
    resize: vertical;
    min-height: 80px;
}

small {
    display: block;
    text-align: right;
    color: var(--text-secondary);
    font-size: 0.8rem;
    margin-top: 4px;
}

input[type="color"] {
    width: 100%;
    height: 42px;
    border: 2px solid var(--border);
    border-radius: var(--radius-sm);
    cursor: pointer;
    padding: 2px;
    background: var(--bg-secondary);
}

/* === Options Grid === */
.options-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin-bottom: 16px;
}

/* === Security Sections === */
.security-section {
    background: var(--bg-card);
    border: 2px solid var(--border);
    border-radius: var(--radius);
    padding: 16px;
    margin-bottom: 16px;
}

.toggle-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.toggle-row label {
    font-weight: 600;
    font-size: 0.95rem;
}

.toggle-row label i {
    margin-right: 8px;
    color: var(--accent);
}

/* === Toggle Switch === */
.switch {
    position: relative;
    display: inline-block;
    width: 48px;
    height: 26px;
}

.switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.slider {
    position: absolute;
    cursor: pointer;
    top: 0; left: 0; right: 0; bottom: 0;
    background: var(--border);
    border-radius: 26px;
    transition: var(--transition);
}

.slider::before {
    content: "";
    position: absolute;
    height: 20px;
    width: 20px;
    left: 3px;
    bottom: 3px;
    background: #fff;
    border-radius: 50%;
    transition: var(--transition);
}

.switch input:checked + .slider {
    background: var(--accent);
}

.switch input:checked + .slider::before {
    transform: translateX(22px);
}

/* === Buttons === */
.btn-primary, .btn-secondary, .btn-danger {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 24px;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition);
    text-decoration: none;
    font-family: inherit;
}

.btn-primary {
    background: var(--accent);
    color: #fff;
    width: 100%;
}

.btn-primary:hover {
    background: var(--accent-hover);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(67, 97, 238, 0.3);
}

.btn-secondary {
    background: var(--bg-secondary);
    color: var(--text-primary);
    border: 2px solid var(--border);
}

.btn-secondary:hover {
    border-color: var(--accent);
    color: var(--accent);
}

.btn-danger {
    background: var(--danger);
    color: #fff;
}

.btn-danger:hover {
    background: var(--danger-hover);
}

/* === QR Result === */
.qr-result {
    text-align: center;
    margin-top: 24px;
    padding: 24px;
    background: var(--bg-card);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

#qr-canvas-container {
    display: inline-block;
    padding: 16px;
    background: #fff;
    border-radius: var(--radius-sm);
    margin-bottom: 16px;
}

#qr-canvas-container img,
#qr-canvas-container canvas {
    display: block;
}

.result-actions {
    display: flex;
    gap: 12px;
    justify-content: center;
    margin-top: 16px;
}


/* === Utility === */
.hidden {
    display: none !important;
}

/* === Responsive === */
@media (max-width: 480px) {
    .app-container {
        padding: 12px;
    }

    header h1 {
        font-size: 1.2rem;
    }

    .options-grid {
        grid-template-columns: 1fr 1fr;
        gap: 8px;
    }

    .result-actions {
        flex-direction: column;
    }

    .modal-actions {
        flex-direction: column;
    }
}
