/* ─── อักขราธิการ AI Stylesheet (Vanilla CSS) ─── */

:root {
    /* Color Palette */
    --bg-main: #0b0f19;
    --bg-card: rgba(17, 24, 39, 0.7);
    --bg-card-hover: rgba(31, 41, 55, 0.8);
    --primary: #8b5cf6;
    --primary-hover: #7c3aed;
    --primary-glow: rgba(139, 92, 246, 0.35);
    
    --secondary: rgba(55, 65, 81, 0.8);
    --secondary-hover: rgba(75, 85, 99, 0.9);
    
    --text-main: #f3f4f6;
    --text-muted: #9ca3af;
    
    --success: #10b981;
    --success-bg: rgba(16, 185, 129, 0.1);
    --info: #3b82f6;
    --info-bg: rgba(59, 130, 246, 0.1);
    --danger: #ef4444;
    --danger-bg: rgba(239, 68, 68, 0.1);
    
    --border-color: rgba(255, 255, 255, 0.08);
    --border-focus: rgba(139, 92, 246, 0.6);
    
    --font-thai: 'Noto Sans Thai', sans-serif;
    --font-eng: 'Outfit', sans-serif;
    
    /* Effects */
    --glass-blur: blur(16px);
    --card-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.5);
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Global Reset & Base */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    background-color: var(--bg-main);
    background-image: 
        radial-gradient(at 10% 20%, rgba(139, 92, 246, 0.15) 0px, transparent 50%),
        radial-gradient(at 90% 80%, rgba(59, 130, 246, 0.12) 0px, transparent 50%);
    background-attachment: fixed;
    color: var(--text-main);
    font-family: var(--font-thai);
    font-size: 15px;
    line-height: 1.6;
    min-height: 100vh;
    display: flex;
    justify-content: center;
    overflow-x: hidden;
}

/* Container */
.app-container {
    width: 100%;
    max-width: 1440px;
    min-height: 100vh;
    padding: 24px;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

/* Header */
.app-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 24px;
    background: var(--bg-card);
    backdrop-filter: var(--glass-blur);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    box-shadow: var(--card-shadow);
}

.logo-area {
    display: flex;
    align-items: center;
    gap: 16px;
}

.logo-icon {
    width: 44px;
    height: 44px;
    background: linear-gradient(135deg, var(--primary), #3b82f6);
    border-radius: 12px;
    display: flex;
    justify-content: center;
    align-items: center;
    color: #fff;
    box-shadow: 0 4px 15px var(--primary-glow);
}

.logo-icon i {
    width: 24px;
    height: 24px;
}

.logo-text h1 {
    font-family: var(--font-thai);
    font-weight: 700;
    font-size: 20px;
    letter-spacing: 0.5px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.badge {
    background: linear-gradient(90deg, #f59e0b, #ef4444);
    font-family: var(--font-eng);
    font-size: 11px;
    font-weight: 700;
    padding: 2px 8px;
    border-radius: 6px;
    color: #fff;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
}

.logo-text p {
    font-size: 12px;
    color: var(--text-muted);
}

/* Buttons */
button {
    font-family: var(--font-thai);
    cursor: pointer;
    border: none;
    outline: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 18px;
    border-radius: 10px;
    font-size: 14px;
    font-weight: 500;
    transition: var(--transition);
}

.btn-primary {
    background: var(--primary);
    color: #fff;
    box-shadow: 0 4px 12px var(--primary-glow);
}

.btn-primary:hover {
    background: var(--primary-hover);
    transform: translateY(-2px);
    box-shadow: 0 6px 16px var(--primary-glow);
}

.btn-primary:active {
    transform: translateY(0);
}

.btn-secondary {
    background: var(--secondary);
    color: var(--text-main);
    border: 1px solid var(--border-color);
}

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

.btn-icon {
    width: 36px;
    height: 36px;
    padding: 0;
    border-radius: 8px;
    background: transparent;
    color: var(--text-muted);
}

.btn-icon:hover {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-main);
}

.btn-text {
    background: transparent;
    color: var(--text-muted);
}

.btn-text:hover {
    color: var(--text-main);
}

.btn-text-danger {
    background: transparent;
    color: var(--text-muted);
}

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

.full-width {
    width: 100%;
}

/* Workspace Grid */
.workspace {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 20px;
    position: relative;
}

.editor-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    flex: 1;
    min-height: calc(100vh - 160px);
}

@media (max-width: 968px) {
    .editor-grid {
        grid-template-columns: 1fr;
        min-height: auto;
    }
}

/* Cards Layout */
.editor-card {
    background: var(--bg-card);
    backdrop-filter: var(--glass-blur);
    border: 1px solid var(--border-color);
    border-radius: 18px;
    box-shadow: var(--card-shadow);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transition: var(--transition);
}

.editor-card:hover {
    border-color: rgba(255, 255, 255, 0.12);
}

.card-header {
    padding: 16px 20px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: rgba(255, 255, 255, 0.02);
}

.card-title {
    font-size: 16px;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--text-main);
}

.card-title i {
    width: 18px;
    height: 18px;
    color: var(--primary);
}

.card-body {
    flex: 1;
    padding: 20px;
    position: relative;
}

/* Form and Fields */
textarea {
    width: 100%;
    height: 100%;
    min-height: 350px;
    background: transparent;
    border: none;
    outline: none;
    color: var(--text-main);
    font-family: var(--font-thai);
    font-size: 16px;
    line-height: 1.7;
    resize: none;
}

.card-footer {
    padding: 16px 20px;
    border-top: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: rgba(0, 0, 0, 0.2);
}

