/* ===================================================
   Tokutei - 位置情報トラッキングツール
   Global Styles
   =================================================== */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&family=JetBrains+Mono:wght@400;500;600&display=swap');

/* ── Reset & Base ────────────────────────────── */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --bg-primary: #0a0a0f;
    --bg-secondary: #12121a;
    --bg-card: rgba(18, 18, 26, 0.85);
    --bg-card-hover: rgba(24, 24, 36, 0.9);
    --surface: rgba(255, 255, 255, 0.04);
    --surface-hover: rgba(255, 255, 255, 0.08);

    --text-primary: #e8e8ed;
    --text-secondary: #8b8b9e;
    --text-muted: #55556a;

    --accent-cyan: #00d4ff;
    --accent-purple: #8b5cf6;
    --accent-green: #10b981;
    --accent-orange: #f59e0b;
    --accent-pink: #ec4899;
    --accent-red: #ef4444;

    --gradient-primary: linear-gradient(135deg, #00d4ff 0%, #8b5cf6 100%);
    --gradient-dark: linear-gradient(135deg, #0a0a0f 0%, #1a1a2e 100%);

    --border: rgba(255, 255, 255, 0.06);
    --border-focus: rgba(0, 212, 255, 0.4);

    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 24px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 8px 48px rgba(0, 0, 0, 0.5);
    --shadow-glow: 0 0 40px rgba(0, 212, 255, 0.15);

    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 24px;

    --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    --font-mono: 'JetBrains Mono', 'Consolas', monospace;

    --transition: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

html {
    font-size: 16px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    font-family: var(--font-sans);
    background: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    line-height: 1.6;
    overflow-x: hidden;
}

a {
    color: var(--accent-cyan);
    text-decoration: none;
    transition: var(--transition);
}

a:hover {
    color: #33dfff;
    text-shadow: 0 0 8px rgba(0, 212, 255, 0.3);
}

/* ── Background Effects ───────────────────────── */
.bg-grid {
    position: fixed;
    inset: 0;
    background-image:
        linear-gradient(rgba(255, 255, 255, 0.02) 1px, transparent 1px),
        linear-gradient(90deg, rgba(255, 255, 255, 0.02) 1px, transparent 1px);
    background-size: 60px 60px;
    pointer-events: none;
    z-index: 0;
}

.bg-glow {
    position: fixed;
    width: 600px;
    height: 600px;
    border-radius: 50%;
    filter: blur(120px);
    opacity: 0.12;
    pointer-events: none;
    z-index: 0;
}

.bg-glow-1 {
    top: -200px;
    right: -100px;
    background: var(--accent-cyan);
}

.bg-glow-2 {
    bottom: -200px;
    left: -100px;
    background: var(--accent-purple);
}

/* ── Container ────────────────────────────────── */
.container {
    max-width: 900px;
    margin: 0 auto;
    padding: 2rem;
    position: relative;
    z-index: 1;
}

/* ── Header ───────────────────────────────────── */
.header {
    text-align: center;
    padding: 3rem 0 2rem;
}

.header__icon {
    font-size: 3rem;
    margin-bottom: 1rem;
    display: inline-block;
    animation: float 3s ease-in-out infinite;
}

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

.header__title {
    font-size: 2rem;
    font-weight: 700;
    background: var(--gradient-primary);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    letter-spacing: -0.02em;
    margin-bottom: 0.5rem;
}

.header__subtitle {
    font-size: 0.9rem;
    color: var(--text-secondary);
    font-weight: 400;
}

/* ── Card ─────────────────────────────────────── */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 2rem;
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    box-shadow: var(--shadow-md);
    transition: var(--transition);
}

.card:hover {
    border-color: rgba(255, 255, 255, 0.1);
    box-shadow: var(--shadow-lg);
}

.card + .card {
    margin-top: 1.5rem;
}

.card__title {
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: 1.25rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.card__title::before {
    content: '';
    width: 3px;
    height: 1.1em;
    background: var(--gradient-primary);
    border-radius: 2px;
}

/* ── Form ─────────────────────────────────────── */
.form-group {
    margin-bottom: 1.25rem;
}

.form-label {
    display: block;
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    margin-bottom: 0.5rem;
}

.form-input {
    width: 100%;
    padding: 0.85rem 1rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-family: var(--font-mono);
    font-size: 0.9rem;
    transition: var(--transition);
    outline: none;
}

.form-input::placeholder {
    color: var(--text-muted);
}

.form-input:focus {
    border-color: var(--border-focus);
    box-shadow: 0 0 0 3px rgba(0, 212, 255, 0.08), inset 0 0 0 1px rgba(0, 212, 255, 0.1);
    background: rgba(255, 255, 255, 0.06);
}

/* ── Buttons ──────────────────────────────────── */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.8rem 1.8rem;
    border: none;
    border-radius: var(--radius-sm);
    font-family: var(--font-sans);
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    position: relative;
    overflow: hidden;
}

.btn-primary {
    background: var(--gradient-primary);
    color: #fff;
    box-shadow: 0 4px 16px rgba(0, 212, 255, 0.25);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 24px rgba(0, 212, 255, 0.35);
}

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

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

.btn-secondary:hover {
    background: var(--surface-hover);
    border-color: rgba(255, 255, 255, 0.12);
}

.btn-sm {
    padding: 0.5rem 1rem;
    font-size: 0.8rem;
}

.btn-block {
    width: 100%;
}

/* ── Result Box ───────────────────────────────── */
.result-box {
    display: none;
    margin-top: 1.5rem;
    animation: fadeSlideIn 0.4s ease;
}

.result-box.active {
    display: block;
}

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

.result-item {
    background: rgba(0, 212, 255, 0.04);
    border: 1px solid rgba(0, 212, 255, 0.12);
    border-radius: var(--radius-sm);
    padding: 1rem 1.25rem;
    margin-bottom: 0.75rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
}

.result-item__label {
    font-size: 0.75rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    white-space: nowrap;
}

.result-item__value {
    font-family: var(--font-mono);
    font-size: 0.85rem;
    color: var(--accent-cyan);
    word-break: break-all;
    flex: 1;
    text-align: right;
}

.result-item__copy {
    cursor: pointer;
    font-size: 1rem;
    opacity: 0.5;
    transition: var(--transition);
    flex-shrink: 0;
}

.result-item__copy:hover {
    opacity: 1;
}

.result-item__copy.copied {
    color: var(--accent-green);
    opacity: 1;
}

/* ── Toast / Notification ─────────────────────── */
.toast {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    padding: 0.8rem 1.5rem;
    background: var(--bg-card);
    border: 1px solid var(--accent-green);
    border-radius: var(--radius-sm);
    color: var(--accent-green);
    font-size: 0.85rem;
    font-weight: 500;
    box-shadow: var(--shadow-lg), 0 0 20px rgba(16, 185, 129, 0.15);
    transform: translateY(100px);
    opacity: 0;
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 9999;
}

.toast.show {
    transform: translateY(0);
    opacity: 1;
}

/* ── History Table ────────────────────────────── */
.history-list {
    list-style: none;
}

.history-item {
    padding: 0.8rem 1rem;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    font-size: 0.85rem;
    transition: var(--transition);
}

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

.history-item:hover {
    background: var(--surface);
    border-radius: var(--radius-sm);
}

.history-item__url {
    font-family: var(--font-mono);
    font-size: 0.8rem;
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    flex: 1;
    min-width: 0;
}

.history-item__date {
    font-size: 0.75rem;
    color: var(--text-muted);
    white-space: nowrap;
}

.history-item__actions {
    display: flex;
    gap: 0.5rem;
    flex-shrink: 0;
}

/* ── Empty State ──────────────────────────────── */
.empty-state {
    text-align: center;
    padding: 3rem 1rem;
    color: var(--text-muted);
}

.empty-state__icon {
    font-size: 2.5rem;
    margin-bottom: 1rem;
    opacity: 0.5;
}

.empty-state__text {
    font-size: 0.9rem;
}

/* ── View Page (Terminal Style) ───────────────── */
.terminal {
    background: #000;
    border: 1px solid #1a1a2e;
    border-radius: var(--radius-md);
    overflow: hidden;
    box-shadow: var(--shadow-lg);
}

.terminal__bar {
    background: #1a1a1a;
    padding: 0.6rem 1rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    border-bottom: 1px solid #2a2a2a;
}

.terminal__dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
}

