/* Notes App - メモ帳アプリのスタイル */

/* ============================================
   基本スタイルとリセット
   ============================================ */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Noto Sans JP', sans-serif;
    background-color: #f5f5f5;
    color: #333;
    line-height: 1.6;
}

/* ============================================
   アプリケーション全体のレイアウト
   ============================================ */
.app-container {
    display: flex;
    flex-direction: column;
    height: 100vh;
    overflow: hidden;
}

/* ============================================
   ヘッダー
   ============================================ */
.app-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 12px 20px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    z-index: 100;
}

.header-left h1 {
    font-size: 1.5rem;
    font-weight: 600;
}

.header-left i {
    margin-right: 8px;
}

.header-center {
    flex: 1;
    max-width: 400px;
    margin: 0 20px;
}

.search-container {
    position: relative;
}

.search-input {
    width: 100%;
    padding: 8px 40px 8px 16px;
    border: none;
    border-radius: 20px;
    background: rgba(255, 255, 255, 0.2);
    color: white;
    placeholder-color: rgba(255, 255, 255, 0.7);
}

.search-input::placeholder {
    color: rgba(255, 255, 255, 0.7);
}

.search-icon {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: rgba(255, 255, 255, 0.7);
}

.header-right {
    display: flex;
    gap: 10px;
}

.btn {
    padding: 8px 16px;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    transition: all 0.3s ease;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.btn-sync {
    background: rgba(255, 255, 255, 0.2);
    color: white;
}

.btn-sync:hover {
    background: rgba(255, 255, 255, 0.3);
}

.btn-settings {
    background: rgba(255, 255, 255, 0.2);
    color: white;
}

.btn-settings:hover {
    background: rgba(255, 255, 255, 0.3);
}

.sync-status {
    font-size: 12px;
}

/* ============================================
   アプリケーションボディ
   ============================================ */
.app-body {
    display: flex;
    flex: 1;
    overflow: hidden;
}

/* ============================================
   サイドバー
   ============================================ */
.sidebar {
    width: 320px;
    background: white;
    border-right: 1px solid #e0e0e0;
    display: flex;
    flex-direction: column;
    transition: transform 0.3s ease;
}

.sidebar-header {
    padding: 20px;
    border-bottom: 1px solid #e0e0e0;
}

.btn-primary {
    background: #667eea;
    color: white;
    width: 100%;
    padding: 12px;
    font-weight: 500;
}

.btn-primary:hover {
    background: #5a6fd8;
}

.btn-new-note {
    border-radius: 8px;
}

/* ============================================
   メモ一覧
   ============================================ */
.notes-list {
    flex: 1;
    overflow-y: auto;
    padding: 10px 0;
}

.note-item {
    padding: 16px 20px;
    border-bottom: 1px solid #f0f0f0;
    cursor: pointer;
    transition: background-color 0.2s ease;
}

.note-item:hover {
    background-color: #f8f9fa;
}

.note-item.active {
    background-color: #e3f2fd;
    border-right: 3px solid #667eea;
}

.note-item-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 8px;
}

.note-title {
    font-size: 16px;
    font-weight: 500;
    color: #333;
    margin: 0;
    line-height: 1.4;
    flex: 1;
    margin-right: 10px;
}

.note-date {
    font-size: 12px;
    color: #888;
    white-space: nowrap;
}

.note-preview {
    font-size: 14px;
    color: #666;
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* ============================================
   メインコンテンツエリア
   ============================================ */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: white;
    overflow: hidden;
}

/* ============================================
   ウェルカムメッセージ
   ============================================ */
.welcome-message {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
    text-align: center;
    color: #888;
}

.welcome-content {
    max-width: 400px;
}

.welcome-icon {
    font-size: 4rem;
    margin-bottom: 20px;
    color: #ddd;
}

.welcome-content h2 {
    font-size: 1.5rem;
    margin-bottom: 10px;
    color: #666;
}

.welcome-content p {
    color: #888;
    line-height: 1.6;
}

/* ============================================
   メモエディター
   ============================================ */
.note-editor {
    display: flex;
    flex-direction: column;
    height: 100%;
}

.editor-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px;
    border-bottom: 1px solid #e0e0e0;
    background: #fafafa;
}

.note-title-input {
    flex: 1;
    padding: 12px 16px;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-size: 18px;
    font-weight: 500;
    margin-right: 20px;
}

.note-title-input:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 2px rgba(102, 126, 234, 0.2);
}

.editor-actions {
    display: flex;
    gap: 10px;
}

.btn-success {
    background: #28a745;
    color: white;
}

.btn-success:hover {
    background: #218838;
}

.btn-danger {
    background: #dc3545;
    color: white;
}

.btn-danger:hover {
    background: #c82333;
}

.note-content-textarea {
    flex: 1;
    padding: 20px;
    border: none;
    font-size: 16px;
    line-height: 1.6;
    resize: none;
    outline: none;
    font-family: inherit;
}

