/* layout.css — Base layout, header, footer, buttons, welcome guide */

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: var(--font-ui);
    background: var(--bg-base);
    color: var(--text-primary);
    font-size: var(--font-size-base);
    height: 100vh;
    overflow: hidden;
}

.header {
    background: var(--bg-elevated);
    padding: 0 8px;
    border-bottom: 1px solid var(--border-default);
    display: flex;
    justify-content: space-between;
    align-items: center;
    height: 35px;
}

.header-top {
    display: flex;
    align-items: center;
    gap: 4px;
    flex: 1;
}

.header h1 {
    font-size: var(--font-size-base);
    color: var(--text-primary);
    margin: 0;
    flex: 1;
}

.auth-controls {
    display: flex;
    gap: 6px;
    align-items: center;
}

.btn {
    background: var(--accent-primary);
    color: var(--on-accent);
    border: none;
    padding: 6px 14px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: var(--font-size-base);
    transition: background 0.1s;
}

.btn:hover {
    background: var(--accent-hover);
}

.btn.secondary {
    background: var(--input-bg);
}

.btn.secondary:hover {
    background: var(--bg-hover);
}

.status {
    font-size: var(--font-size-sm);
    color: var(--text-primary);
}

.main-container {
    display: flex;
    height: calc(100vh - 57px); /* ヘッダー35px + フッター22px */
}

/* ヘッダー折りたたみ（Focus Mode） */
.header {
    transition: transform 0.2s ease;
}

.header.collapsed {
    transform: translateY(-100%);
    position: absolute;
    width: 100%;
    z-index: 1000;
}

.main-container.header-collapsed {
    height: 100vh;
}

.header-hover-zone {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    z-index: 1001;
    display: none;
}

.header-hover-zone.active {
    display: block;
}

/* Welcome Guide */
.welcome-guide {
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    overflow-y: auto;
    background: var(--bg-elevated);
    z-index: 5;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 48px 24px;
}

.welcome-guide.hidden { display: none; }

.welcome-guide-content {
    max-width: 560px;
    width: 100%;
}

.welcome-guide-title {
    font-size: 28px;
    font-weight: 700;
    color: var(--text-bright);
    margin-bottom: 8px;
    font-family: system-ui, -apple-system, sans-serif;
}

.welcome-guide-icon { color: #007ACC; }

.welcome-guide-subtitle {
    font-size: 16px;
    color: var(--text-secondary);
    margin-bottom: 32px;
    font-family: system-ui, -apple-system, sans-serif;
}

.welcome-guide-section h2 {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-bright);
    margin-bottom: 12px;
    font-family: system-ui, -apple-system, sans-serif;
}

.auth-steps {
    margin-bottom: 16px;
    padding: 12px 16px;
    background: var(--bg-base);
    border-radius: var(--radius-sm);
    border-left: 3px solid #007ACC;
}

.auth-steps p {
    font-size: 13px;
    color: var(--text-secondary);
    margin: 4px 0;
    line-height: 1.6;
}

