/**
 * ============================================================================
 * HK Community Travel App - Stylesheet
 * ============================================================================
 * 
 * Modern CSS styling using Flexbox and Grid layouts.
 * Designed for a clean, professional Hong Kong tourism application.
 * 
 * Color Palette:
 * - Primary: #E63946 (Hong Kong red)
 * - Secondary: #1D3557 (Deep blue)
 * - Accent: #F4A261 (Warm orange)
 * - Background: #F8F9FA (Light gray)
 * - Text: #2D3436 (Dark gray)
 * 
 * @author Senior Web Architect
 * @version 1.0.0
 */

/* ============================================================================
   CSS RESET & BASE STYLES
   ============================================================================ */

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    font-size: 16px;
    scroll-behavior: smooth;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Microsoft JhengHei', 
                 '微軟正黑體', 'PingFang HK', 'Helvetica Neue', sans-serif;
    background-color: #F8F9FA;
    color: #2D3436;
    line-height: 1.6;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* ============================================================================
   TYPOGRAPHY
   ============================================================================ */

h1, h2, h3, h4, h5, h6 {
    font-weight: 600;
    line-height: 1.3;
    margin-bottom: 0.5rem;
}

h1 { font-size: 1.75rem; }
h2 { font-size: 1.5rem; }
h3 { font-size: 1.25rem; }

p {
    margin-bottom: 0.75rem;
}

a {
    color: #E63946;
    text-decoration: none;
    transition: color 0.2s ease;
}

a:hover {
    color: #C1121F;
    text-decoration: underline;
}

/* ============================================================================
   LAYOUT CONTAINERS
   ============================================================================ */

.container {
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 1rem;
}

/* ============================================================================
   HEADER
   ============================================================================ */

.app-header {
    background: linear-gradient(135deg, #E63946 0%, #C1121F 100%);
    color: white;
    padding: 1rem 0;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    position: sticky;
    top: 0;
    z-index: 100;
}

.app-header .container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 1rem;
}

.logo {
    font-size: 1.5rem;
    font-weight: 700;
    margin: 0;
}

.nav-links {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.user-info {
    font-size: 0.9rem;
    opacity: 0.9;
}

/* Admin Header Variant */
.admin-header {
    background: linear-gradient(135deg, #1D3557 0%, #0D1B2A 100%);
}

/* ============================================================================
   MAIN CONTENT
   ============================================================================ */

.main-content {
    flex: 1;
    padding: 2rem 0;
}

/* ============================================================================
   CARDS
   ============================================================================ */

.card {
    background: white;
    border-radius: 12px;
    padding: 1.5rem;
    margin-bottom: 1.5rem;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    transition: box-shadow 0.2s ease;
}

.card:hover {
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.12);
}

.card h2 {
    color: #1D3557;
    margin-bottom: 0.5rem;
}

.subtitle {
    color: #636E72;
    font-size: 0.9rem;
    margin-bottom: 1.5rem;
}

/* ============================================================================
   BUTTONS
   ============================================================================ */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.75rem 1.5rem;
    font-size: 1rem;
    font-weight: 500;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
    text-decoration: none;
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn-primary {
    background: linear-gradient(135deg, #E63946 0%, #C1121F 100%);
    color: white;
}

.btn-primary:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(230, 57, 70, 0.4);
}

.btn-secondary {
    background: linear-gradient(135deg, #1D3557 0%, #0D1B2A 100%);
    color: white;
}

.btn-secondary:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(29, 53, 87, 0.4);
}

.btn-accent {
    background: linear-gradient(135deg, #F4A261 0%, #E76F51 100%);
    color: white;
}

.btn-accent:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(244, 162, 97, 0.4);
}

.btn-outline {
    background: transparent;
    color: white;
    border: 2px solid white;
}

.btn-outline:hover {
    background: white;
    color: #E63946;
}

.btn-large {
    padding: 1rem 2rem;
    font-size: 1.1rem;
}

.btn-small {
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
}

/* ============================================================================
   FORMS
   ============================================================================ */

.form-group {
    margin-bottom: 1.25rem;
}

.form-group label {
    display: block;
    font-weight: 500;
    margin-bottom: 0.5rem;
    color: #1D3557;
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 0.75rem 1rem;
    font-size: 1rem;
    border: 2px solid #DFE6E9;
    border-radius: 8px;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
    font-family: inherit;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: #E63946;
    box-shadow: 0 0 0 3px rgba(230, 57, 70, 0.1);
}

.form-group input::placeholder,
.form-group textarea::placeholder {
    color: #B2BEC3;
}

.form-group select {
    background-color: white;
    cursor: pointer;
}

.form-group textarea {
    resize: vertical;
    min-height: 100px;
}

.help-text {
    display: block;
    font-size: 0.8rem;
    color: #636E72;
    margin-top: 0.25rem;
}

.form-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
}

.form-actions {
    display: flex;
    gap: 1rem;
    margin-top: 1.5rem;
}

