/* ==========================================================================
   Design Tokens & Variables
   ========================================================================== */
   :root {
    /* Curated Premium Dark Theme Palette */
    --bg-base: #0b0f19;
    --bg-surface: rgba(18, 25, 43, 0.7);
    --bg-surface-hover: rgba(26, 36, 61, 0.8);
    --border-color: rgba(255, 255, 255, 0.08);
    --border-color-hover: rgba(255, 255, 255, 0.15);
    
    /* Vibrant Accents */
    --accent-primary: #6366f1;
    --accent-primary-hover: #4f46e5;
    --accent-secondary: #ec4899;
    --accent-gradient: linear-gradient(135deg, #6366f1 0%, #a855f7 50%, #ec4899 100%);
    --accent-glow: rgba(99, 102, 241, 0.25);
    
    /* Text Colors */
    --text-main: #f8fafc;
    --text-muted: #94a3b8;
    --text-disabled: #475569;
    
    /* Status Colors */
    --status-success: #10b981;
    --status-warning: #f59e0b;
    --status-error: #ef4444;
    
    /* Typography */
    --font-sans: 'Inter', 'Noto Sans Thai', -apple-system, BlinkMacSystemFont, sans-serif;
    
    /* Shadows & Transitions */
    --shadow-premium: 0 10px 30px -5px rgba(0, 0, 0, 0.5);
    --shadow-glow: 0 0 20px var(--accent-glow);
    --transition-fast: 0.15s cubic-bezier(0.4, 0, 0.2, 1);
    --transition-normal: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

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

body {
    font-family: var(--font-sans);
    background-color: var(--bg-base);
    color: var(--text-main);
    line-height: 1.6;
    min-height: 100vh;
    overflow-x: hidden;
    position: relative;
    display: flex;
    flex-direction: column;
}

/* Beautiful Animated Background Mesh */
.background-mesh {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    overflow: hidden;
    z-index: -1;
    opacity: 0.6;
}

.background-mesh::before,
.background-mesh::after {
    content: '';
    position: absolute;
    border-radius: 50%;
    filter: blur(120px);
}

.background-mesh::before {
    top: -10%;
    right: -5%;
    width: 600px;
    height: 600px;
    background: radial-gradient(circle, rgba(99,102,241,0.2) 0%, rgba(0,0,0,0) 70%);
    animation: float1 15s infinite alternate;
}

.background-mesh::after {
    bottom: -10%;
    left: -5%;
    width: 500px;
    height: 500px;
    background: radial-gradient(circle, rgba(236,72,153,0.15) 0%, rgba(0,0,0,0) 70%);
    animation: float2 12s infinite alternate;
}

@keyframes float1 {
    0% { transform: translate(0, 0) scale(1); }
    100% { transform: translate(-50px, 30px) scale(1.1); }
}

@keyframes float2 {
    0% { transform: translate(0, 0) scale(1); }
    100% { transform: translate(40px, -40px) scale(1.15); }
}

/* ==========================================================================
   Header Styles
   ========================================================================== */
.app-header {
    border-bottom: 1px solid var(--border-color);
    background: rgba(11, 15, 25, 0.8);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    position: sticky;
    top: 0;
    z-index: 100;
}

.header-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 1rem 1.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.logo-wrapper {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.logo-icon {
    font-size: 2.2rem;
    filter: drop-shadow(0 2px 8px rgba(0,0,0,0.3));
}

h1 {
    font-size: 1.3rem;
    font-weight: 700;
    background: var(--accent-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    letter-spacing: -0.5px;
}

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

.status-badge {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.4rem 0.8rem;
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: 50px;
    font-size: 0.8rem;
    font-weight: 500;
    transition: var(--transition-normal);
}

.status-badge.success {
    border-color: rgba(16, 185, 129, 0.3);
}

.status-badge.error {
    border-color: rgba(239, 68, 68, 0.3);
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
}

.status-dot.loading {
    background-color: var(--status-warning);
    animation: pulse 1.5s infinite;
}

.status-dot.success {
    background-color: var(--status-success);
}

.status-dot.error {
    background-color: var(--status-error);
}

@keyframes pulse {
    0% { opacity: 0.4; transform: scale(0.8); }
    50% { opacity: 1; transform: scale(1.2); }
    100% { opacity: 0.4; transform: scale(0.8); }
}

/* ==========================================================================
   Main Content Layout
   ========================================================================== */
.main-container {
    max-width: 1200px;
    width: 100%;
    margin: 0 auto;
    padding: 2rem 1.5rem;
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 2rem;
}

/* Glassmorphism Generic Component */
.glass-card {
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    padding: 1.5rem;
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    box-shadow: var(--shadow-premium);
    transition: var(--transition-normal);
}

/* Fallback Upload Section */
.fallback-section.hidden {
    display: none;
}

.dropzone {
    border: 2px dashed var(--accent-primary);
    border-radius: 16px;
    padding: 3rem 2rem;
    text-align: center;
    background: rgba(99, 102, 241, 0.03);
    transition: var(--transition-normal);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
}

.dropzone.dragover {
    background: rgba(99, 102, 241, 0.1);
    border-color: var(--accent-secondary);
    transform: scale(1.01);
}

.dropzone-icon {
    font-size: 3rem;
    animation: bounce 2s infinite ease-in-out;
}

@keyframes bounce {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-10px); }
}

.instruction-text {
    color: var(--text-muted);
    font-size: 0.9rem;
    max-width: 500px;
}

.hidden-input {
    display: none;
}

/* Grid Layout */
.app-grid {
    display: grid;
    grid-template-columns: 350px 1fr;
    gap: 2rem;
    align-items: start;
}

@media (max-width: 860px) {
    .app-grid {
        grid-template-columns: 1fr;
    }
}

/* ==========================================================================
   Configuration Panel Controls
   ========================================================================== */
.config-panel h2 {
    font-size: 1.2rem;
    font-weight: 600;
    margin-bottom: 1.5rem;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid var(--border-color);
}

.form-group {
    margin-bottom: 1.5rem;
}

.form-group label {
    display: block;
    font-size: 0.9rem;
    font-weight: 500;
    margin-bottom: 0.5rem;
    color: var(--text-muted);
}

.form-control {
    width: 100%;
    background: rgba(0, 0, 0, 0.4);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    padding: 0.75rem 1rem;
    color: var(--text-main);
    font-family: inherit;
    font-size: 0.95rem;
    outline: none;
    cursor: pointer;
    transition: var(--transition-fast);
}

.form-control:focus, .form-control:hover {
    border-color: var(--accent-primary);
    background: rgba(0, 0, 0, 0.6);
}

.form-control option {
    background-color: #0f172a;
    color: var(--text-main);
}

/* Radio Cards */
.radio-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.radio-card {
    display: block;
    position: relative;
    cursor: pointer;
}

.radio-card input {
    position: absolute;
    opacity: 0;
    cursor: pointer;
}

.radio-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem 1rem;
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    transition: var(--transition-fast);
}

.radio-card:hover .radio-content {
    border-color: var(--border-color-hover);
    background: rgba(255, 255, 255, 0.02);
}

.radio-card input:checked + .radio-content {
    border-color: var(--accent-primary);
    background: rgba(99, 102, 241, 0.1);
}

.radio-content .title {
    font-weight: 500;
    font-size: 0.95rem;
}

.radio-content .desc {
    font-size: 0.75rem;
    color: var(--text-muted);
}

/* Count Selector */
.count-selector {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 0.5rem;
}

.count-btn {
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid var(--border-color);
    color: var(--text-muted);
    padding: 0.6rem;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition-fast);
}

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

