/* Google Fonts */
@import url('https://fonts.googleapis.com/css2?family=Pretendard:wght@300;400;500;600;700&family=Outfit:wght@300;400;600&display=swap');

/* Reset & Scaffolding */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

:root {
    --bg-color: #0f0f13;
    --card-bg: rgba(20, 20, 30, 0.6);
    --card-border: rgba(255, 255, 255, 0.1);
    --text-primary: #ffffff;
    --text-secondary: #a0a0b0;
    --accent-color: #00A84D;
    --font-main: 'Pretendard', -apple-system, BlinkMacSystemFont, system-ui, Roboto, sans-serif;
    --font-accent: 'Outfit', sans-serif;

    /* Effects */
    --glass-blur: blur(12px);
    --shadow-sm: 0 4px 12px rgba(0, 0, 0, 0.2);
    --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.4);
    --glow: 0 0 15px rgba(0, 168, 77, 0.4);
}

body {
    background-color: var(--bg-color);
    background-image:
        linear-gradient(rgba(0, 0, 0, 0.7), rgba(0, 0, 0, 0.8)),
        url('https://images.unsplash.com/photo-1494587416117-f101a292419d?q=80&w=2000&auto=format&fit=crop');
    background-size: cover;
    background-position: center;
    background-attachment: fixed;
    color: var(--text-primary);
    font-family: var(--font-main);
    display: flex;
    justify-content: center;
    min-height: 100vh;
    padding: 2rem 1rem;
}

.app-container {
    width: 100%;
    max-width: 600px;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

/* Header */
header {
    text-align: center;
    margin-bottom: 2rem;
    padding: 2rem;
    background: rgba(0, 0, 0, 0.4);
    backdrop-filter: var(--glass-blur);
    border-radius: 24px;
    border: 1px solid var(--card-border);
    box-shadow: var(--shadow-sm);
}

header .logo {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.8rem;
    margin-bottom: 0.5rem;
}

header i {
    font-size: 2.2rem;
    color: var(--accent-color);
    filter: drop-shadow(0 0 8px var(--accent-color));
}

header h1 {
    font-family: var(--font-accent);
    font-weight: 700;
    font-size: 2.5rem;
    background: linear-gradient(135deg, #fff 0%, #aaa 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    letter-spacing: -0.03em;
}

header p {
    color: var(--text-secondary);
    font-size: 1rem;
    font-weight: 300;
}

/* Search Section */
.search-container {
    background: var(--card-bg);
    padding: 0.8rem;
    border-radius: 20px;
    border: 1px solid var(--card-border);
    backdrop-filter: var(--glass-blur);
    display: flex;
    gap: 0.8rem;
    box-shadow: var(--shadow-md);
    transition: transform 0.3s, box-shadow 0.3s;
}

.search-container:focus-within {
    border-color: rgba(255, 255, 255, 0.3);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5), var(--glow);
    transform: translateY(-2px);
}

.input-wrapper {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 0.8rem;
    padding: 0 1rem;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 14px;
}

.input-wrapper i {
    color: var(--text-secondary);
}

#station-input {
    background: transparent;
    border: none;
    outline: none;
    color: white;
    font-size: 1.1rem;
    width: 100%;
    padding: 1rem 0;
    font-family: var(--font-main);
}

#station-input::placeholder {
    color: rgba(255, 255, 255, 0.3);
}

#search-btn {
    background: linear-gradient(135deg, var(--accent-color), #008f41);
    color: white;
    border: none;
    padding: 0 1.8rem;
    border-radius: 14px;
    font-weight: 600;
    font-size: 1rem;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 4px 15px rgba(0, 168, 77, 0.3);
}

#search-btn:active {
    transform: scale(0.96);
}

/* API Settings */
.api-key-section {
    text-align: center;
}

#toggle-api-settings {
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid var(--card-border);
    color: var(--text-secondary);
    padding: 0.5rem 1rem;
    border-radius: 20px;
    cursor: pointer;
    font-size: 0.8rem;
    transition: all 0.3s;
}

#toggle-api-settings:hover {
    background: rgba(255, 255, 255, 0.1);
    color: white;
}