/* ============================================================================
   LOGIN SECTION
   ============================================================================ */

.login-card {
    max-width: 450px;
    margin: 2rem auto;
    text-align: center;
}

.login-card h2 {
    font-size: 1.75rem;
    margin-bottom: 0.5rem;
}

.login-form {
    text-align: left;
    margin-top: 1.5rem;
}

.login-form .form-actions {
    flex-direction: column;
}

.login-form .btn {
    width: 100%;
}

.error-message {
    color: #E63946;
    background: #FFEAEA;
    padding: 0.75rem 1rem;
    border-radius: 8px;
    margin-top: 1rem;
    font-size: 0.9rem;
}

.success-message {
    color: #00B894;
    background: #E8FFF8;
    padding: 0.75rem 1rem;
    border-radius: 8px;
    margin-top: 1rem;
    font-size: 0.9rem;
}

.demo-info {
    margin-top: 1.5rem;
    padding: 1rem;
    background: #F8F9FA;
    border-radius: 8px;
    font-size: 0.85rem;
    color: #636E72;
}

.demo-info p {
    margin-bottom: 0.25rem;
}

/* ============================================================================
   ZONE SELECTION
   ============================================================================ */

.zone-selection {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    gap: 1.5rem;
    align-items: end;
}

@media (max-width: 768px) {
    .zone-selection {
        grid-template-columns: 1fr;
    }
}

.divider {
    display: flex;
    align-items: center;
    justify-content: center;
    color: #B2BEC3;
    font-weight: 500;
}

.divider span {
    background: white;
    padding: 0.5rem;
}