.mode-selector {
    display: flex;
    align-items: center;
    gap: 12px;
}

.mode-selector label {
    font-size: 13px;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    gap: 6px;
}

.mode-selector label i {
    width: 14px;
    height: 14px;
}

select, input[type="text"], input[type="password"] {
    background: rgba(17, 24, 39, 0.8);
    border: 1px solid var(--border-color);
    color: var(--text-main);
    font-family: var(--font-thai);
    font-size: 13px;
    padding: 8px 14px;
    border-radius: 8px;
    outline: none;
    transition: var(--transition);
}

select:focus, input[type="text"]:focus, input[type="password"]:focus {
    border-color: var(--border-focus);
    box-shadow: 0 0 0 2px var(--primary-glow);
}

/* Output States */
.output-area {
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.placeholder-state, .loading-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 40px 20px;
    color: var(--text-muted);
    flex: 1;
}

.placeholder-icon {
    width: 48px;
    height: 48px;
    margin-bottom: 16px;
    color: var(--secondary);
    stroke-width: 1.5;
}

.placeholder-state h4, .loading-state h4 {
    color: var(--text-main);
    font-weight: 500;
    margin-bottom: 8px;
    font-size: 16px;
}

.placeholder-state p, .loading-state p {
    font-size: 13px;
    max-width: 320px;
}

/* Spinner Animation */
.spinner {
    width: 40px;
    height: 40px;
    border: 3.5px solid rgba(139, 92, 246, 0.1);
    border-top: 3.5px solid var(--primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 20px;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Result Screen Layout */
.result-content {
    display: flex;
    flex-direction: column;
    gap: 16px;
    height: 100%;
}

.output-text-box {
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid rgba(255, 255, 255, 0.04);
    border-radius: 12px;
    padding: 16px;
    font-size: 16px;
    line-height: 1.7;
    white-space: pre-wrap;
    min-height: 200px;
    max-height: 380px;
    overflow-y: auto;
}

.diff-block h5, .explanation-view h5 {
    font-size: 13px;
    font-weight: 500;
    color: var(--text-muted);
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.diff-block h5 i, .explanation-view h5 i {
    width: 16px;
    height: 16px;
}

.divider {
    border: 0;
    height: 1px;
    background: var(--border-color);
    margin: 4px 0;
}

.explanation-box {
    background: var(--info-bg);
    border: 1px solid rgba(59, 130, 246, 0.2);
    border-radius: 12px;
    padding: 16px;
    font-size: 14px;
    color: #93c5fd;
    line-height: 1.6;
    max-height: 180px;
    overflow-y: auto;
}

.explanation-box p {
    margin-bottom: 8px;
}

.explanation-box p:last-child {
    margin-bottom: 0;
}

/* Diff highlighting styles */
.highlight-add {
    background: rgba(16, 185, 129, 0.2);
    color: #a7f3d0;
    border-radius: 4px;
    padding: 2px 4px;
}

.highlight-remove {
    background: rgba(239, 68, 68, 0.2);
    color: #fca5a5;
    text-decoration: line-through;
    border-radius: 4px;
    padding: 2px 4px;
}

/* Settings Overlay */
.settings-panel {
    position: absolute;
    top: 0;
    right: 0;
    width: 360px;
    height: auto;
    max-height: 100%;
    z-index: 100;
    background: rgba(17, 24, 39, 0.95);
    backdrop-filter: var(--glass-blur);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.7);
    padding: 24px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    animation: slideIn 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(-20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.settings-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 12px;
}

.settings-header h3 {
    font-size: 15px;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--text-main);
}

.settings-header h3 i {
    width: 16px;
    height: 16px;
    color: var(--primary);
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-bottom: 14px;
}

.form-group label {
    font-size: 12px;
    color: var(--text-muted);
}

.form-group select, .form-group input {
    width: 100%;
}

.input-password-wrapper {
    position: relative;
    display: flex;
    align-items: center;
}

.input-password-wrapper input {
    padding-right: 40px;
}

.input-password-wrapper button {
    position: absolute;
    right: 8px;
    background: transparent;
    padding: 4px;
    color: var(--text-muted);
    border-radius: 4px;
}

.helper-text {
    font-size: 11px;
    color: var(--text-muted);
    margin-top: 2px;
}

/* Toast Message */
.toast {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(17, 24, 39, 0.9);
    backdrop-filter: var(--glass-blur);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    padding: 12px 24px;
    font-size: 13px;
    color: var(--text-main);
    z-index: 1000;
    box-shadow: 0 5px 20px rgba(0,0,0,0.5);
    display: flex;
    align-items: center;
    gap: 10px;
    animation: fadeInUp 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translate(-50%, 20px);
    }
    to {
        opacity: 1;
        transform: translate(-50%, 0);
    }
}

/* Utilities classes */
.hidden {
    display: none !important;
}

.text-success { color: var(--success); }
.text-info { color: var(--info); }
.text-danger { color: var(--danger); }

/* Premium Info Box */
.info-box-premium {
    background: rgba(139, 92, 246, 0.08);
    border: 1px solid rgba(139, 92, 246, 0.2);
    border-radius: 10px;
    padding: 12px 16px;
    display: flex;
    gap: 12px;
    align-items: flex-start;
    margin-bottom: 14px;
}

.info-box-premium i {
    width: 20px;
    height: 20px;
    margin-top: 2px;
    flex-shrink: 0;
}

.info-box-premium h5 {
    font-size: 13px;
    font-weight: 600;
    margin-bottom: 4px;
    color: var(--text-main);
}

.info-box-premium p {
    font-size: 11px;
    color: var(--text-muted);
    line-height: 1.5;
}
