/* CSS 變數定義 - Apple 風格 */
:root {
    /* Apple 色彩系統 */
    --primary-color: #007AFF;
    --success-color: #34c759;
    --danger-color: #ff3b30;
    --warning-color: #ff9500;
    --info-color: #5ac8fa;
    
    /* Apple 灰階系統 */
    --dark-color: #1d1d1f;
    --light-color: #f5f5f7;
    --background-color: #ffffff;
    --background-secondary: #f5f5f7;
    
    /* Apple 邊框和分隔線 */
    --border-color: rgba(0, 0, 0, 0.08);
    --separator-color: rgba(0, 0, 0, 0.05);
    
    /* Apple 陰影系統 */
    --shadow-light: 0 2px 8px rgba(0, 0, 0, 0.04);
    --shadow-medium: 0 4px 16px rgba(0, 0, 0, 0.08);
    --shadow-heavy: 0 8px 32px rgba(0, 0, 0, 0.12);
    
    /* Apple 文字顏色 */
    --text-primary: #1d1d1f;
    --text-secondary: #86868b;
    --text-tertiary: #aeaeb2;
    --text-quaternary: #c7c7cc;
    
    /* Apple 圓角系統 */
    --border-radius: 16px;
    --border-radius-large: 20px;
    --border-radius-small: 12px;
    --border-radius-button: 24px;
    
    /* Apple 過渡動畫 */
    --transition-standard: all 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    --transition-smooth: all 0.4s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    --transition-spring: all 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    
    /* Apple 字體系統 */
    --font-family-display: 'SF Pro Display', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    --font-family-text: 'SF Pro Text', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    --font-family-mono: 'SF Mono', 'Monaco', 'Menlo', 'Consolas', monospace;
    
    /* Apple 行高系統 */
    --line-height-tight: 1.2;
    --line-height-normal: 1.47059;
    --line-height-relaxed: 1.6;
}

/* 基礎樣式 */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: var(--font-family-text);
    line-height: var(--line-height-normal);
    color: var(--text-primary);
    background: var(--background-color);
    min-height: 100vh;
    margin: 0;
    padding: 48px 24px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

.container {
    max-width: 980px;
    margin: 0 auto;
    width: 100%;
    animation: fadeInUp 0.6s var(--transition-standard);
}

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

/* Header 區域 - Apple 風格 */
header {
    text-align: center;
    padding: 64px 0 80px 0;
    background: transparent;
}

h1 {
    font-family: var(--font-family-display);
    font-size: 3.5rem;
    font-weight: 600;
    line-height: var(--line-height-tight);
    color: var(--text-primary);
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 16px;
    letter-spacing: -0.02em;
}

.aws-icon {
    font-size: 3.5rem;
    filter: grayscale(1) brightness(0.8);
}

.subtitle {
    font-family: var(--font-family-text);
    font-size: 1.375rem;
    font-weight: 400;
    line-height: var(--line-height-normal);
    color: var(--text-secondary);
    max-width: 520px;
    margin: 0 auto;
    letter-spacing: -0.01em;
}

/* 主內容 - Apple 風格 */
main {
    padding: 0;
}

.search-section {
    margin-bottom: 64px;
    max-width: 600px;
    margin-left: auto;
    margin-right: auto;
}

.input-group {
    display: flex;
    gap: 16px;
    margin-bottom: 12px;
    align-items: stretch;
}

#ip-input {
    flex: 1;
    padding: 20px 24px;
    font-size: 1.125rem;
    font-family: var(--font-family-mono);
    font-weight: 400;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-small);
    outline: none;
    background: var(--background-color);
    color: var(--text-primary);
    transition: var(--transition-standard);
    box-shadow: var(--shadow-light);
    height: 56px;
}

#ip-input:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 4px rgba(0, 122, 255, 0.15), var(--shadow-light);
    background: var(--background-color);
}

#ip-input.error {
    border-color: var(--danger-color);
    box-shadow: 0 0 0 4px rgba(255, 59, 48, 0.15), var(--shadow-light);
}