.api-settings {
    margin-top: 1rem;
    background: var(--card-bg);
    padding: 1rem;
    border-radius: 16px;
    border: 1px solid var(--card-border);
    backdrop-filter: var(--glass-blur);
    text-align: left;
}

.api-settings.hidden {
    display: none;
}

#api-key-input {
    width: 100%;
    margin-top: 0.5rem;
    padding: 0.8rem;
    background: rgba(0, 0, 0, 0.4);
    border: 1px solid var(--card-border);
    border-radius: 10px;
    color: #fff;
    font-size: 0.9rem;
}

/* Loading & Error */
#loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 3rem;
    color: var(--text-secondary);
}

.loader {
    width: 48px;
    height: 48px;
    border: 5px solid rgba(255, 255, 255, 0.1);
    border-bottom-color: var(--accent-color);
    border-radius: 50%;
    display: inline-block;
    box-sizing: border-box;
    animation: rotation 1s linear infinite;
    margin-bottom: 1rem;
}

@keyframes rotation {
    0% {
        transform: rotate(0deg);
    }

    100% {
        transform: rotate(360deg);
    }
}

#error-message {
    background: rgba(255, 59, 48, 0.1);
    border: 1px solid rgba(255, 59, 48, 0.2);
    color: #ff3b30;
    padding: 1.5rem;
    border-radius: 16px;
    text-align: center;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.8rem;
    backdrop-filter: var(--glass-blur);
}

.hidden {
    display: none !important;
}


/* Results Grid */
.results-grid {
    display: flex;
    flex-direction: column;
    gap: 1.2rem;
    padding-bottom: 3rem;
}

.welcome-message {
    text-align: center;
    color: var(--text-secondary);
    padding: 4rem 1rem;
    background: rgba(0, 0, 0, 0.2);
    border-radius: 24px;
    border: 1px dashed var(--card-border);
}

.welcome-message i {
    font-size: 4rem;
    margin-bottom: 1.5rem;
    opacity: 0.3;
}

