/* DriveCAM Web - スタイルシート */

:root {
    --primary-color: #4285f4;
    --primary-dark: #3367d6;
    --danger-color: #ea4335;
    --success-color: #34a853;
    --warning-color: #fbbc05;
    --background-dark: #1a1a1a;
    --background-light: #2d2d2d;
    --text-primary: #ffffff;
    --text-secondary: #b0b0b0;
    --border-color: #404040;
    --recording-red: #ff3b30;
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    background-color: var(--background-dark);
    color: var(--text-primary);
    min-height: 100vh;
    overflow-x: hidden;
}

/* ログインセクション */
#loginSection {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 20px;
    text-align: center;
}

.login-container {
    max-width: 400px;
    width: 100%;
}

.app-logo {
    font-size: 64px;
    margin-bottom: 20px;
}

.app-title {
    font-size: 28px;
    font-weight: 600;
    margin-bottom: 8px;
}

.app-subtitle {
    font-size: 16px;
    color: var(--text-secondary);
    margin-bottom: 40px;
}

#signInBtn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    width: 100%;
    padding: 14px 24px;
    font-size: 16px;
    font-weight: 500;
    color: var(--text-primary);
    background-color: var(--primary-color);
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: background-color 0.2s;
}

#signInBtn:hover {
    background-color: var(--primary-dark);
}

#signInBtn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.google-icon {
    width: 20px;
    height: 20px;
}

/* メインアプリセクション */
#appSection {
    display: none;
    position: relative;
    width: 100vw;
    height: 100vh;
    overflow: hidden;
    background-color: #000;
}

/* カメラビュー (全画面) */
.camera-view {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1;
}

#cameraPreview {
    width: 100%;
    height: 100%;
    object-fit: cover;
    background-color: #000;
}

/* 上部オーバーレイ */
.camera-overlay-top {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    padding: safe-area-inset-top; /* iOS safe area */
    padding-top: max(20px, env(safe-area-inset-top));
    padding-left: 20px;
    padding-right: 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    z-index: 10;
    pointer-events: none; /* オーバーレイ自体はクリック透過 */
}

/* 録画インジケーター */
#recordingIndicator {
    display: none;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    background-color: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    border-radius: 20px;
    pointer-events: auto;
}

.recording-dot {
    width: 10px;
    height: 10px;
    background-color: var(--recording-red);
    border-radius: 50%;
    animation: pulse 1s infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

#recordingTime {
    font-size: 14px;
    font-weight: 500;
    font-variant-numeric: tabular-nums;
    text-shadow: 0 1px 2px rgba(0,0,0,0.5);
}

/* 設定ボタン */
#settingsBtn {
    width: 44px;
    height: 44px;
    font-size: 24px;
    background-color: rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(4px);
    border: none;
    border-radius: 50%;
    color: white;
    cursor: pointer;
    pointer-events: auto;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.2s;
}

#settingsBtn:hover {
    background-color: rgba(0, 0, 0, 0.6);
}

/* カメラコントロール */
.camera-controls {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    padding-bottom: max(40px, env(safe-area-inset-bottom));
    padding-top: 20px;
    display: flex;
    align-items: center;
    justify-content: space-around; /* 均等配置 */
    z-index: 10;
    background: linear-gradient(transparent, rgba(0, 0, 0, 0.8));
    pointer-events: none;
}

.camera-controls button {
    pointer-events: auto;
}

#switchCameraBtn {
    width: 48px;
    height: 48px;
    font-size: 24px;
    background-color: rgba(255, 255, 255, 0.2);
    backdrop-filter: blur(4px);
    border: none;
    border-radius: 50%;
    cursor: pointer;
    transition: background-color 0.2s;
    color: white;
}

#switchCameraBtn:hover {
    background-color: rgba(255, 255, 255, 0.3);
}

#recordBtn {
    width: 72px;
    height: 72px;
    font-size: 14px; /* テキストサイズ調整 */
    font-weight: 600;
    color: transparent; /* 通常時はテキストなし */
    background-color: var(--recording-red);
    border: 4px solid white;
    border-radius: 50%;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

#recordBtn:hover {
    transform: scale(1.05);
}

#recordBtn.recording {
    background-color: white;
    /* 録画中は四角くするアニメーション等も一般的だが、ここではシンプルに */
    width: 72px;
    height: 72px;
    border-radius: 50%;
    position: relative;
}

#recordBtn.recording::after {
    content: "";
    display: block;
    width: 32px;
    height: 32px;
    background-color: var(--recording-red);
    border-radius: 6px;
}

#recordBtn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* 設定オーバーレイ */
.settings-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: var(--background-dark);
    z-index: 100;
    display: none;
    flex-direction: column;
}

.settings-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    padding-top: max(16px, env(safe-area-inset-top));
    background-color: var(--background-light);
    border-bottom: 1px solid var(--border-color);
}

.settings-header h2 {
    font-size: 18px;
    font-weight: 600;
}

#closeSettingsBtn {
    width: 36px;
    height: 36px;
    font-size: 20px;
    background: transparent;
    border: none;
    color: var(--text-primary);
    cursor: pointer;
    border-radius: 50%;
}

#closeSettingsBtn:hover {
    background-color: rgba(255, 255, 255, 0.1);
}

.settings-content {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    padding-bottom: max(20px, env(safe-area-inset-bottom));
}

/* ユーザー情報セクション */
.user-section {
    margin-bottom: 24px;
}