.editor-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 20px;
    background: #fafafa;
    border-top: 1px solid #e0e0e0;
    font-size: 14px;
    color: #666;
}

/* ============================================
   モーダル
   ============================================ */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.modal.show {
    display: flex;
}

.modal-content {
    background: white;
    padding: 30px;
    border-radius: 8px;
    max-width: 400px;
    width: 90%;
    text-align: center;
}

.modal-content h3 {
    margin-bottom: 15px;
    color: #333;
}

.modal-content p {
    margin-bottom: 20px;
    color: #666;
    line-height: 1.6;
}

.modal-actions {
    display: flex;
    gap: 10px;
    justify-content: center;
}

.btn-secondary {
    background: #6c757d;
    color: white;
}

.btn-secondary:hover {
    background: #5a6268;
}

.btn-warning {
    background: #ffc107;
    color: #212529;
}

.btn-warning:hover {
    background: #e0a800;
}

/* ============================================
   同期関連
   ============================================ */
.sync-progress {
    margin: 15px 0;
}

.progress-bar {
    width: 100%;
    height: 6px;
    background: #e0e0e0;
    border-radius: 3px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: #667eea;
    width: 0%;
    transition: width 0.3s ease;
}

/* ============================================
   モバイル対応
   ============================================ */
.mobile-toggle {
    display: none;
    position: fixed;
    bottom: 20px;
    right: 20px;
    width: 56px;
    height: 56px;
    background: #667eea;
    color: white;
    border: none;
    border-radius: 50%;
    font-size: 20px;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    z-index: 999;
}

@media (max-width: 768px) {
    .app-header {
        padding: 10px 15px;
    }
    
    .header-left h1 {
        font-size: 1.2rem;
    }
    
    .header-center {
        margin: 0 5px;
        flex: 1;
        min-width: 120px;
    }
    
    .search-input {
        padding: 8px 30px 8px 12px;
        font-size: 14px;
        width: 100%;
    }
    
    .header-right {
        flex-shrink: 0;
    }
    
    .sidebar {
        position: fixed;
        top: 0;
        left: 0;
        height: 100%;
        z-index: 200;
        transform: translateX(-100%);
        padding-top: 60px;
    }
    
    .sidebar.show {
        transform: translateX(0);
    }
    
    .main-content {
        width: 100%;
    }
    
    .mobile-toggle {
        display: block;
    }
    
    .editor-header {
        flex-direction: column;
        gap: 15px;
        align-items: stretch;
    }
    
    .note-title-input {
        margin-right: 0;
        margin-bottom: 10px;
    }
    
    .editor-actions {
        justify-content: center;
    }
    
    .editor-footer {
        flex-direction: column;
        gap: 8px;
        text-align: center;
    }
}

@media (max-width: 480px) {
    .sidebar {
        width: 280px;
    }
    
    .header-center {
        margin: 0 2px;
        flex: 1;
    }
    
    .search-input {
        padding: 6px 25px 6px 10px;
        font-size: 13px;
    }
    
    .theme-toggle,
    .btn-sync,
    .btn-settings {
        padding: 6px 8px;
        font-size: 14px;
    }
    
    .sync-status {
        display: none; /* 極小画面では同期ステータステキストを非表示 */
    }
    
    .modal-content {
        padding: 20px;
        margin: 20px;
    }
    
    .btn {
        padding: 10px 16px;
        font-size: 16px;
    }
}

/* ============================================
   スクロールバーのカスタマイズ
   ============================================ */
.notes-list::-webkit-scrollbar,
.note-content-textarea::-webkit-scrollbar {
    width: 6px;
}

.notes-list::-webkit-scrollbar-track,
.note-content-textarea::-webkit-scrollbar-track {
    background: #f1f1f1;
}

.notes-list::-webkit-scrollbar-thumb,
.note-content-textarea::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 3px;
}

.notes-list::-webkit-scrollbar-thumb:hover,
.note-content-textarea::-webkit-scrollbar-thumb:hover {
    background: #a8a8a8;
}