.auth-steps a { color: #007ACC; text-decoration: underline; }

.welcome-auth-form {
    margin-bottom: 32px;
}

.welcome-auth-form .form-input {
    width: 100%;
    margin-bottom: 8px;
}

.welcome-signin-btn {
    background: #007ACC;
    color: #fff;
    padding: 8px 24px;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-family: system-ui, -apple-system, sans-serif;
    cursor: pointer;
    transition: background 0.2s;
    margin-top: 8px;
}

.welcome-signin-btn:hover { background: #3794ff; }

.welcome-oauth-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    width: 100%;
    padding: 12px 24px;
    background: #ffffff;
    color: #24292f;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 16px;
    font-weight: 500;
    font-family: system-ui, -apple-system, sans-serif;
    cursor: pointer;
    text-decoration: none;
    transition: background 0.2s;
    margin-bottom: 16px;
}

.welcome-oauth-btn:hover { background: #e8e8e8; }

html.light-theme .welcome-oauth-btn {
    background: #24292f;
    color: #ffffff;
}

html.light-theme .welcome-oauth-btn:hover { background: #32383f; }

.welcome-oauth-btn .github-icon { flex-shrink: 0; }

.welcome-token-toggle {
    text-align: center;
    margin: 12px 0 0;
    font-size: 13px;
}

.welcome-token-toggle a {
    color: var(--text-muted);
    text-decoration: none;
}

.welcome-token-toggle a:hover {
    color: var(--text-secondary);
    text-decoration: underline;
}

.welcome-token-section { margin-bottom: 24px; }

.welcome-guide-footer {
    margin-top: 32px;
    padding-top: 16px;
    border-top: 1px solid var(--border-default);
    font-size: 12px;
    color: var(--text-muted);
    line-height: 1.8;
}

.welcome-guide-footer a {
    color: #007ACC;
    text-decoration: none;
}

.status-readonly {
    color: var(--on-accent-muted);
    font-size: 10px;
    margin-left: 8px;
}

.default-repo-banner {
    padding: 6px 16px;
    background: var(--bg-surface);
    border-bottom: 1px solid var(--border-default);
    font-size: 12px;
    color: var(--text-muted);
    text-align: center;
}

/* Footer */
.app-footer {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: 22px;
    background: var(--accent-primary);
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 10px;
    font-size: var(--font-size-xs);
    color: var(--on-accent);
    z-index: 1000;
}

.footer-left {
    display: flex;
    align-items: center;
    flex: 0 0 auto;
}

.footer-center {
    display: flex;
    align-items: center;
    gap: 8px;
    flex: 1;
    justify-content: center;
    font-size: 10px;
    color: var(--on-accent-muted);
}

.footer-center .separator {
    color: var(--on-accent-subtle);
}

.footer-right {
    display: flex;
    align-items: center;
    flex: 0 0 auto;
    gap: 6px;
}

.version-switch {
    color: var(--on-accent-subtle);
    text-decoration: none;
    font-size: var(--font-size-sm);
    transition: color 0.2s;
}
.version-switch:hover {
    color: var(--on-accent);
}

.company-link {
    color: var(--on-accent);
    text-decoration: none;
    transition: opacity 0.1s;
}

.company-link:hover {
    opacity: 0.8;
    text-decoration: underline;
}

.version-info {
    font-family: var(--font-mono);
    color: var(--text-primary);
    background: rgba(0, 0, 0, 0.2);
    padding: 1px 6px;
    border-radius: 2px;
    cursor: pointer;
    user-select: text;
    transition: background 0.1s;
}

.version-info:hover {
    color: var(--text-primary);
    background: rgba(0, 0, 0, 0.6);
}

.hidden {
    display: none !important;
}

/* サイドバートグルボタン（PC版） */
.sidebar-toggle-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    background: none;
    border: none;
    color: var(--text-primary);
    font-size: 16px;
    cursor: pointer;
    padding: 4px 6px;
    border-radius: var(--radius-sm);
    transition: background 0.1s;
}

.sidebar-toggle-btn:hover {
    color: var(--text-bright);
    background: var(--overlay-medium);
}

/* ハンバーガーメニューボタン（モバイル版） */
.mobile-menu-btn {
    display: none;
    background: none;
    border: none;
    color: var(--text-primary);
    font-size: 24px;
    cursor: pointer;
    padding: 10px;
}

.mobile-menu-btn:hover {
    color: var(--text-bright);
}

.mobile-auth-toggle {
    display: none;
    background: none;
    border: none;
    color: var(--text-primary);
    font-size: 14px;
    cursor: pointer;
    padding: 5px 8px;
    border-radius: 3px;
}

.mobile-auth-toggle:hover {
    background: var(--input-bg);
    color: var(--text-bright);
}

/* iOS Safariの100vh問題対応 */
:root {
    --vh: 1vh;
}

@media (max-width: 768px) {
    .header {
        flex-direction: row;
        padding: 10px 15px;
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        z-index: 200;
        background: var(--bg-elevated);
        border-bottom: 1px solid var(--border-default);
        min-height: 60px;
        max-height: 60px;
        justify-content: space-between;
        align-items: center;
    }

    .header-top {
        display: flex;
        justify-content: space-between;
        align-items: center;
        margin-bottom: 0;
        flex: 1;
    }

    .header h1 {
        font-size: 16px;
        margin: 0 10px;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        font-weight: normal;
    }

    .auth-controls {
        display: none;
    }

    .auth-controls.mobile-expanded {
        display: flex;
        flex-wrap: wrap;
        gap: 4px;
        justify-content: center;
        position: absolute;
        top: 100%;
        left: 0;
        right: 0;
        background: var(--bg-elevated);
        border-bottom: 1px solid var(--border-default);
        padding: 8px 15px;
        box-shadow: 0 2px 4px rgba(0,0,0,0.3);
    }

    .mobile-auth-toggle {
        display: block;
        background: none;
        border: none;
        color: var(--text-primary);
        font-size: 18px;
        cursor: pointer;
        padding: 8px 12px;
        border-radius: 3px;
    }

    .mobile-auth-toggle:hover {
        background: var(--input-bg);
        color: var(--text-bright);
    }

    .btn {
        padding: 8px 12px;
        font-size: 14px;
        min-height: 36px;
        border-radius: 4px;
    }

    .status {
        font-size: 12px;
        width: 100%;
        text-align: center;
        margin-bottom: 4px;
    }

    body {
        padding-top: 60px;
    }

    .main-container {
        flex-direction: column;
        height: calc(var(--vh, 1vh) * 100 - 60px);
        min-height: calc(var(--vh, 1vh) * 100 - 60px);
        position: relative;
    }

    .mobile-menu-btn {
        display: block;
        font-size: 20px;
        padding: 8px 12px;
    }

    .form-input {
        font-size: 16px;
        padding: 12px;
    }
}

@media (max-width: 480px) {
    .header {
        min-height: 50px;
        max-height: 50px;
        padding: 8px 12px;
    }

    .header h1 {
        font-size: 14px;
        margin: 0 8px;
    }

    .mobile-menu-btn {
        font-size: 18px;
        padding: 6px 10px;
    }

    .mobile-auth-toggle {
        font-size: 16px;
        padding: 6px 10px;
    }

    .welcome-guide { padding: 24px 16px; }
    .welcome-guide-title { font-size: 22px; }
}

@media (max-width: 400px) {
    .btn {
        font-size: 12px;
        padding: 6px 10px;
        min-height: 32px;
    }

    .status {
        font-size: 10px;
    }

    body {
        padding-top: 50px;
    }

    .main-container {
        height: calc(var(--vh, 1vh) * 100 - 50px);
        min-height: calc(var(--vh, 1vh) * 100 - 50px);
    }
}

/* タッチデバイス最適化 */
@media (hover: none) and (pointer: coarse) {
    .file-item,
    .context-menu-item,
    .btn {
        min-height: 44px;
        display: flex;
        align-items: center;
    }

    .file-item:active,
    .context-menu-item:active {
        background: var(--bg-active);
    }

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

    .toolbar-overflow-item {
        min-height: 44px;
        padding: 12px 16px;
    }
}
