/* Reset and Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    /* Typography Scale - Apple Style */
    --text-xs: 0.6875rem;  /* 11px */
    --text-sm: 0.8125rem;  /* 13px */
    --text-base: 1rem;     /* 16px */
    --text-lg: 1.0625rem;  /* 17px */
    --text-xl: 1.375rem;   /* 22px */
    --text-2xl: 1.75rem;   /* 28px */
    --text-3xl: 2.25rem;   /* 36px */
    --text-4xl: 3rem;      /* 48px */

    /* Apple Color System - Minimal */
    --color-black: #000000;
    --color-text: #1d1d1f;
    --color-text-secondary: #6e6e73;
    --color-text-tertiary: #86868b;
    --color-background: #ffffff;
    --color-background-secondary: #f5f5f7;
    --color-separator: #d2d2d7;
    --color-separator-light: #e8e8ed;
    --color-blue: #007AFF;
    --color-blue-hover: #0051D5;
    --color-green: #34C759;
    --color-orange: #FF9500;
    --color-red: #FF3B30;

    /* Spacing System - Apple */
    --space-1: 0.25rem;   /* 4px */
    --space-2: 0.5rem;    /* 8px */
    --space-3: 0.75rem;   /* 12px */
    --space-4: 1rem;      /* 16px */
    --space-5: 1.25rem;   /* 20px */
    --space-6: 1.5rem;    /* 24px */
    --space-8: 2rem;      /* 32px */
    --space-10: 2.5rem;   /* 40px */
    --space-12: 3rem;     /* 48px */
    --space-16: 4rem;     /* 64px */
    --space-20: 5rem;     /* 80px */
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Display', 'SF Pro Text', 'Helvetica Neue', sans-serif;
    background: var(--color-background);
    color: var(--color-text);
    line-height: 1.47059;
    letter-spacing: -0.022em;
    font-weight: 400;
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* ===== Keyframe Animations - Apple Style ===== */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(4px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes slideInRow {
    from {
        opacity: 0;
        transform: translateX(-8px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

/* Container */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 2rem;
}

/* Header - Apple Style */
header {
    text-align: center;
    padding: var(--space-12) 0 var(--space-8) 0;
    margin: 0 0 var(--space-12) 0;
    background: var(--color-background);
    border-bottom: 1px solid var(--color-separator-light);
}

header h1 {
    font-size: var(--text-3xl);
    font-weight: 600;
    margin-bottom: var(--space-2);
    color: var(--color-text);
    letter-spacing: -0.005em;
}

header p {
    font-size: var(--text-lg);
    font-weight: 400;
    color: var(--color-text-secondary);
    letter-spacing: -0.016em;
}

/* Card - Apple Style */
.card {
    background: var(--color-background);
    border-radius: 18px;
    padding: var(--space-8);
    margin-bottom: var(--space-6);
    border: 1px solid var(--color-separator-light);
    animation: fadeIn 0.3s ease-out;
}

.card h2 {
    font-size: var(--text-2xl);
    font-weight: 600;
    margin-bottom: var(--space-6);
    color: var(--color-text);
    letter-spacing: -0.003em;
}

.card h3 {
    font-size: var(--text-xl);
    font-weight: 600;
    margin-bottom: var(--space-4);
    color: var(--color-text);
    letter-spacing: -0.003em;
}

/* Form Elements - Apple Style */
.form-group {
    margin-bottom: var(--space-6);
}

.form-group label {
    display: block;
    margin-bottom: var(--space-2);
    font-weight: 400;
    font-size: var(--text-sm);
    color: var(--color-text);
    letter-spacing: -0.016em;
}

.form-group input {
    width: 100%;
    padding: var(--space-3) var(--space-4);
    border: 1px solid var(--color-separator);
    border-radius: 8px;
    font-size: var(--text-base);
    color: var(--color-text);
    background: var(--color-background);
    transition: all 0.2s ease-out;
    letter-spacing: -0.016em;
    -webkit-appearance: none;
}

.form-group input:hover {
    border-color: var(--color-text-tertiary);
}

.form-group input:focus {
    outline: none;
    border-color: var(--color-blue);
    box-shadow: 0 0 0 4px rgba(0, 122, 255, 0.1);
}

.form-group small {
    display: block;
    margin-top: var(--space-2);
    color: var(--color-text-secondary);
    font-size: var(--text-xs);
    letter-spacing: -0.016em;
}

/* Buttons - Apple Style */
.btn {
    display: inline-block;
    padding: 0.6875rem 1.375rem;
    border: none;
    border-radius: 980px;
    font-size: var(--text-lg);
    font-weight: 400;
    cursor: pointer;
    transition: all 0.25s ease-out;
    text-decoration: none;
    letter-spacing: -0.016em;
}

.btn-primary {
    background: var(--color-blue);
    color: white;
    width: 100%;
}

.btn-primary:hover {
    background: var(--color-blue-hover);
    transform: scale(0.98);
}

.btn-primary:active {
    transform: scale(0.96);
}

.btn-primary:disabled {
    background: var(--color-text-tertiary);
    cursor: not-allowed;
    opacity: 0.5;
}

.btn-secondary {
    background: transparent;
    color: var(--color-blue);
    border: 1px solid var(--color-separator);
}

.btn-secondary:hover {
    border-color: var(--color-blue);
    background: rgba(0, 122, 255, 0.04);
}

.btn-figma {
    background: linear-gradient(135deg, #f24e1e 0%, #ff7262 100%);
    color: white !important;
    border: none !important;
    font-weight: 600;
}

.btn-figma:hover {
    background: linear-gradient(135deg, #e03e0e 0%, #ff5242 100%);
    transform: translateY(-1px);
    box-shadow: var(--shadow-lg);
    color: white !important;
}

.btn-figma:disabled {
    background: var(--secondary-color);
    cursor: not-allowed;
    transform: none;
}

.btn-figma-mcp {
    background: linear-gradient(135deg, #10b981 0%, #34d399 100%);
    color: white !important;
    border: none !important;
    font-weight: 600;
}

.btn-figma-mcp:hover {
    background: linear-gradient(135deg, #059669 0%, #10b981 100%);
    transform: translateY(-1px);
    box-shadow: var(--shadow-lg);
    color: white !important;
}

.btn-figma-mcp:disabled {
    background: var(--secondary-color);
    cursor: not-allowed;
    transform: none;
}

/* Progress Section */
.progress-info {
    margin-bottom: 1rem;
}

.progress-stats {
    display: flex;
    justify-content: space-between;
    margin-bottom: 1rem;
}

.stat {
    font-size: 1rem;
}

.progress-bar {
    width: 100%;
    height: 24px;
    background: var(--bg-color);
    border-radius: 12px;
    overflow: hidden;
    margin-bottom: 1rem;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--primary-color), var(--success-color));
    transition: width 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    padding-right: 0.5rem;
    color: white;
    font-size: 0.875rem;
    font-weight: 600;
}

.current-url {
    padding: 1rem;
    background: var(--bg-color);
    border-radius: 8px;
    word-break: break-all;
    font-size: 0.875rem;
}

/* Results Section */
.results-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
    gap: 1rem;
}

.results-actions {
    display: flex;
    gap: 0.5rem;
}

.results-summary {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
    margin-bottom: 2rem;
}

.summary-item {
    padding: 1rem;
    background: var(--bg-color);
    border-radius: 8px;
    text-align: center;
}

.summary-item strong {
    display: block;
    margin-bottom: 0.5rem;
    color: var(--text-secondary);
    font-size: 0.875rem;
}

.summary-item span {
    font-size: 2rem;
    font-weight: 700;
    color: var(--primary-color);
}

/* View Toggle */
.view-toggle {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.btn-toggle {
    padding: 0.5rem 1rem;
    border: 2px solid var(--border-color);
    background: white;
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.875rem;
    transition: all 0.2s;
}

.btn-toggle:hover {
    border-color: var(--primary-color);
}

.btn-toggle.active {
    background: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
}

/* Sitemap Tree */
.sitemap-container {
    margin-top: 2rem;
}

.sitemap-tree {
    background: var(--bg-color);
    border-radius: 8px;
    padding: 1.5rem;
    max-height: 600px;
    overflow-y: auto;
}

.tree-node {
    margin: 0.5rem 0;
    padding-left: 1.5rem;
    position: relative;
}

.tree-node::before {
    content: '└─';
    position: absolute;
    left: 0;
    color: var(--text-secondary);
}

.tree-node.root {
    padding-left: 0;
    font-weight: 600;
}

.tree-node.root::before {
    content: '🌐';
}

.tree-url {
    color: var(--primary-color);
    text-decoration: none;
    word-break: break-all;
    display: inline-block;
    margin: 0.25rem 0;
}

.tree-url:hover {
    text-decoration: underline;
}

.tree-children {
    margin-left: 1rem;
    border-left: 2px solid var(--border-color);
    padding-left: 1rem;
}

/* List View */
.sitemap-list {
    background: var(--bg-color);
    border-radius: 8px;
    padding: 1.5rem;
    max-height: 600px;
    overflow-y: auto;
}

.list-item {
    padding: 0.75rem;
    margin: 0.5rem 0;
    background: white;
    border-radius: 8px;
    border-left: 4px solid var(--primary-color);
}

.list-url {
    color: var(--primary-color);
    text-decoration: none;
    word-break: break-all;
    font-weight: 500;
}

.list-url:hover {
    text-decoration: underline;
}

.list-links {
    margin-top: 0.5rem;
    padding-left: 1rem;
    font-size: 0.875rem;
    color: var(--text-secondary);
}

/* Error Section */
.error-section {
    border-left: 4px solid var(--danger-color);
}

.error-message {
    padding: 1rem;
    background: rgba(239, 68, 68, 0.1);
    border-radius: 8px;
    color: var(--danger-color);
    margin-bottom: 1rem;
}

/* Footer */
footer {
    text-align: center;
    padding: 2rem 0;
    color: var(--text-secondary);
}

/* Scrollbar Styling */
::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background: var(--bg-color);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb {
    background: var(--secondary-color);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-secondary);
}

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

    header h1 {
        font-size: 2rem;
    }

    .card {
        padding: 1.5rem;
    }

    .results-header {
        flex-direction: column;
        align-items: flex-start;
    }

    .results-actions {
        width: 100%;
        flex-direction: column;
    }

    .btn-secondary {
        width: 100%;
    }
}

/* Loading Animation */
@keyframes pulse {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.5;
    }
}

.loading {
    animation: pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;
}

/* Page Type Badges */
.tree-node-content {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
    padding: 0.25rem;
    border-radius: 4px;
    transition: background-color 0.2s;
}

.tree-node-content:hover {
    background-color: var(--bg-color);
}

.page-type-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    font-size: 14px;
    border-radius: 4px;
    flex-shrink: 0;
}

.page-type-badge.home {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

.page-type-badge.product {
    background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
}

.page-type-badge.board {
    background: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%);
}

.page-type-badge.info {
    background: linear-gradient(135deg, #43e97b 0%, #38f9d7 100%);
}

.page-type-badge.contact {
    background: linear-gradient(135deg, #fa709a 0%, #fee140 100%);
}

.page-type-badge.page {
    background: linear-gradient(135deg, #a8edea 0%, #fed6e3 100%);
}

/* Page Tooltip */
.page-tooltip {
    position: fixed;
    z-index: 10000;
    background: white;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 1rem;
    box-shadow: var(--shadow-lg);
    max-width: 400px;
    min-width: 300px;
    pointer-events: none;
}

.tooltip-title {
    font-weight: 600;
    font-size: 1rem;
    color: var(--text-primary);
    margin-bottom: 0.5rem;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 0.5rem;
}

.tooltip-description {
    font-size: 0.875rem;
    color: var(--text-secondary);
    line-height: 1.5;
    margin-bottom: 0.5rem;
}

.tooltip-type {
    font-size: 0.75rem;
    color: var(--text-secondary);
    padding: 0.25rem 0.5rem;
    background: var(--bg-color);
    border-radius: 4px;
    display: inline-block;
    margin-top: 0.5rem;
}