/* ============================================
   アニメーション
   ============================================ */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.note-item {
    animation: fadeIn 0.3s ease;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.fa-sync-alt.spinning {
    animation: spin 1s linear infinite;
}

/* ============================================
   ダークモード対応（将来用）
   ============================================ */
@media (prefers-color-scheme: dark) {
    /* ダークモードのスタイルは将来実装 */
}
/* ============================================
   CSS変数 - ダークモード対応
   ============================================ */
:root {
    --bg-primary: #f5f5f5;
    --bg-secondary: white;
    --bg-tertiary: #fafafa;
    --text-primary: #333;
    --text-secondary: #666;
    --text-tertiary: #888;
    --border-primary: #e0e0e0;
    --border-secondary: #f0f0f0;
    --accent-primary: #667eea;
    --accent-secondary: #764ba2;
    --success-color: #28a745;
    --danger-color: #dc3545;
    --warning-color: #ffc107;
    --shadow-light: rgba(0,0,0,0.1);
    --shadow-medium: rgba(0,0,0,0.15);
}

[data-theme="dark"] {
    --bg-primary: #121212;
    --bg-secondary: #1e1e1e;
    --bg-tertiary: #2d2d2d;
    --text-primary: #ffffff;
    --text-secondary: #b3b3b3;
    --text-tertiary: #8a8a8a;
    --border-primary: #404040;
    --border-secondary: #333333;
    --accent-primary: #7c3aed;
    --accent-secondary: #a855f7;
    --success-color: #10b981;
    --danger-color: #ef4444;
    --warning-color: #f59e0b;
    --shadow-light: rgba(0,0,0,0.3);
    --shadow-medium: rgba(0,0,0,0.4);
}

/* ============================================
   ダークモード追加スタイル
   ============================================ */

/* ダークモード切り替えボタン */
.theme-toggle {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    border-radius: 6px;
    padding: 8px;
    cursor: pointer;
    color: white;
    font-size: 16px;
    transition: background-color 0.3s ease;
}

.theme-toggle:hover {
    background: rgba(255, 255, 255, 0.3);
}

/* ダークモード用色の上書き */
[data-theme="dark"] body {
    background-color: var(--bg-primary);
    color: var(--text-primary);
}

[data-theme="dark"] .app-header {
    background: linear-gradient(135deg, var(--accent-primary) 0%, var(--accent-secondary) 100%);
}

[data-theme="dark"] .sidebar {
    background: var(--bg-secondary);
    border-right: 1px solid var(--border-primary);
}

[data-theme="dark"] .sidebar-header {
    border-bottom: 1px solid var(--border-primary);
}

[data-theme="dark"] .note-item {
    border-bottom: 1px solid var(--border-secondary);
    color: var(--text-primary);
}

[data-theme="dark"] .note-item:hover {
    background-color: var(--bg-tertiary);
}

[data-theme="dark"] .note-item.active {
    background-color: var(--accent-primary);
    border-right: 3px solid var(--accent-secondary);
}

[data-theme="dark"] .note-title {
    color: var(--text-primary);
}

[data-theme="dark"] .note-date {
    color: var(--text-tertiary);
}

[data-theme="dark"] .note-preview {
    color: var(--text-secondary);
}

[data-theme="dark"] .main-content {
    background: var(--bg-secondary);
}

[data-theme="dark"] .welcome-content h2 {
    color: var(--text-secondary);
}

[data-theme="dark"] .welcome-content p {
    color: var(--text-tertiary);
}

[data-theme="dark"] .editor-header {
    border-bottom: 1px solid var(--border-primary);
    background: var(--bg-tertiary);
}

[data-theme="dark"] .note-title-input {
    border: 1px solid var(--border-primary);
    background: var(--bg-secondary);
    color: var(--text-primary);
}

[data-theme="dark"] .note-title-input:focus {
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 2px rgba(124, 58, 237, 0.2);
}

[data-theme="dark"] .note-content-textarea {
    background: var(--bg-secondary);
    color: var(--text-primary);
}

[data-theme="dark"] .editor-footer {
    background: var(--bg-tertiary);
    border-top: 1px solid var(--border-primary);
    color: var(--text-secondary);
}

[data-theme="dark"] .btn-primary {
    background: var(--accent-primary);
}

[data-theme="dark"] .btn-primary:hover {
    background: var(--accent-secondary);
}

[data-theme="dark"] .btn-success {
    background: var(--success-color);
}

[data-theme="dark"] .btn-danger {
    background: var(--danger-color);
}

[data-theme="dark"] .btn-secondary {
    background: var(--text-secondary);
}

[data-theme="dark"] .modal {
    background: rgba(0, 0, 0, 0.7);
}

[data-theme="dark"] .modal-content {
    background: var(--bg-secondary);
    color: var(--text-primary);
}

[data-theme="dark"] .modal-content h3 {
    color: var(--text-primary);
}

[data-theme="dark"] .modal-content p {
    color: var(--text-secondary);
}

[data-theme="dark"] .progress-bar {
    background: var(--border-primary);
}

[data-theme="dark"] .progress-fill {
    background: var(--accent-primary);
}

[data-theme="dark"] .search-input {
    background: rgba(255, 255, 255, 0.1);
}

[data-theme="dark"] .notes-list::-webkit-scrollbar-track,
[data-theme="dark"] .note-content-textarea::-webkit-scrollbar-track {
    background: var(--bg-tertiary);
}

[data-theme="dark"] .notes-list::-webkit-scrollbar-thumb,
[data-theme="dark"] .note-content-textarea::-webkit-scrollbar-thumb {
    background: var(--border-primary);
}

/* すべての要素にトランジション効果 */
* {
    transition: background-color 0.3s ease, border-color 0.3s ease, color 0.3s ease;
}