#search-btn {
    padding: 0 32px;
    height: 56px;
    background: var(--primary-color);
    color: white;
    border: none;
    border-radius: var(--border-radius-button);
    font-family: var(--font-family-text);
    font-size: 1.125rem;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition-standard);
    white-space: nowrap;
    min-width: 120px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: var(--shadow-light);
    letter-spacing: -0.01em;
}

#search-btn:hover:not(:disabled) {
    background: #0056cc;
    transform: scale(1.02);
    box-shadow: var(--shadow-medium);
}

#search-btn:active:not(:disabled) {
    transform: scale(0.98);
    transition: var(--transition-standard);
}

#search-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    transform: none;
    box-shadow: var(--shadow-light);
}

.input-help {
    font-family: var(--font-family-text);
    font-size: 1rem;
    color: var(--text-secondary);
    text-align: center;
    line-height: var(--line-height-normal);
    margin-top: 8px;
}

/* 載入動畫 - Apple 風格 */
.spinner {
    width: 20px;
    height: 20px;
    border: 2px solid rgba(255, 255, 255, 0.2);
    border-top: 2px solid white;
    border-radius: 50%;
    animation: spin 1s ease-in-out infinite;
}

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

/* 結果區域 - Apple 風格 */
.result-section {
    animation: slideIn 0.4s var(--transition-standard);
    max-width: 700px;
    margin: 0 auto;
}

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

.result-card {
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    padding: 32px;
    background: var(--background-secondary);
    box-shadow: var(--shadow-light);
    backdrop-filter: blur(20px);
}

.result-card.success {
    border-color: rgba(52, 199, 89, 0.3);
    background: rgba(52, 199, 89, 0.08);
    box-shadow: var(--shadow-medium);
}

.result-card.danger {
    border-color: rgba(255, 59, 48, 0.3);
    background: rgba(255, 59, 48, 0.08);
    box-shadow: var(--shadow-medium);
}

.result-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 24px;
    flex-wrap: wrap;
    gap: 16px;
}

.result-status {
    display: flex;
    align-items: center;
    gap: 12px;
}

.result-icon {
    font-size: 1.5rem;
}

.result-title {
    font-family: var(--font-family-display);
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--text-primary);
    line-height: var(--line-height-tight);
    letter-spacing: -0.01em;
}

.result-ip {
    font-family: var(--font-family-mono);
    font-size: 1rem;
    font-weight: 500;
    background: var(--background-color);
    color: var(--text-primary);
    padding: 12px 16px;
    border-radius: var(--border-radius-small);
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-light);
}

.result-details {
    border-top: 1px solid var(--separator-color);
    padding-top: 24px;
    margin-top: 8px;
}

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

.detail-item:last-child {
    border-bottom: none;
}

.label {
    font-family: var(--font-family-text);
    font-weight: 500;
    font-size: 1rem;
    color: var(--text-secondary);
    line-height: var(--line-height-normal);
}

.value {
    font-family: var(--font-family-mono);
    font-weight: 600;
    font-size: 0.9375rem;
    color: var(--text-primary);
    text-align: right;
}

/* 錯誤區域 - Apple 風格 */
.error-section {
    animation: slideIn 0.4s var(--transition-standard);
    max-width: 600px;
    margin: 0 auto;
}

.error-card {
    border: 1px solid rgba(255, 59, 48, 0.3);
    border-radius: var(--border-radius);
    padding: 40px 32px;
    text-align: center;
    background: rgba(255, 59, 48, 0.08);
    backdrop-filter: blur(20px);
    box-shadow: var(--shadow-medium);
}

.error-icon {
    font-size: 3rem;
    margin-bottom: 20px;
    filter: grayscale(0.2);
}

.error-content h3 {
    font-family: var(--font-family-display);
    font-size: 1.5rem;
    font-weight: 600;
    margin-bottom: 12px;
    color: var(--danger-color);
    line-height: var(--line-height-tight);
    letter-spacing: -0.01em;
}

.error-content p {
    font-family: var(--font-family-text);
    color: var(--text-secondary);
    margin-bottom: 24px;
    line-height: var(--line-height-normal);
    font-size: 1rem;
}