.count-btn.active {
    background: var(--accent-primary);
    border-color: var(--accent-primary);
    color: #fff;
    box-shadow: 0 0 12px rgba(99, 102, 241, 0.4);
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    font-family: inherit;
    font-weight: 600;
    padding: 0.8rem 1.5rem;
    border-radius: 10px;
    border: none;
    cursor: pointer;
    transition: var(--transition-normal);
    text-decoration: none;
    font-size: 1rem;
}

.btn-block {
    width: 100%;
}

.btn-primary {
    background: var(--accent-gradient);
    color: #fff;
    position: relative;
    overflow: hidden;
    z-index: 1;
}

.btn-primary::before {
    content: '';
    position: absolute;
    top: 0; left: 0; width: 100%; height: 100%;
    background: linear-gradient(135deg, #4f46e5 0%, #9333ea 50%, #db2777 100%);
    opacity: 0;
    transition: var(--transition-normal);
    z-index: -1;
}

.btn-primary:hover:not(:disabled)::before {
    opacity: 1;
}

.btn-primary:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: var(--shadow-glow);
}

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

.btn-primary:disabled {
    background: var(--text-disabled);
    cursor: not-allowed;
    opacity: 0.6;
    box-shadow: none;
}

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

.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.15);
    border-color: rgba(255, 255, 255, 0.25);
}

