/* ============================================
   CSS Custom Properties
   ============================================ */
:root {
    --primary: #2563eb;
    --primary-dark: #1d4ed8;
    --primary-light: #dbeafe;
    --bg: #f1f5f9;
    --card: #ffffff;
    --text: #0f172a;
    --text-secondary: #64748b;
    --border: #e2e8f0;
    --success: #16a34a;
    --success-light: #dcfce7;
    --amber: #d97706;
    --amber-light: #fef3c7;
    --radius: 12px;
    --shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

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

[hidden] {
    display: none !important;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    min-height: 100dvh;
    -webkit-font-smoothing: antialiased;
    -webkit-text-size-adjust: 100%;
}

button {
    font-family: inherit;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}

input {
    font-family: inherit;
}

ul {
    list-style: none;
}

/* ============================================
   Header
   ============================================ */
.header {
    background: var(--primary);
    color: white;
    padding: 1.25rem 1rem;
    text-align: center;
    position: sticky;
    top: 0;
    z-index: 10;
}

.header__title {
    font-size: 1.125rem;
    font-weight: 700;
    margin-bottom: 0.125rem;
}

.header__subtitle {
    font-size: 0.8125rem;
    opacity: 0.85;
    font-weight: 400;
}

/* ============================================
   Main Container
   ============================================ */
.main {
    max-width: 600px;
    margin: 0 auto;
    padding: 1rem;
    padding-bottom: 3rem;
}

/* ============================================
   Breadcrumbs
   ============================================ */
.breadcrumbs {
    display: flex;
    align-items: center;
    gap: 0.125rem;
    padding: 0.5rem 0 0.75rem;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
}

.breadcrumbs::-webkit-scrollbar {
    display: none;
}

.breadcrumbs__item {
    background: none;
    border: none;
    font-size: 0.8125rem;
    color: var(--primary);
    padding: 0.375rem 0.5rem;
    border-radius: 6px;
    white-space: nowrap;
    transition: background 0.15s;
}

.breadcrumbs__item:active {
    background: var(--primary-light);
}

.breadcrumbs__item--active {
    color: var(--text);
    font-weight: 600;
    cursor: default;
}

.breadcrumbs__sep {
    color: var(--text-secondary);
    font-size: 0.6875rem;
    flex-shrink: 0;
}

/* ============================================
   Auto-Selection Message
   ============================================ */
.auto-msg {
    background: var(--amber-light);
    border: 1px solid var(--amber);
    border-radius: var(--radius);
    padding: 0.75rem 1rem;
    margin-bottom: 1rem;
    font-size: 0.875rem;
    color: var(--amber);
    font-weight: 500;
    animation: slideDown 0.3s ease;
}

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

/* ============================================
   Search Box
   ============================================ */
.search-box {
    position: sticky;
    top: 76px; /* below header */
    z-index: 5;
    margin-bottom: 1rem;
    background: var(--bg);
    padding-bottom: 0.25rem;
}

.search-box__icon {
    position: absolute;
    right: 1rem;
    top: 50%;
    transform: translateY(-50%);
    width: 20px;
    height: 20px;
    color: var(--text-secondary);
    pointer-events: none;
}

.search-box__input {
    width: 100%;
    padding: 0.875rem 3rem 0.875rem 1rem;
    border: 2px solid var(--border);
    border-radius: var(--radius);
    font-size: 1rem;
    background: var(--card);
    color: var(--text);
    outline: none;
    transition: border-color 0.2s;
}

.search-box__input:focus {
    border-color: var(--primary);
}

.search-box__input::placeholder {
    color: var(--text-secondary);
}

/* ============================================
   Loading
   ============================================ */
.loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
    padding: 3rem 1rem;
}

.loading__spinner {
    width: 36px;
    height: 36px;
    border: 3px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
}

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

.loading__text {
    color: var(--text-secondary);
    font-size: 0.875rem;
}

/* ============================================
   Error
   ============================================ */
.error {
    text-align: center;
    padding: 2rem 1rem;
}