.retry-btn {
    padding: 0 24px;
    height: 48px;
    background: var(--danger-color);
    color: white;
    border: none;
    border-radius: var(--border-radius-button);
    font-family: var(--font-family-text);
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition-standard);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 100px;
    box-shadow: var(--shadow-light);
}

.retry-btn:hover {
    background: #d70015;
    transform: scale(1.02);
    box-shadow: var(--shadow-medium);
}

.retry-btn:active {
    transform: scale(0.98);
}

/* Footer - Apple 風格 */
footer {
    background: transparent;
    padding: 80px 0 48px 0;
    margin-top: 80px;
    max-width: 980px;
    margin-left: auto;
    margin-right: auto;
}

.stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 32px;
    margin-bottom: 40px;
    padding-bottom: 40px;
    border-bottom: 1px solid var(--separator-color);
}

.stat-item {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.stat-label {
    font-family: var(--font-family-text);
    font-size: 0.9375rem;
    color: var(--text-secondary);
    font-weight: 500;
    line-height: var(--line-height-normal);
}

.stat-value {
    font-family: var(--font-family-text);
    font-size: 1rem;
    color: var(--text-primary);
    font-weight: 600;
    line-height: var(--line-height-normal);
}

.footer-info {
    text-align: center;
    padding-top: 32px;
}

.footer-info p {
    font-family: var(--font-family-text);
    font-size: 0.9375rem;
    color: var(--text-tertiary);
    margin: 8px 0;
    line-height: var(--line-height-normal);
}

.footer-info a {
    color: var(--primary-color);
    text-decoration: none;
    font-weight: 500;
    transition: var(--transition-standard);
}

.footer-info a:hover {
    color: #0056cc;
    text-decoration: none;
}

/* 響應式設計 - Apple 風格 */
@media (max-width: 1024px) {
    body {
        padding: 32px 20px;
    }
    
    header {
        padding: 48px 0 64px 0;
    }
    
    footer {
        padding: 64px 0 40px 0;
        margin-top: 64px;
    }
}

@media (max-width: 768px) {
    body {
        padding: 24px 16px;
    }
    
    header {
        padding: 40px 0 56px 0;
    }
    
    h1 {
        font-size: 2.5rem;
        flex-direction: column;
        gap: 12px;
    }
    
    .aws-icon {
        font-size: 2.5rem;
    }
    
    .subtitle {
        font-size: 1.25rem;
    }
    
    .search-section {
        margin-bottom: 48px;
    }
    
    .input-group {
        flex-direction: column;
        gap: 12px;
    }
    
    #search-btn {
        width: 100%;
        height: 52px;
    }
    
    .result-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 16px;
    }
    
    .result-title {
        font-size: 1.375rem;
    }
    
    .detail-item {
        flex-direction: column;
        align-items: flex-start;
        gap: 6px;
        padding: 16px 0;
    }
    
    .value {
        text-align: left;
    }
    
    footer {
        padding: 48px 0 32px 0;
        margin-top: 48px;
    }
    
    .stats {
        grid-template-columns: 1fr;
        gap: 24px;
        margin-bottom: 32px;
        padding-bottom: 32px;
    }
}

@media (max-width: 428px) {
    body {
        padding: 20px 16px;
    }
    
    header {
        padding: 32px 0 48px 0;
    }
    
    h1 {
        font-size: 2rem;
    }
    
    .aws-icon {
        font-size: 2rem;
    }
    
    .subtitle {
        font-size: 1.125rem;
    }
    
    #ip-input {
        font-size: 16px; /* 防止 iOS Safari 縮放 */
        height: 52px;
        padding: 18px 20px;
    }
    
    #search-btn {
        height: 52px;
        font-size: 1rem;
    }
    
    .result-card, .error-card {
        padding: 24px 20px;
    }
    
    .result-title {
        font-size: 1.25rem;
    }
    
    footer {
        padding: 40px 0 24px 0;
        margin-top: 40px;
    }
}