.terminal__dot--red { background: #ff5f57; }
.terminal__dot--yellow { background: #febc2e; }
.terminal__dot--green { background: #28c840; }

.terminal__title {
    margin-left: 0.5rem;
    font-family: var(--font-mono);
    font-size: 0.75rem;
    color: #888;
}

.terminal__body {
    padding: 1.5rem;
    font-family: var(--font-mono);
    font-size: 0.82rem;
    line-height: 1.8;
    overflow-x: auto;
    white-space: pre-wrap;
    word-wrap: break-word;
}

.terminal__body .comment {
    color: #6a9955;
}

.terminal__body .key {
    color: var(--accent-orange);
}

.terminal__body .value {
    color: var(--accent-cyan);
}

.terminal__body .success {
    color: var(--accent-green);
}

.terminal__body .error {
    color: var(--accent-red);
}

.terminal__body .highlight {
    color: var(--accent-pink);
}

.terminal__body .ip {
    color: #7fff00;
}

.terminal__body .sep {
    color: #333;
}

.terminal__body .link {
    color: var(--accent-green);
    text-decoration: underline;
    cursor: pointer;
}

.terminal__body .link:hover {
    color: #33ff99;
}

/* ── Log Entry ────────────────────────────────── */
.log-entry {
    margin-bottom: 2rem;
    padding-bottom: 2rem;
    border-bottom: 1px solid #1a1a2e;
}

.log-entry:last-child {
    margin-bottom: 0;
    padding-bottom: 0;
    border-bottom: none;
}

/* ── Status Badges ────────────────────────────── */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    padding: 0.25rem 0.75rem;
    border-radius: 999px;
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.badge-success {
    background: rgba(16, 185, 129, 0.1);
    color: var(--accent-green);
    border: 1px solid rgba(16, 185, 129, 0.2);
}

.badge-warning {
    background: rgba(245, 158, 11, 0.1);
    color: var(--accent-orange);
    border: 1px solid rgba(245, 158, 11, 0.2);
}

.badge-error {
    background: rgba(239, 68, 68, 0.1);
    color: var(--accent-red);
    border: 1px solid rgba(239, 68, 68, 0.2);
}

/* ── Loading Spinner ──────────────────────────── */
.spinner {
    display: inline-block;
    width: 18px;
    height: 18px;
    border: 2px solid rgba(255, 255, 255, 0.1);
    border-top-color: var(--accent-cyan);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* ── Responsive ───────────────────────────────── */
@media (max-width: 640px) {
    .container {
        padding: 1rem;
    }

    .header {
        padding: 2rem 0 1.5rem;
    }

    .header__title {
        font-size: 1.5rem;
    }

    .card {
        padding: 1.25rem;
    }

    .result-item {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.25rem;
    }

    .result-item__value {
        text-align: left;
    }

    .terminal__body {
        font-size: 0.72rem;
        padding: 1rem;
    }
}

/* ── View Page Specific ───────────────────────── */
.view-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
    gap: 1rem;
}

.view-header__info {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.view-header__info strong {
    color: var(--text-primary);
}

.log-count {
    font-family: var(--font-mono);
    font-size: 0.8rem;
    padding: 0.35rem 0.8rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 999px;
    color: var(--accent-cyan);
}

.no-logs {
    text-align: center;
    padding: 4rem 2rem;
    color: var(--text-muted);
    font-size: 0.9rem;
}

/* ── Map Link ─────────────────────────────────── */
.map-link {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    padding: 0.3rem 0.8rem;
    background: rgba(16, 185, 129, 0.08);
    border: 1px solid rgba(16, 185, 129, 0.2);
    border-radius: var(--radius-sm);
    color: var(--accent-green);
    font-size: 0.75rem;
    font-weight: 500;
    margin-top: 0.5rem;
    transition: var(--transition);
}

.map-link:hover {
    background: rgba(16, 185, 129, 0.15);
    color: #33ff99;
}

/* ── JSON Block ───────────────────────────────── */
.json-block {
    margin-top: 1rem;
    padding: 1rem;
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid #1a1a2e;
    border-radius: var(--radius-sm);
    font-family: var(--font-mono);
    font-size: 0.72rem;
    color: #888;
    overflow-x: auto;
    white-space: pre-wrap;
    word-break: break-all;
}

/* ── Pulse animation for live indicator ──────── */
.pulse {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--accent-green);
    animation: pulse 2s ease-in-out infinite;
    margin-right: 0.5rem;
}

@keyframes pulse {
    0%, 100% { opacity: 1; box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.4); }
    50% { opacity: 0.7; box-shadow: 0 0 0 6px rgba(16, 185, 129, 0); }
}

/* ── Footer ───────────────────────────────────── */
.footer {
    text-align: center;
    padding: 2rem;
    color: var(--text-muted);
    font-size: 0.75rem;
}
