/* =============================================================
   My Drive - Google Drive風UI
   ============================================================= */

:root {
    --primary: #1a73e8;
    --primary-hover: #185abc;
    --bg: #f6f8fc;
    --bg-card: #ffffff;
    --bg-hover: #f1f3f4;
    --bg-selected: #e8f0fe;
    --border: #dadce0;
    --text: #202124;
    --text-secondary: #5f6368;
    --danger: #d93025;
    --success: #1e8e3e;
    --shadow-sm: 0 1px 2px rgba(60,64,67,.1), 0 1px 3px rgba(60,64,67,.05);
    --shadow-md: 0 1px 3px rgba(60,64,67,.15), 0 4px 8px rgba(60,64,67,.1);
    --shadow-lg: 0 8px 16px rgba(60,64,67,.2);
    --radius: 8px;
    --radius-lg: 12px;
    --header-h: 64px;
    --sidebar-w: 256px;
    --font: 'Helvetica Neue','Hiragino Sans','Hiragino Kaku Gothic ProN','Meiryo',sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; height: 100%; }
body {
    font-family: var(--font);
    color: var(--text);
    background: var(--bg);
    font-size: 14px;
    -webkit-font-smoothing: antialiased;
}
button { font-family: inherit; cursor: pointer; }
input, button { font-size: 14px; }
a { color: var(--primary); text-decoration: none; }