.btn-text {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 0.85rem;
    cursor: pointer;
    transition: var(--transition-fast);
}

.btn-text:hover {
    color: var(--accent-secondary);
    text-decoration: underline;
}

.hidden {
    display: none !important;
}

/* ==========================================================================
   Results Panel & Cards
   ========================================================================== */
.results-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
}

.results-header h2 {
    font-size: 1.2rem;
    font-weight: 600;
}

.empty-state {
    text-align: center;
    padding: 4rem 2rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
}

.empty-icon {
    font-size: 3.5rem;
    opacity: 0.5;
}

.empty-state h3 {
    font-weight: 600;
    color: var(--text-muted);
}

.empty-state p {
    font-size: 0.9rem;
    color: var(--text-disabled);
    max-width: 350px;
}

/* Address Card List */
.results-container {
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
}

.address-card {
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    padding: 1.5rem;
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    box-shadow: var(--shadow-premium);
    transition: var(--transition-normal);
    animation: slideIn 0.3s ease-out backwards;
    position: relative;
    overflow: hidden;
}

.address-card::before {
    content: '';
    position: absolute;
    top: 0; left: 0;
    width: 4px;
    height: 100%;
    background: var(--accent-gradient);
}

.address-card:hover {
    border-color: var(--border-color-hover);
    transform: translateY(-2px);
    background: var(--bg-surface-hover);
}

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

.address-main {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 1rem;
    margin-bottom: 1.25rem;
}

.full-address-text {
    font-size: 1.15rem;
    font-weight: 500;
    color: var(--text-main);
    line-height: 1.5;
    word-break: break-word;
}

.card-actions {
    display: flex;
    gap: 0.5rem;
    flex-shrink: 0;
}

.icon-btn {
    width: 38px;
    height: 38px;
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid var(--border-color);
    color: var(--text-muted);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: var(--transition-fast);
    position: relative;
}

.icon-btn:hover {
    background: var(--accent-primary);
    color: #fff;
    border-color: var(--accent-primary);
}

/* Tooltips */
.icon-btn::after {
    content: attr(title);
    position: absolute;
    bottom: 110%;
    left: 50%;
    transform: translateX(-50%) scale(0.8);
    background: #000;
    color: #fff;
    padding: 0.3rem 0.6rem;
    border-radius: 6px;
    font-size: 0.75rem;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: var(--transition-fast);
}

.icon-btn:hover::after {
    opacity: 1;
    transform: translateX(-50%) scale(1);
}

/* Component Badges Breakdown */
.address-components {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
    gap: 0.5rem;
    background: rgba(0, 0, 0, 0.25);
    padding: 0.8rem;
    border-radius: 10px;
    border: 1px solid rgba(255, 255, 255, 0.03);
}

.comp-item {
    display: flex;
    flex-direction: column;
}

.comp-label {
    font-size: 0.7rem;
    color: var(--text-muted);
    font-weight: 500;
    margin-bottom: 0.1rem;
}

.comp-value {
    font-size: 0.9rem;
    color: var(--text-main);
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.comp-value.highlight {
    color: var(--accent-secondary);
}

/* ==========================================================================
   Toast Notification System
   ========================================================================== */
.toast {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    background: rgba(16, 185, 129, 0.9);
    backdrop-filter: blur(8px);
    color: #fff;
    padding: 0.8rem 1.5rem;
    border-radius: 10px;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    box-shadow: 0 10px 25px rgba(0,0,0,0.3);
    z-index: 1000;
    animation: toastIn 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    font-weight: 500;
}

@keyframes toastIn {
    from { transform: translateY(100px) scale(0.9); opacity: 0; }
    to { transform: translateY(0) scale(1); opacity: 1; }
}