#userInfo {
    display: flex;
    align-items: center;
    gap: 16px;
}

#userPhoto {
    width: 48px;
    height: 48px;
    border-radius: 50%;
}

.user-details {
    flex: 1;
    display: flex;
    flex-direction: column;
}

#userName {
    font-size: 16px;
    font-weight: 600;
}

#userEmail {
    font-size: 13px;
    color: var(--text-secondary);
}

#signOutBtn {
    padding: 8px 16px;
    font-size: 14px;
    color: var(--text-secondary);
    background: transparent;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    cursor: pointer;
    white-space: nowrap;
}

#signOutBtn:hover {
    color: var(--text-primary);
    border-color: var(--text-secondary);
}

.settings-section {
    background-color: var(--background-light);
    border-radius: 12px;
    padding: 16px;
    margin-bottom: 16px;
}

.settings-section h3 {
    font-size: 14px;
    color: var(--text-secondary);
    margin-bottom: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* 保存先設定 */
.location-row {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 12px;
}

.location-row label {
    min-width: 80px;
    font-size: 14px;
    color: var(--text-secondary);
}

#driveSelector {
    flex: 1;
    padding: 10px 12px;
    font-size: 14px;
    color: var(--text-primary);
    background-color: var(--background-dark);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    cursor: pointer;
}

#folderSelector {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 12px;
    font-size: 14px;
    color: var(--text-primary);
    background-color: var(--background-dark);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    cursor: pointer;
}

#folderSelector:hover {
    border-color: var(--primary-color);
}

#currentLocation {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* ファイル名入力 */
.filename-input {
    width: 100%;
    padding: 10px 12px;
    font-size: 14px;
    color: var(--text-primary);
    background-color: var(--background-dark);
    border: 1px solid var(--border-color);
    border-radius: 8px;
}

.filename-input:focus {
    outline: none;
    border-color: var(--primary-color);
}

.filename-input::placeholder {
    color: var(--text-secondary);
}

/* 同期設定 */
.sync-toggle {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
}

.sync-toggle label {
    font-size: 14px;
}

.toggle-switch {
    position: relative;
    width: 50px;
    height: 28px;
}

.toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.toggle-slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: var(--border-color);
    border-radius: 28px;
    transition: 0.3s;
}

.toggle-slider:before {
    position: absolute;
    content: "";
    height: 22px;
    width: 22px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    border-radius: 50%;
    transition: 0.3s;
}

input:checked + .toggle-slider {
    background-color: var(--primary-color);
}

input:checked + .toggle-slider:before {
    transform: translateX(22px);
}

/* 同期ステータス */
#syncStatus {
    display: none;
    padding: 12px;
    background-color: var(--background-dark);
    border-radius: 8px;
    margin-top: 12px;
}

.sync-info {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 8px;
}

#memberCount {
    font-size: 14px;
    color: var(--text-secondary);
}

#syncMessage {
    font-size: 14px;
    color: var(--primary-color);
}

/* アップロード進捗 */
#uploadProgress {
    display: none;
    padding: 16px;
    background-color: var(--background-light);
    border-radius: 12px;
    margin: 16px;
    max-width: 800px;
    margin-left: auto;
    margin-right: auto;
}

.progress-container {
    margin-bottom: 8px;
}

.progress-bar-bg {
    height: 8px;
    background-color: var(--background-dark);
    border-radius: 4px;
    overflow: hidden;
}

#progressBar {
    height: 100%;
    width: 0%;
    background-color: var(--primary-color);
    border-radius: 4px;
    transition: width 0.3s;
}

#progressText {
    font-size: 14px;
    color: var(--text-secondary);
    text-align: center;
}

/* フォルダ選択モーダル */
#folderModal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0.8);
    z-index: 1000;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.modal-content {
    width: 100%;
    max-width: 400px;
    max-height: 80vh;
    background-color: var(--background-light);
    border-radius: 16px;
    overflow: hidden;
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px;
    border-bottom: 1px solid var(--border-color);
}

.modal-header h2 {
    font-size: 18px;
    font-weight: 600;
}

#closeFolderModal {
    width: 32px;
    height: 32px;
    font-size: 20px;
    background: transparent;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
}

#closeFolderModal:hover {
    color: var(--text-primary);
}

#folderList {
    max-height: 60vh;
    overflow-y: auto;
    padding: 8px;
}

.folder-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    border-radius: 8px;
    cursor: pointer;
    transition: background-color 0.2s;
}

.folder-item:hover {
    background-color: var(--background-dark);
}

.folder-icon {
    font-size: 20px;
}

/* レスポンシブ */
@media (max-width: 600px) {
    .app-header {
        flex-direction: column;
        gap: 12px;
        padding: 12px;
    }

    .header-left {
        width: 100%;
        justify-content: space-between;
    }

    #userInfo {
        width: 100%;
        justify-content: space-between;
    }

    .user-details {
        display: none;
    }

    .location-row {
        flex-direction: column;
        align-items: stretch;
    }

    .location-row label {
        margin-bottom: 4px;
    }

    .camera-controls {
        padding: 16px;
    }

    #recordBtn {
        width: 64px;
        height: 64px;
        font-size: 14px;
    }

    #switchCameraBtn {
        width: 44px;
        height: 44px;
        font-size: 20px;
    }
}

/* ダークモード対応（すでにダークテーマ） */
@media (prefers-color-scheme: light) {
    /* 必要に応じてライトモード対応を追加 */
}