/* Train Card */
.train-card {
    background: var(--card-bg);
    /* Translucent dark */
    border: 1px solid var(--card-border);
    border-radius: 20px;
    overflow: hidden;
    position: relative;
    backdrop-filter: blur(20px);
    box-shadow: var(--shadow-sm);
    transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
    display: flex;
    flex-direction: column;
    animation: slideIn 0.5s cubic-bezier(0.2, 0.8, 0.2, 1) forwards;
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(30px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.train-card:hover {
    transform: translateY(-5px) scale(1.02);
    box-shadow: var(--shadow-md), 0 0 20px rgba(0, 0, 0, 0.2);
    border-color: rgba(255, 255, 255, 0.3);
    z-index: 10;
}


/* Card Header: Image Area */
.card-image-area {
    height: 140px;
    width: 100%;
    position: relative;
    overflow: hidden;
}

.card-image-area::after {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: var(--line-color);
    mix-blend-mode: overlay;
    opacity: 0.6;
    z-index: 1;
}

.train-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.5s;
    filter: grayscale(100%) contrast(1.1);
}

.train-card:hover .train-image {
    transform: scale(1.1);
}

.image-overlay {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(to top, rgba(0, 0, 0, 0.9) 0%, rgba(0, 0, 0, 0) 60%);
    display: flex;
    align-items: flex-end;
    padding: 1.2rem;
    z-index: 2;
    /* Ensure text is above tint */
}

.line-tag {
    background: var(--line-color);
    color: white;
    padding: 0.3rem 0.8rem;
    border-radius: 30px;
    font-size: 0.8rem;
    font-weight: 700;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
    margin-right: auto;
    /* Push others to right */
    position: absolute;
    top: 1rem;
    left: 1rem;
    z-index: 3;
    /* Above everything */
}

/* Card Content: Info Area */
.card-content {
    padding: 1.2rem;
    position: relative;
}

.train-dest-wrapper {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.5rem;
}

.train-destination {
    font-size: 1.6rem;
    font-weight: 700;
    color: #fff;
    letter-spacing: -0.5px;
}

.train-status-badge {
    font-size: 0.75rem;
    padding: 0.25rem 0.6rem;
    border-radius: 6px;
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-secondary);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.is-express {
    color: #ff4d4d;
    background: rgba(255, 77, 77, 0.15);
    border-color: rgba(255, 77, 77, 0.3);
}

.arrival-section {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-top: 1rem;
}

.time-box {
    background: rgba(0, 0, 0, 0.3);
    padding: 0.5rem 1rem;
    border-radius: 12px;
    border: 1px solid var(--card-border);
}

.arrival-time {
    font-size: 1.3rem;
    font-weight: 600;
    color: var(--accent-color);
    text-shadow: 0 0 10px rgba(0, 168, 77, 0.3);
}

.current-loc {
    font-size: 0.9rem;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.current-loc i {
    color: var(--accent-color);
}

/* Footer */
footer {
    margin-top: auto;
    text-align: center;
    color: rgba(255, 255, 255, 0.3);
    font-size: 0.8rem;
    padding-top: 2rem;
}

/* Responsive */
@media (max-width: 480px) {
    .app-container {
        padding: 0;
        gap: 1rem;
    }

    header {
        margin: 1rem;
        padding: 1.5rem;
    }

    .search-container {
        margin: 0 1rem;
    }

    .results-grid {
        padding: 0 1rem 2rem 1rem;
    }

    .card-image-area {
        height: 120px;
    }
}
/* Schematic Map View Styles */
.station-monitor {
    display: flex;
    flex-direction: column;
    gap: 2rem;
    width: 100%;
}

.line-section {
    background: rgba(20, 20, 30, 0.7);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 20px;
    padding: 1.5rem;
    backdrop-filter: blur(16px);
    box-shadow: 0 8px 32px rgba(0,0,0,0.3);
    overflow: hidden;
    position: relative;
    margin-bottom: 2rem;
}

.line-header {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 2rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.line-badge {
    padding: 0.4rem 1rem;
    border-radius: 30px;
    font-weight: 700;
    color: white;
    font-size: 0.9rem;
    box-shadow: 0 2px 8px rgba(0,0,0,0.2);
}

.line-name {
    font-size: 1.2rem;
    font-weight: 600;
    color: white;
}

.track-container {
    position: relative;
    height: 120px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 1rem 0;
}

/* The horizontal rail */
.rail {
    position: absolute;
    width: 100%;
    height: 8px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 4px;
    z-index: 1;
}

.rail::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--line-color);
    border-radius: 4px;
    opacity: 0.6;
}

/* The Main Station Node (Center) */
.station-node {
    position: relative;
    z-index: 2;
    background: var(--bg-color);
    border: 4px solid var(--line-color);
    width: 60px;
    height: 60px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 0 20px rgba(0,0,0,0.5);
}

.station-node i {
    color: white;
    font-size: 1.5rem;
}

.station-label {
    position: absolute;
    top: 70px;
    left: 50%;
    transform: translateX(-50%);
    white-space: nowrap;
    font-weight: 600;
    color: white;
    font-size: 1.1rem;
    text-shadow: 0 2px 4px rgba(0,0,0,0.8);
}

/* Floating Train */
.train-icon {
    position: absolute;
    top: 50%;
    transform: translate(-50%, -50%); /* Center the icon on the point */
    z-index: 10;
    display: flex;
    flex-direction: column;
    align-items: center;
    cursor: pointer;
    transition: left 1s ease-in-out;
}

.train-body {
    background: white;
    padding: 0.4rem 0.6rem;
    border-radius: 12px;
    border: 2px solid var(--line-color);
    display: flex;
    align-items: center;
    gap: 0.4rem;
    box-shadow: 0 4px 10px rgba(0,0,0,0.5);
    min-width: 80px;
    justify-content: center;
}

.train-body i {
    color: var(--line-color);
    font-size: 1rem;
}

.train-info {
    display: flex;
    flex-direction: column;
    font-size: 0.7rem;
    line-height: 1.1;
    text-align: left;
}

.train-dest {
    font-weight: 700;
    color: #222;
}

.train-status {
    color: #666;
    font-size: 0.65rem;
}

/* Direction Labels */
.direction-label {
    position: absolute;
    top: -30px;
    font-size: 0.8rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 1px;
    font-weight: 600;
}
.direction-left { left: 10px; }
.direction-right { right: 10px; }


/* Updated Schematic Map View Styles for Center Alignment */
.station-monitor {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    width: 100%;
}

.line-section {
    background: #121215; 
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 20px;
    padding: 1.5rem 2rem;
    box-shadow: 0 4px 20px rgba(0,0,0,0.5);
    position: relative;
    overflow: visible; 
    margin-bottom: 1rem;
}

.line-header {
    display: flex;
    align-items: center;
    gap: 0.8rem;
    margin-bottom: 2rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.line-badge {
    padding: 0.3rem 0.8rem;
    border-radius: 20px;
    font-weight: 700;
    color: white;
    font-size: 0.9rem;
    box-shadow: 0 2px 5px rgba(0,0,0,0.3);
}

.line-name {
    font-size: 1.4rem;
    font-weight: 700;
    color: white;
}

.track-row {
    position: relative;
    margin-bottom: 4rem; 
}

/* Direction Labels */
.track-row .direction-label {
    top: -25px; 
    left: 0;
    position: absolute;
    font-size: 0.95rem;
    color: #aeaeae;
    font-weight: 500;
}

/* Track Container */
.track-container {
    position: relative;
    height: 60px; 
    display: flex;
    align-items: center;
}

/* The Rail */
.rail {
    position: absolute;
    width: 100%;
    height: 6px;
    background: rgba(255, 255, 255, 0.15);
    border-radius: 3px;
    z-index: 1;
}

.rail::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--line-color);
    opacity: 0.8;
    border-radius: 3px;
}