/* ===== ログイン画面 ===== */
.login-body {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: linear-gradient(135deg,#e8f0fe 0%,#f6f8fc 100%);
}
.login-card {
    background: #fff;
    padding: 48px 40px;
    border-radius: 16px;
    box-shadow: var(--shadow-lg);
    width: 100%;
    max-width: 400px;
    text-align: center;
}
.login-logo { margin-bottom: 16px; }
.login-card h1 { margin: 0 0 8px; font-size: 24px; font-weight: 500; }
.login-sub { color: var(--text-secondary); margin: 0 0 24px; }
.login-error {
    background: #fce8e6;
    color: var(--danger);
    padding: 10px 14px;
    border-radius: var(--radius);
    margin-bottom: 16px;
    font-size: 13px;
}
.login-card form { display: flex; flex-direction: column; gap: 12px; }
.login-card input {
    padding: 12px 16px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    outline: none;
    transition: border-color .2s;
}
.login-card input:focus { border-color: var(--primary); }
.login-card button {
    padding: 12px;
    background: var(--primary);
    color: #fff;
    border: none;
    border-radius: var(--radius);
    font-weight: 500;
    transition: background .2s;
}
.login-card button:hover { background: var(--primary-hover); }

/* ===== レイアウト ===== */
#app { display: flex; flex-direction: column; height: 100vh; overflow: hidden; }

.app-header {
    height: var(--header-h);
    display: flex;
    align-items: center;
    padding: 0 16px;
    background: var(--bg);
    border-bottom: 1px solid var(--border);
    gap: 16px;
    flex-shrink: 0;
}
.header-left { display: flex; align-items: center; gap: 12px; min-width: 240px; }
.header-center { flex: 1; max-width: 720px; }
.header-right { display: flex; align-items: center; gap: 8px; }
.site-title { font-size: 20px; font-weight: 500; margin: 0; color: var(--text); }
.logo-icon { flex-shrink: 0; }

.search-box {
    display: flex;
    align-items: center;
    background: #eaf1fb;
    border-radius: 8px;
    padding: 0 16px;
    height: 48px;
    transition: background .2s, box-shadow .2s;
}
.search-box:focus-within {
    background: #fff;
    box-shadow: var(--shadow-md);
}
.search-box svg { color: var(--text-secondary); margin-right: 12px; flex-shrink: 0; }
.search-box input {
    border: none;
    background: transparent;
    outline: none;
    width: 100%;
    height: 100%;
    font-size: 16px;
    color: var(--text);
}

.icon-btn {
    background: transparent;
    border: none;
    width: 40px; height: 40px;
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    color: var(--text-secondary);
    transition: background .15s;
}
.icon-btn:hover { background: var(--bg-hover); }

.app-body { flex: 1; display: flex; overflow: hidden; }

/* ===== サイドバー ===== */
.sidebar {
    width: var(--sidebar-w);
    background: var(--bg);
    padding: 8px;
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    overflow-y: auto;
}
.new-menu { position: relative; padding: 8px 8px 16px; }
.new-btn {
    display: flex; align-items: center; gap: 12px;
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 12px 24px 12px 16px;
    font-weight: 500;
    color: var(--text);
    box-shadow: var(--shadow-sm);
    transition: box-shadow .2s, background .15s;
    width: auto;
}
.new-btn:hover { box-shadow: var(--shadow-md); background: #fafbfc; }

.new-menu-pop {
    position: absolute;
    top: 60px; left: 8px;
    background: #fff;
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    padding: 8px 0;
    min-width: 240px;
    z-index: 100;
}
.new-menu-pop button {
    display: flex; align-items: center; gap: 16px;
    width: 100%;
    padding: 10px 24px;
    border: none; background: transparent;
    text-align: left;
    color: var(--text);
    font-size: 14px;
}
.new-menu-pop button:hover { background: var(--bg-hover); }
.new-menu-pop hr { border: none; border-top: 1px solid var(--border); margin: 4px 0; }

.side-nav { display: flex; flex-direction: column; gap: 2px; }
.side-nav button {
    display: flex; align-items: center; gap: 16px;
    padding: 8px 24px;
    border: none; background: transparent;
    text-align: left;
    color: var(--text);
    border-radius: 0 24px 24px 0;
    margin-right: 8px;
    height: 40px;
    font-size: 14px;
}
.side-nav button:hover { background: var(--bg-hover); }
.side-nav button.active { background: var(--bg-selected); color: var(--primary); font-weight: 500; }
.side-nav button.active svg { color: var(--primary); }

.storage-info {
    margin-top: auto;
    padding: 16px;
    border-top: 1px solid var(--border);
}
.storage-label { font-size: 12px; color: var(--text-secondary); margin-bottom: 8px; }
.storage-bar {
    height: 4px;
    background: var(--border);
    border-radius: 2px;
    overflow: hidden;
    margin-bottom: 8px;
}
.storage-bar-inner {
    height: 100%;
    background: var(--primary);
    width: 0%;
    transition: width .4s;
}
.storage-text { font-size: 12px; color: var(--text-secondary); }

/* ===== メインエリア ===== */
.main-area {
    flex: 1;
    background: #fff;
    border-radius: 16px 0 0 0;
    margin: 0;
    overflow: auto;
    padding: 16px 24px 80px;
    position: relative;
}

.breadcrumbs {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 8px 0 16px;
    flex-wrap: wrap;
}
.breadcrumbs button {
    border: none; background: transparent;
    padding: 6px 10px;
    border-radius: var(--radius);
    color: var(--text);
    font-size: 18px;
    font-weight: 500;
}
.breadcrumbs button:hover { background: var(--bg-hover); }
.breadcrumbs .crumb-sep { color: var(--text-secondary); margin: 0 2px; user-select: none; }

.toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    min-height: 40px;
    margin-bottom: 12px;
}
.selection-info { color: var(--text-secondary); font-size: 13px; }
.toolbar-actions { display: flex; gap: 4px; }
.toolbar-actions button {
    background: transparent;
    border: 1px solid transparent;
    padding: 6px 14px;
    border-radius: 18px;
    color: var(--text);
    display: flex; align-items: center; gap: 6px;
    font-size: 13px;
}
.toolbar-actions button:hover { background: var(--bg-hover); }
.toolbar-actions button.danger { color: var(--danger); }
.toolbar-actions button.danger:hover { background: #fce8e6; }

/* ===== ファイル一覧 ===== */
.file-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 12px;
}
.file-grid.list-view {
    display: flex;
    flex-direction: column;
    gap: 0;
}

.file-card {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    background: #fff;
    cursor: pointer;
    transition: box-shadow .15s, background .15s, border-color .15s;
    display: flex;
    flex-direction: column;
}
.file-card:hover { box-shadow: var(--shadow-sm); background: #fafbfc; }
.file-card.selected { background: var(--bg-selected); border-color: var(--primary); }
.file-card .thumb {
    background: #f6f8fc;
    aspect-ratio: 16 / 10;
    display: flex; align-items: center; justify-content: center;
    overflow: hidden;
    border-bottom: 1px solid var(--border);
}
.file-card .thumb img {
    width: 100%; height: 100%;
    object-fit: cover;
}
.file-card .thumb .icon-large {
    width: 48px; height: 48px;
}
.file-card .meta {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 10px;
    min-height: 44px;
}
.file-card .meta .icon-small { width: 18px; height: 18px; flex-shrink: 0; }
.file-card .name {
    flex: 1;
    font-size: 13px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* リスト表示 */
.file-grid.list-view .file-card {
    flex-direction: row;
    align-items: center;
    border: none;
    border-bottom: 1px solid var(--border);
    border-radius: 0;
    padding: 6px 12px;
    background: transparent;
}
.file-grid.list-view .file-card:hover { background: var(--bg-hover); }
.file-grid.list-view .file-card.selected { background: var(--bg-selected); }
.file-grid.list-view .file-card .thumb {
    width: 40px; height: 40px; aspect-ratio: auto;
    border: none; border-radius: var(--radius);
    background: transparent;
    flex-shrink: 0;
}
.file-grid.list-view .file-card .thumb img { width: 36px; height: 36px; border-radius: 4px; }
.file-grid.list-view .file-card .thumb .icon-large { width: 24px; height: 24px; }
.file-grid.list-view .file-card .meta { flex: 1; padding: 0 12px; min-height: 0; }
.file-grid.list-view .file-card .meta .icon-small { display: none; }
.file-grid.list-view .file-card .file-meta-extra {
    display: flex; gap: 24px;
    color: var(--text-secondary); font-size: 12px;
}

/* ===== モーダル ===== */
.modal {
    position: fixed; inset: 0;
    background: rgba(32,33,36,.85);
    z-index: 1000;
    display: flex;
    flex-direction: column;
}
.modal-header {
    display: flex; align-items: center; justify-content: space-between;
    padding: 12px 24px;
    color: #fff;
    flex-shrink: 0;
}
.modal-header .name { font-size: 16px; font-weight: 500; flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; padding: 0 16px; }
.modal-header .actions { display: flex; gap: 8px; }
.modal-header .icon-btn { color: #fff; }
.modal-header .icon-btn:hover { background: rgba(255,255,255,.15); }

.modal-body {
    flex: 1;
    display: flex; align-items: center; justify-content: center;
    overflow: hidden;
    position: relative;
    padding: 0 56px;
}
.modal-body img, .modal-body video {
    max-width: 100%; max-height: 100%;
    object-fit: contain;
    background: #000;
    border-radius: 4px;
}
.modal-body iframe {
    width: 90%; height: 90%;
    border: none;
    background: #fff;
    border-radius: 4px;
}
.modal-body pre {
    width: 90%; height: 90%;
    overflow: auto;
    background: #fff;
    color: var(--text);
    padding: 24px;
    border-radius: 4px;
    margin: 0;
    font-family: monospace;
    font-size: 13px;
}
.modal-nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(255,255,255,.1);
    border: none;
    width: 48px; height: 48px;
    border-radius: 50%;
    color: #fff;
    display: flex; align-items: center; justify-content: center;
    cursor: pointer;
    transition: background .2s;
}
.modal-nav:hover { background: rgba(255,255,255,.25); }
.modal-nav.prev { left: 8px; }
.modal-nav.next { right: 8px; }

/* ダイアログ */
.dialog-card {
    background: #fff;
    border-radius: var(--radius-lg);
    padding: 24px;
    max-width: 500px;
    width: 100%;
    margin: auto;
    box-shadow: var(--shadow-lg);
}
.dialog-card h2 { margin: 0 0 16px; font-size: 18px; font-weight: 500; }
.dialog-card .field { margin-bottom: 16px; }
.dialog-card label { display: block; margin-bottom: 6px; font-size: 13px; color: var(--text-secondary); }
.dialog-card input, .dialog-card select {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    outline: none;
}
.dialog-card input:focus, .dialog-card select:focus { border-color: var(--primary); }
.dialog-card .actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 24px; }
.dialog-card .actions button {
    padding: 8px 20px;
    border: none;
    border-radius: var(--radius);
    background: transparent;
    color: var(--primary);
    font-weight: 500;
}
.dialog-card .actions button.primary { background: var(--primary); color: #fff; }
.dialog-card .actions button.primary:hover { background: var(--primary-hover); }
.dialog-card .actions button:hover { background: var(--bg-hover); }
.dialog-card .actions button.primary:hover { background: var(--primary-hover); }

.modal.dialog {
    background: rgba(32,33,36,.4);
    align-items: center;
    justify-content: center;
    padding: 24px;
}

/* ツリービュー（移動先選択など） */
.tree {
    max-height: 320px;
    overflow: auto;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 8px;
}
.tree-node {
    padding: 4px 8px;
    border-radius: var(--radius);
    cursor: pointer;
    user-select: none;
    display: flex;
    align-items: center;
    gap: 6px;
}
.tree-node:hover { background: var(--bg-hover); }
.tree-node.selected { background: var(--bg-selected); color: var(--primary); }
.tree-node .toggle { width: 16px; text-align: center; color: var(--text-secondary); }
.tree-children { padding-left: 16px; }

/* ===== ドロップオーバーレイ ===== */
.drop-overlay {
    position: absolute;
    inset: 0;
    background: rgba(232,240,254,.95);
    border: 3px dashed var(--primary);
    border-radius: var(--radius-lg);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 50;
    pointer-events: none;
}
.drop-message { text-align: center; color: var(--primary); }
.drop-message p { font-size: 18px; font-weight: 500; margin: 12px 0 0; }

/* ===== 空状態 ===== */
.empty-state {
    text-align: center;
    padding: 80px 20px;
    color: var(--text-secondary);
}
.empty-state p { margin: 8px 0; }
.empty-state .hint { font-size: 13px; }

/* ===== コンテキストメニュー ===== */
.context-menu {
    position: fixed;
    background: #fff;
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    padding: 8px 0;
    min-width: 200px;
    z-index: 1500;
}
.context-menu button {
    display: flex; align-items: center; gap: 12px;
    width: 100%;
    padding: 8px 16px;
    border: none; background: transparent;
    text-align: left;
    color: var(--text);
    font-size: 13px;
}
.context-menu button:hover { background: var(--bg-hover); }
.context-menu button.danger { color: var(--danger); }
.context-menu button.danger:hover { background: #fce8e6; }
.context-menu hr { border: none; border-top: 1px solid var(--border); margin: 4px 0; }

/* ===== アップロード進捗 ===== */
.upload-progress {
    position: fixed;
    bottom: 16px; right: 16px;
    width: 360px;
    background: #fff;
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    z-index: 800;
    overflow: hidden;
}
.upload-header {
    display: flex; align-items: center; justify-content: space-between;
    padding: 12px 16px;
    background: #5f6368;
    color: #fff;
}
.upload-header .icon-btn { color: #fff; width: 28px; height: 28px; }
.upload-header .icon-btn:hover { background: rgba(255,255,255,.15); }
.upload-list {
    max-height: 240px;
    overflow-y: auto;
}
.upload-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    border-bottom: 1px solid var(--border);
    font-size: 13px;
}
.upload-item:last-child { border-bottom: none; }
.upload-item .upload-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.upload-item .upload-status { color: var(--text-secondary); font-size: 11px; }
.upload-item.done .upload-status { color: var(--success); }
.upload-item.error .upload-status { color: var(--danger); }

/* ===== トースト ===== */
.toast-container {
    position: fixed;
    bottom: 16px; left: 16px;
    z-index: 2000;
    display: flex; flex-direction: column; gap: 8px;
}
.toast {
    background: #323232;
    color: #fff;
    padding: 12px 20px;
    border-radius: var(--radius);
    box-shadow: var(--shadow-md);
    animation: toastIn .25s ease-out;
    font-size: 13px;
    max-width: 360px;
}
.toast.error { background: var(--danger); }
.toast.success { background: var(--success); }
@keyframes toastIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* ===== 共有リンク管理 ===== */
.share-list { max-height: 360px; overflow: auto; }
.share-row {
    display: flex; align-items: center; gap: 8px;
    padding: 10px 12px;
    border-bottom: 1px solid var(--border);
    font-size: 13px;
}
.share-row .share-path { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.share-row .share-link {
    background: var(--bg-hover);
    padding: 4px 8px;
    border-radius: 4px;
    font-family: monospace;
    font-size: 12px;
}

/* ===== ファイルアイコン色 ===== */
.kind-folder { color: #5f6368; }
.kind-image { color: #ea4335; }
.kind-video { color: #ea4335; }
.kind-audio { color: #fbbc04; }
.kind-pdf { color: #ea4335; }
.kind-text { color: #34a853; }
.kind-doc { color: #4285f4; }
.kind-archive { color: #fbbc04; }
.kind-other { color: #5f6368; }

/* ===== レスポンシブ ===== */
@media (max-width: 768px) {
    .header-left { min-width: auto; }
    .site-title { display: none; }
    .sidebar {
        position: fixed;
        top: var(--header-h);
        bottom: 0; left: 0;
        z-index: 200;
        background: #fff;
        box-shadow: var(--shadow-lg);
        transform: translateX(-100%);
        transition: transform .25s;
    }
    .sidebar.open { transform: translateX(0); }
    .file-grid { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); }
    .menu-toggle { display: flex !important; }
}
@media (min-width: 769px) {
    .menu-toggle { display: none; }
}