.current-zone {
    margin-top: 1.5rem;
    padding: 1rem;
    background: linear-gradient(135deg, #E8F4FD 0%, #D4EDFC 100%);
    border-radius: 8px;
    border-left: 4px solid #1D3557;
}

.current-zone strong {
    color: #1D3557;
}

/* ============================================================================
   SEARCH BUTTONS
   ============================================================================ */

.search-buttons {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
}

/* ============================================================================
   AI CARD
   ============================================================================ */

.ai-card {
    background: linear-gradient(135deg, #FFF9E6 0%, #FFF3CC 100%);
    border: 2px solid #F4A261;
}

.ai-card h2 {
    color: #E76F51;
}

.ai-card-attraction {
    background: linear-gradient(135deg, #E8F4FD 0%, #D4EDFC 100%);
    border: 2px solid #1D3557;
}

.ai-card-attraction h2 {
    color: #1D3557;
}

.ai-form {
    margin-top: 1rem;
}

.ai-form .form-row {
    margin-bottom: 1rem;
}

/* Attraction results styling */
.attraction-results {
    border-left-color: #1D3557;
    background: linear-gradient(135deg, #F0F7FC 0%, #E8F4FD 100%);
}

.attraction-card {
    border-left: 3px solid #1D3557;
}

/* ============================================================================
   RESULTS SECTION
   ============================================================================ */

.results-card {
    border-left: 4px solid #E63946;
}

.ai-results-card {
    border-left: 4px solid #F4A261;
    background: linear-gradient(135deg, #FFFBF5 0%, #FFF8EE 100%);
}

.results-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid #DFE6E9;
}

.results-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 1rem;
}

.result-card {
    background: #F8F9FA;
    border-radius: 8px;
    padding: 1.25rem;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.result-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.result-card h3 {
    color: #1D3557;
    margin-bottom: 0.5rem;
}

.result-address {
    font-size: 0.9rem;
    color: #636E72;
}

.result-intro,
.result-info {
    font-size: 0.9rem;
    color: #2D3436;
    margin: 0.5rem 0;
}

.result-details {
    font-size: 0.85rem;
    color: #636E72;
    margin: 0.75rem 0;
}

.result-details p {
    margin-bottom: 0.25rem;
}

.no-results {
    text-align: center;
    color: #636E72;
    padding: 2rem;
}

/* Visit Button States */
.visit-btn.visited {
    background: #00B894;
    color: white;
}

/* ============================================================================
   AI RECOMMENDATIONS
   ============================================================================ */

.ai-message {
    background: white;
    padding: 1rem;
    border-radius: 8px;
    margin-bottom: 1rem;
    font-size: 1rem;
    line-height: 1.6;
    border-left: 3px solid #F4A261;
}

.ai-results-grid {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.ai-result-card {
    display: flex;
    gap: 1rem;
    background: white;
    border-radius: 8px;
    padding: 1.25rem;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

.ai-rank {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    background: linear-gradient(135deg, #F4A261 0%, #E76F51 100%);
    color: white;
    font-size: 1.25rem;
    font-weight: 700;
    border-radius: 50%;
    flex-shrink: 0;
}

.ai-card-content {
    flex: 1;
}

.ai-card-content h3 {
    color: #1D3557;
    margin-bottom: 0.5rem;
}

.ai-reason {
    background: #FFF9E6;
    padding: 0.75rem;
    border-radius: 6px;
    font-size: 0.9rem;
    margin: 0.75rem 0;
    color: #E76F51;
}

/* ============================================================================
   ADMIN STYLES
   ============================================================================ */

.admin-body {
    background: #F0F2F5;
}

.admin-content {
    padding-top: 1rem;
}

.admin-tabs {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
}

.tab-btn {
    padding: 0.75rem 1.25rem;
    font-size: 0.95rem;
    font-weight: 500;
    background: white;
    border: 2px solid #DFE6E9;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.tab-btn:hover {
    border-color: #1D3557;
}

.tab-btn.active {
    background: #1D3557;
    color: white;
    border-color: #1D3557;
}

.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
}

.admin-form {
    max-width: 600px;
}

.form-result {
    margin-top: 1rem;
}

/* ============================================================================
   DATA TABLE
   ============================================================================ */

.table-container {
    margin-top: 1.5rem;
    overflow-x: auto;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}

.data-table th,
.data-table td {
    padding: 0.75rem 1rem;
    text-align: left;
    border-bottom: 1px solid #DFE6E9;
}

.data-table th {
    background: #1D3557;
    color: white;
    font-weight: 500;
    white-space: nowrap;
}

.data-table tr:hover {
    background: #F8F9FA;
}

.data-table td {
    max-width: 200px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.placeholder-text {
    text-align: center;
    color: #636E72;
    padding: 2rem;
}

/* ============================================================================
   CSV UPLOAD STYLES
   ============================================================================ */

.upload-section {
    margin-bottom: 2rem;
}

.upload-section h3 {
    color: #1D3557;
    margin-bottom: 1rem;
}

.csv-format-info {
    background: #F8F9FA;
    padding: 1rem;
    border-radius: 8px;
    margin-bottom: 1rem;
}

.csv-format-info code {
    display: block;
    background: #1D3557;
    color: #F4A261;
    padding: 0.75rem;
    border-radius: 4px;
    margin: 0.5rem 0;
    font-size: 0.85rem;
    overflow-x: auto;
}

.file-input {
    padding: 0.5rem;
    border: 2px dashed #DFE6E9;
    border-radius: 8px;
    cursor: pointer;
    transition: border-color 0.2s ease;
}

.file-input:hover {
    border-color: #1D3557;
}

.radio-group {
    display: flex;
    gap: 1.5rem;
    flex-wrap: wrap;
}

.radio-label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
    font-weight: normal;
}

.radio-label input[type="radio"] {
    width: auto;
    margin: 0;
}

.section-divider {
    border: none;
    border-top: 1px solid #DFE6E9;
    margin: 2rem 0;
}

.download-buttons {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
}

/* ============================================================================
   LOADING OVERLAY
   ============================================================================ */

.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.loading-spinner {
    background: white;
    padding: 2rem 3rem;
    border-radius: 12px;
    text-align: center;
}

.spinner {
    width: 40px;
    height: 40px;
    border: 4px solid #DFE6E9;
    border-top-color: #E63946;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 1rem;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* ============================================================================
   FOOTER
   ============================================================================ */

.app-footer {
    background: #1D3557;
    color: white;
    padding: 1.5rem 0;
    text-align: center;
    margin-top: auto;
}

.app-footer a {
    color: #F4A261;
}

.app-footer a:hover {
    color: #E76F51;
}

.credits {
    font-size: 0.9rem;
    opacity: 0.8;
    margin: 0.25rem 0;
}

/* ============================================================================
   RESPONSIVE DESIGN
   ============================================================================ */

@media (max-width: 768px) {
    html {
        font-size: 14px;
    }
    
    .app-header .container {
        flex-direction: column;
        text-align: center;
    }
    
    .card {
        padding: 1.25rem;
    }
    
    .form-actions {
        flex-direction: column;
    }
    
    .form-actions .btn {
        width: 100%;
    }
    
    .search-buttons {
        grid-template-columns: 1fr;
    }
    
    .results-grid {
        grid-template-columns: 1fr;
    }
    
    .ai-result-card {
        flex-direction: column;
        align-items: flex-start;
    }
    
    .admin-tabs {
        flex-direction: column;
    }
    
    .tab-btn {
        width: 100%;
        text-align: center;
    }
}

@media (max-width: 480px) {
    .container {
        padding: 0 0.75rem;
    }
    
    .btn-large {
        padding: 0.875rem 1.5rem;
        font-size: 1rem;
    }
}

/* ============================================================================
   ACCESSIBILITY
   ============================================================================ */

/* Focus styles for keyboard navigation */
:focus-visible {
    outline: 3px solid #E63946;
    outline-offset: 2px;
}

/* Reduce motion for users who prefer it */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
    
    html {
        scroll-behavior: auto;
    }
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .btn {
        border: 2px solid currentColor;
    }
    
    .card {
        border: 2px solid #2D3436;
    }
}