.error__text {
    color: #dc2626;
    margin-bottom: 1rem;
    font-size: 0.9375rem;
}

/* ============================================
   Empty State
   ============================================ */
.empty {
    text-align: center;
    padding: 3rem 1rem;
}

.empty__text {
    color: var(--text-secondary);
    font-size: 1rem;
}

/* ============================================
   Folder List
   ============================================ */
.folder-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.folder-list__empty {
    text-align: center;
    padding: 2rem;
    color: var(--text-secondary);
    font-size: 0.9375rem;
}

/* ============================================
   Folder Card
   ============================================ */
.folder-card {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.875rem 1rem;
    background: var(--card);
    border: 1.5px solid var(--border);
    border-radius: var(--radius);
    font-size: 0.9375rem;
    color: var(--text);
    text-align: right;
    transition: border-color 0.15s, transform 0.1s;
    box-shadow: var(--shadow);
}

.folder-card:active {
    transform: scale(0.98);
    border-color: var(--primary);
}

.folder-card__icon {
    font-size: 1.375rem;
    flex-shrink: 0;
    line-height: 1;
}

.folder-card__name {
    flex: 1;
    text-align: right;
    word-break: break-word;
    line-height: 1.4;
}

.folder-card__count {
    font-size: 0.75rem;
    color: var(--text-secondary);
    flex-shrink: 0;
    white-space: nowrap;
}

.folder-card__arrow {
    color: var(--text-secondary);
    font-size: 1.25rem;
    flex-shrink: 0;
    line-height: 1;
}

/* ============================================
   Buttons
   ============================================ */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: var(--radius);
    font-size: 1rem;
    font-weight: 600;
    transition: background 0.15s, transform 0.1s;
}

.btn:active {
    transform: scale(0.97);
}

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

.btn--primary:active {
    background: var(--primary-dark);
}

.btn--secondary {
    background: var(--card);
    color: var(--primary);
    border: 2px solid var(--primary);
    width: 100%;
}

.btn--secondary:active {
    background: var(--primary-light);
}

/* ============================================
   Target Folder
   ============================================ */
.target-folder {
    background: var(--success-light);
    border: 2px solid var(--success);
    border-radius: var(--radius);
    padding: 1.25rem;
    margin-top: 1.25rem;
    text-align: center;
    animation: slideDown 0.3s ease;
}

.target-folder__badge {
    display: inline-block;
    background: var(--success);
    color: white;
    padding: 0.25rem 0.75rem;
    border-radius: 20px;
    font-size: 0.8125rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
}

.target-folder__path {
    font-size: 0.8125rem;
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
    word-break: break-word;
    direction: ltr;
    unicode-bidi: plaintext;
}

.target-folder__note {
    font-size: 0.8125rem;
    color: var(--text-secondary);
    font-style: italic;
}

/* ============================================
   Create Visit
   ============================================ */
.create-visit {
    margin-top: 1.5rem;
}

.create-visit__form {
    margin-top: 1rem;
    background: var(--card);
    border: 1.5px solid var(--border);
    border-radius: var(--radius);
    padding: 1rem;
    animation: slideDown 0.3s ease;
}

.create-visit__label {
    display: block;
    font-size: 0.875rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
}

.create-visit__input {
    width: 100%;
    padding: 0.75rem;
    border: 2px solid var(--border);
    border-radius: 8px;
    font-size: 1rem;
    color: var(--text);
    outline: none;
    transition: border-color 0.2s;
}

.create-visit__input:focus {
    border-color: var(--primary);
}

.create-visit__hint {
    margin-top: 0.75rem;
    font-size: 0.8125rem;
    color: var(--amber);
    font-weight: 500;
}

/* ============================================
   Responsive
   ============================================ */
@media (min-width: 640px) {
    .header__title {
        font-size: 1.375rem;
    }

    .main {
        padding: 1.5rem;
    }

    .folder-card {
        padding: 1rem 1.25rem;
    }

    .folder-card:hover {
        border-color: var(--primary);
        box-shadow: 0 2px 8px rgba(37, 99, 235, 0.12);
    }
}