/* Station Node (CENTERED) */
.station-node {
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    z-index: 5;
    background: #121215; 
    border: 3px solid var(--line-color);
    width: 50px;
    height: 50px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 0 0 5px #121215; 
}

.station-node i {
    color: white;
    font-size: 1.4rem;
}

.station-label {
    position: absolute;
    top: 60px;
    left: 50%;
    transform: translateX(-50%);
    white-space: nowrap;
    font-weight: 700;
    color: white;
    font-size: 1.1rem;
    text-shadow: 0 2px 5px rgba(0,0,0,0.8);
}

/* Train Tooltip Styles */
.train-icon {
    position: absolute;
    bottom: 30px; 
    z-index: 10;
    display: flex;
    flex-direction: column;
    align-items: center;
    transform: translateX(-50%); 
    transition: left 1s ease-in-out;
}

.train-body {
    background: white;
    color: #111;
    padding: 0.7rem 1.2rem;
    border-radius: 14px;
    border: 2px solid var(--line-color);
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 0.8rem;
    box-shadow: 0 4px 15px rgba(0,0,0,0.5);
    min-width: 160px;
    justify-content: space-between;
}

.train-info-group {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
}

.train-dest {
    font-weight: 800;
    font-size: 0.95rem;
    color: #000;
    white-space: nowrap;
}

.train-status {
    color: #555;
    font-size: 0.85rem;
    font-weight: 600;
    margin-top: 2px;
}

/* Little triangle/caret pointing down */
.train-caret {
    width: 0; 
    height: 0; 
    border-left: 8px solid transparent;
    border-right: 8px solid transparent;
    border-top: 8px solid white;
    filter: drop-shadow(0 2px 1px rgba(0,0,0,0.1));
}

.train-symbol {
    color: var(--line-color);
    font-size: 1.4rem;
}


/* Schematic Map View Styles for Center Alignment with Images and Alternating Labels */
.station-monitor {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    width: 100%;
}

.line-section {
    background: #121215; 
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 20px;
    padding: 2rem 2rem;
    box-shadow: 0 4px 20px rgba(0,0,0,0.5);
    position: relative;
    margin-bottom: 2rem;
}

.line-header {
    display: flex;
    align-items: center;
    gap: 0.8rem;
    margin-bottom: 3rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.line-badge {
    padding: 0.3rem 0.8rem;
    border-radius: 20px;
    font-weight: 700;
    color: white;
    font-size: 0.9rem;
    box-shadow: 0 2px 5px rgba(0,0,0,0.3);
}

.line-name {
    font-size: 1.4rem;
    font-weight: 700;
    color: white;
}

.track-row {
    position: relative;
    margin-bottom: 8rem;
    min-height: 120px;
}

.track-row .direction-label {
    position: absolute;
    top: -40px; 
    left: 0;
    font-size: 1rem;
    color: #aeaeae;
    font-weight: 600;
}

.track-container {
    position: relative;
    height: 10px;
    top: 60px;
    display: flex;
    align-items: center;
}

.rail {
    position: absolute;
    width: 100%;
    height: 8px;
    background: rgba(255, 255, 255, 0.15);
    border-radius: 4px;
    z-index: 1;
}

.rail::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--line-color);
    opacity: 0.6;
    border-radius: 4px;
}

.station-node {
    position: absolute;
    left: 50%;
    transform: translate(-50%, -50%); 
    top: 50%;
    z-index: 5;
    background: #121215; 
    border: 4px solid var(--line-color);
    width: 60px;
    height: 60px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 0 0 6px #121215;
}

.station-node i {
    color: white;
    font-size: 1.8rem;
}

.station-label {
    position: absolute;
    top: 70px;
    left: 50%;
    transform: translateX(-50%);
    white-space: nowrap;
    font-weight: 800;
    color: white;
    font-size: 1.2rem;
    text-shadow: 0 2px 5px rgba(0,0,0,0.8);
    background: rgba(0,0,0,0.6);
    padding: 0.2rem 0.8rem;
    border-radius: 12px;
}

.train-icon {
    position: absolute;
    top: 50%;
    transform: translate(-50%, -50%);
    z-index: 10;
    width: 20px;
    height: 20px;
    display: flex;
    justify-content: center;
    transition: left 1s ease-in-out;
}

.train-marker {
    width: 16px;
    height: 16px;
    background: var(--line-color);
    border: 3px solid white;
    border-radius: 50%;
    box-shadow: 0 0 10px rgba(0,0,0,0.5);
    position: relative;
    z-index: 12;
}

.train-info-box {
    position: absolute;
    width: 240px;
    background: white;
    border-radius: 16px;
    padding: 0.8rem;
    box-shadow: 0 8px 24px rgba(0,0,0,0.6);
    display: flex;
    align-items: center;
    gap: 0.8rem;
    z-index: 11;
    border: 2px solid var(--line-color);
}

.train-thumbnail {
    width: 60px;
    height: 60px;
    border-radius: 10px;
    object-fit: cover;
    flex-shrink: 0;
    background: #eee;
}

.train-text-content {
    display: flex;
    flex-direction: column;
    flex: 1;
    overflow: hidden;
}

.train-dest {
    color: #111;
    font-weight: 800;
    font-size: 1rem;
    margin-bottom: 0.2rem;
    white-space: nowrap;
    text-overflow: ellipsis;
    overflow: hidden;
}

.train-status {
    color: #555;
    font-size: 0.9rem;
    font-weight: 600;
}

.train-tag {
    display: inline-block;
    font-size: 0.7rem;
    padding: 2px 6px;
    border-radius: 4px;
    margin-top: 4px;
    align-self: flex-start;
}

.tag-express {
    background: #ff4d4d;
    color: white;
}

.tag-normal {
    display: none;
}

.train-icon.pos-up .train-info-box {
    bottom: 25px;
}

.train-icon.pos-up .train-info-box::after {
    content: '';
    position: absolute;
    bottom: -8px;
    left: 50%;
    transform: translateX(-50%);
    border-left: 8px solid transparent;
    border-right: 8px solid transparent;
    border-top: 8px solid white;
}

.train-icon.pos-down .train-info-box {
    top: 25px;
}

.train-icon.pos-down .train-info-box::after {
    content: '';
    position: absolute;
    top: -8px;
    left: 50%;
    transform: translateX(-50%);
    border-left: 8px solid transparent;
    border-right: 8px solid transparent;
    border-bottom: 8px solid white;
}

