/* ==========================================
   宿泊予約カレンダー - メインスタイル
   ========================================== */

:root {
    --primary-color: #0891b2;
    --primary-hover: #0e7490;
    --bg-color: #f0f4f8;
    --white: #ffffff;
    --border-color: #e2e8f0;
    --text-primary: #1e293b;
    --text-secondary: #64748b;
    --sidebar-width: 200px;
    --cell-width: 60px;
    --cell-height: 80px;
    --header-height: 60px;
    
    /* プラットフォームカラー */
    --airbnb-color: #ff5a5f;
    --airbnb-light: #ffcccb;
    --booking-color: #003580;
    --booking-light: #b3d4fc;
    --blocked-color: #64748b;
    --blocked-light: #e2e8f0;
    
    /* ステータスカラー */
    --unavailable-color: #d1d5db;
    --unavailable-text: #6b7280;
}

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

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background-color: var(--bg-color);
    color: var(--text-primary);
    font-size: 14px;
    line-height: 1.5;
}

/* アプリコンテナ */
.app-container {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* ==========================================
   ヘッダー
   ========================================== */
.header {
    background: var(--white);
    height: var(--header-height);
    padding: 0 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid var(--border-color);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

.header-left {
    display: flex;
    align-items: center;
    gap: 12px;
}

.title {
    font-size: 20px;
    font-weight: 600;
    color: var(--text-primary);
}

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

.icon-btn {
    width: 36px;
    height: 36px;
    border: 1px solid var(--border-color);
    background: var(--white);
    border-radius: 6px;
    cursor: pointer;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.icon-btn:hover {
    background: var(--bg-color);
    color: var(--text-primary);
}

.nav-btn {
    padding: 8px 16px;
    border: 1px solid var(--border-color);
    background: var(--white);
    border-radius: 6px;
    cursor: pointer;
    font-weight: 500;
    color: var(--text-primary);
    transition: all 0.2s;
}

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

.month-nav,
.year-nav {
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 4px 8px;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    background: var(--white);
}

.nav-arrow {
    width: 28px;
    height: 28px;
    border: none;
    background: transparent;
    cursor: pointer;
    color: var(--text-secondary);
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.nav-arrow:hover {
    background: var(--bg-color);
    color: var(--text-primary);
}

.current-month,
.current-year {
    font-weight: 500;
    min-width: 60px;
    text-align: center;
}

.add-booking-btn {
    padding: 8px 16px;
    background: var(--primary-color);
    color: var(--white);
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: all 0.2s;
}

.add-booking-btn:hover {
    background: var(--primary-hover);
}

/* 自動更新ステータス */
.auto-refresh-status {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    color: var(--primary-color);
    padding: 4px 10px;
    background: rgba(8, 145, 178, 0.1);
    border-radius: 4px;
    margin-right: 8px;
}

.auto-refresh-status::before {
    content: '';
    width: 8px;
    height: 8px;
    border: 2px solid var(--primary-color);
    border-top-color: transparent;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

/* ==========================================
   メインコンテンツ
   ========================================== */
.main-content {
    flex: 1;
    display: flex;
    overflow: hidden;
}

/* サイドバー */
.sidebar {
    width: var(--sidebar-width);
    background: var(--white);
    border-right: 1px solid var(--border-color);
    flex-shrink: 0;
}

.sidebar-header {
    height: 50px;
    padding: 0 15px;
    display: flex;
    align-items: center;
    gap: 10px;
    border-bottom: 1px solid var(--border-color);
    font-weight: 600;
    font-size: 12px;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.rental-list {
    overflow-y: auto;
}

/* 物件カード */
.rental-item {
    padding: 12px 15px;
    border-bottom: 1px solid var(--border-color);
    border-left: 4px solid transparent;
    cursor: pointer;
    transition: all 0.2s;
    height: var(--cell-height);
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.rental-item:hover {
    background: var(--bg-color);
}

.rental-item.airbnb {
    border-left-color: var(--airbnb-color);
}

.rental-item.booking {
    border-left-color: var(--booking-color);
}

.rental-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 4px;
}

.rental-avatar {
    width: 32px;
    height: 32px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 12px;
    color: var(--white);
}

.rental-avatar.airbnb {
    background: var(--airbnb-color);
}

.rental-avatar.booking {
    background: var(--booking-color);
}

.rental-avatar.other {
    background: var(--primary-color);
}

.rental-info {
    flex: 1;
    min-width: 0;
}

.rental-status {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 11px;
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #22c55e;
}

.rental-name {
    font-weight: 500;
    font-size: 13px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.rental-actions {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 8px;
    margin-left: auto;
}

.rental-action-btns {
    display: flex;
    gap: 4px;
    opacity: 0;
    transition: opacity 0.2s;
}

.rental-item:hover .rental-action-btns {
    opacity: 1;
}

.action-btn {
    width: 24px;
    height: 24px;
    border: none;
    background: transparent;
    color: var(--text-secondary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    font-size: 11px;
    transition: all 0.2s;
}

.action-btn:hover {
    background: var(--border-color);
}

.action-btn.edit-btn:hover {
    color: var(--primary-color);
}

.action-btn.delete-btn:hover {
    color: #ef4444;
    background: #fef2f2;
}

.rental-order-btns {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.order-btn {
    width: 20px;
    height: 16px;
    border: none;
    background: transparent;
    color: var(--text-secondary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 3px;
    font-size: 10px;
    transition: all 0.2s;
}

.order-btn:hover:not(:disabled) {
    background: var(--primary-color);
    color: white;
}

.order-btn:disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

.rental-icons {
    display: flex;
    gap: 8px;
    font-size: 11px;
    color: var(--text-secondary);
}

/* ==========================================
   カレンダー
   ========================================== */
.calendar-container {
    flex: 1;
    overflow: hidden;
    position: relative;
}

.calendar-wrapper {
    display: flex;
    flex-direction: column;
    height: 100%;
    margin: 0 32px; /* 左右の矢印分のスペース */
    overflow-x: auto;
    overflow-y: auto;
}

/* カレンダーナビゲーション矢印 */
.calendar-nav-arrow {
    position: absolute;
    top: 0;
    height: 50px; /* 日付ヘッダーと同じ高さ */
    width: 32px;
    background: rgba(255,255,255,0.95);
    border: none;
    cursor: pointer;
    z-index: 10;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-secondary);
    font-size: 14px;
    transition: all 0.2s ease;
}

.calendar-nav-arrow:hover {
    background: rgba(255,255,255,1);
    color: var(--primary-color);
}

.calendar-nav-left {
    left: 0;
    border-right: 1px solid var(--border-color);
}

.calendar-nav-right {
    right: 0;
    border-left: 1px solid var(--border-color);
}

.calendar-nav-left:hover,
.calendar-nav-right:hover {
    background: var(--bg-color);
}

.calendar-header {
    display: flex;
    position: sticky;
    top: 0;
    z-index: 10;
    background: var(--white);
    border-bottom: 1px solid var(--border-color);
    min-width: max-content;
}

.date-cell {
    width: var(--cell-width);
    min-width: var(--cell-width);
    max-width: var(--cell-width);
    height: 50px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    border-right: 1px solid var(--border-color);
    font-size: 12px;
}

.date-cell .day-name {
    font-size: 10px;
    color: var(--text-secondary);
    text-transform: uppercase;
}

.date-cell .day-number {
    font-weight: 600;
    font-size: 14px;
}

.date-cell.today {
    background: var(--white);
    color: var(--primary-color);
    position: relative;
    border-left: 2px solid var(--primary-color);
    border-right: 2px solid var(--primary-color);
}

.date-cell.today::before {
    content: 'TODAY';
    position: absolute;
    top: 2px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 8px;
    font-weight: 700;
    color: var(--white);
    background: var(--primary-color);
    padding: 1px 4px;
    border-radius: 3px;
}

.date-cell.today .day-name {
    color: var(--primary-color);
    font-weight: 700;
    margin-top: 12px;
}

.date-cell.today .day-number {
    font-weight: 800;
    font-size: 18px;
    color: var(--primary-color);
}

.date-cell.weekend {
    background: #fafafa;
}

/* 月の1日のラベル */
.day-number-row {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 2px;
}

.date-cell .month-label {
    font-size: 10px;
    font-weight: 600;
    color: var(--primary-color);
}

.date-cell.first-of-month {
    position: relative;
}

.date-cell.first-of-month .day-number {
    font-weight: 700;
}

/* カレンダーボディ */
.calendar-body {
    position: relative;
    min-width: max-content;
}

.calendar-row {
    display: flex;
    position: relative;
    height: var(--cell-height);
    border-bottom: 1px solid var(--border-color);
    min-width: max-content;
}

.calendar-cell {
    width: var(--cell-width);
    min-width: var(--cell-width);
    max-width: var(--cell-width);
    height: 100%;
    border-right: none;
    position: relative;
    overflow: visible;
}

/* 予約がない日だけ区切り線を表示（疑似要素で） */
.calendar-cell:not(.has-booking)::after {
    content: '';
    position: absolute;
    right: 0;
    top: 0;
    bottom: 0;
    width: 1px;
    background: var(--border-color);
    z-index: 1;
}

.calendar-cell.weekend {
    background: #fafafa;
}

.calendar-cell.today {
    background: rgba(8, 145, 178, 0.08);
}

.calendar-cell.today::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 2px;
    background: var(--primary-color);
    z-index: 10;
}

.calendar-cell.today::after {
    content: '';
    position: absolute;
    right: 0;
    top: 0;
    bottom: 0;
    width: 2px;
    background: var(--primary-color);
    z-index: 10;
}

/* ==========================================
   予約バー - チェックイン/アウトの半分塗りつぶし
   ========================================== */

/* 予約バーコンテナ */
.booking-bar-container {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    height: 36px;
    display: flex;
    align-items: center;
    z-index: 5;
    pointer-events: none;
}

/* 予約バー本体 */
.booking-bar {
    height: 100%;
    display: flex;
    align-items: center;
    border-radius: 12px;
    padding: 0 10px;
    font-size: 11px;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    pointer-events: auto;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
}

.booking-bar:hover {
    transform: scale(1.02);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    z-index: 10;
}

/* Airbnb スタイル */
.booking-bar.airbnb {
    background: var(--airbnb-color);
    color: var(--white);
}

/* Booking.com スタイル */
.booking-bar.booking {
    background: var(--booking-color);
    color: var(--white);
}

/* ブロック/利用不可 スタイル */
.booking-bar.blocked {
    background: var(--blocked-color);
    color: var(--white);
}

/* Not Available スタイル（薄いグレー） */
.booking-bar.unavailable {
    background: var(--unavailable-color);
    color: var(--unavailable-text);
}

/* プラットフォームアイコン */
.booking-bar .platform-icon {
    width: 20px;
    height: 20px;
    margin-right: 8px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 4px;
    font-size: 10px;
}

.booking-bar .booking-text {
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ==========================================
   セル内の半分塗りつぶし（チェックイン/アウト）
   ========================================== */

/* チェックインセル - 後半だけ塗りつぶし */
.cell-checkin {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    right: -2px;
    width: calc(50% + 4px);
    height: 36px;
    border-radius: 12px 0 0 12px;
    z-index: 3;
}

.cell-checkin.airbnb {
    background: var(--airbnb-color);
}

.cell-checkin.booking {
    background: var(--booking-color);
}

.cell-checkin.blocked {
    background: var(--blocked-color);
}

.cell-checkin.unavailable {
    background: var(--unavailable-color);
}

/* チェックアウトセル - 前半だけ塗りつぶし */
.cell-checkout {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    left: -2px;
    width: calc(50% + 4px);
    height: 36px;
    border-radius: 0 12px 12px 0;
    z-index: 3;
}

.cell-checkout.airbnb {
    background: var(--airbnb-color);
}

.cell-checkout.booking {
    background: var(--booking-color);
}

.cell-checkout.blocked {
    background: var(--blocked-color);
}

.cell-checkout.unavailable {
    background: var(--unavailable-color);
}

/* 同日チェックイン/アウト時の重なり防止 */
.cell-same-day {
    position: absolute;
    top: 50%;
    left: -2px;
    width: calc(100% + 4px);
    transform: translateY(-50%);
    height: 36px;
    z-index: 3;
    display: flex;
}

.cell-same-day .checkout-half {
    width: 50%;
    height: 100%;
    border-radius: 0 12px 12px 0;
}

.cell-same-day .checkin-half {
    width: 50%;
    height: 100%;
    border-radius: 12px 0 0 12px;
}

/* 同日チェックイン/アウトの色 */
.cell-same-day .checkout-half.airbnb {
    background: var(--airbnb-color);
}

.cell-same-day .checkout-half.booking {
    background: var(--booking-color);
}

.cell-same-day .checkout-half.unavailable {
    background: var(--unavailable-color);
}

.cell-same-day .checkin-half.airbnb {
    background: var(--airbnb-color);
}

.cell-same-day .checkin-half.booking {
    background: var(--booking-color);
}

.cell-same-day .checkin-half.unavailable {
    background: var(--unavailable-color);
}

/* 中間日（全体塗りつぶし） */
.cell-middle {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    left: -2px;
    width: calc(100% + 4px);
    height: 36px;
    z-index: 4;
}

.cell-middle.airbnb {
    background: var(--airbnb-color);
}

.cell-middle.booking {
    background: var(--booking-color);
}

.cell-middle.blocked {
    background: var(--blocked-color);
}

.cell-middle.unavailable {
    background: var(--unavailable-color);
}

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

.modal.active {
    display: flex;
}

.modal-content {
    background: var(--white);
    border-radius: 12px;
    width: 100%;
    max-width: 500px;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.2);
}

.modal-content.modal-small {
    max-width: 400px;
}

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

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

.modal-close {
    width: 32px;
    height: 32px;
    border: none;
    background: transparent;
    cursor: pointer;
    color: var(--text-secondary);
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-close:hover {
    background: var(--bg-color);
}

.modal-body {
    padding: 20px;
}

.form-group {
    margin-bottom: 16px;
}

.form-group label {
    display: block;
    font-weight: 500;
    margin-bottom: 8px;
    font-size: 13px;
}

.form-group input,
.form-group textarea,
.form-group select {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    font-size: 14px;
    font-family: inherit;
}

.form-group textarea {
    height: 120px;
    resize: vertical;
}

.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(8, 145, 178, 0.1);
}

/* ラジオボタングループ */
.radio-group {
    display: flex;
    gap: 16px;
}

.radio-label {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 400;
}

.radio-label input[type="radio"] {
    width: 18px;
    height: 18px;
    margin: 0;
    cursor: pointer;
    accent-color: var(--primary-color);
}

.modal-footer {
    padding: 16px 20px;
    border-top: 1px solid var(--border-color);
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}

.btn {
    padding: 10px 20px;
    border-radius: 6px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    border: none;
}

.btn-secondary {
    background: var(--bg-color);
    color: var(--text-primary);
}

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

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

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

/* ==========================================
   ツールチップ
   ========================================== */
.tooltip {
    position: absolute;
    background: var(--text-primary);
    color: var(--white);
    padding: 8px 12px;
    border-radius: 6px;
    font-size: 12px;
    z-index: 100;
    pointer-events: none;
    white-space: nowrap;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.tooltip::after {
    content: '';
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    border: 6px solid transparent;
    border-top-color: var(--text-primary);
}

/* ==========================================
   レスポンシブ
   ========================================== */
@media (max-width: 768px) {
    .header {
        flex-direction: column;
        height: auto;
        padding: 12px;
        gap: 12px;
    }
    
    .header-left,
    .header-right {
        width: 100%;
        justify-content: center;
        flex-wrap: wrap;
    }
    
    .sidebar {
        width: 150px;
    }
    
    :root {
        --cell-width: 50px;
        --cell-height: 70px;
    }
}

/* ==========================================
   アニメーション
   ========================================== */
@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

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

.calendar-row {
    animation: fadeIn 0.3s ease-out;
}

.booking-bar {
    animation: slideIn 0.3s ease-out;
}

/* ==========================================
   ローディングスピナー
   ========================================== */
.btn-loading {
    position: relative;
    pointer-events: none;
}

.btn-loading::after {
    content: '';
    position: absolute;
    width: 16px;
    height: 16px;
    top: 50%;
    left: 50%;
    margin-left: -8px;
    margin-top: -8px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top-color: #fff;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

.btn:disabled {
    opacity: 0.7;
    cursor: not-allowed;
}

/* ステータスメッセージ */
.status-message {
    padding: 10px;
    border-radius: 6px;
    margin-bottom: 15px;
    font-size: 13px;
}

.status-message.info {
    background: #e0f2fe;
    color: #0369a1;
    border: 1px solid #7dd3fc;
}

.status-message.error {
    background: #fef2f2;
    color: #dc2626;
    border: 1px solid #fca5a5;
}

.status-message.success {
    background: #f0fdf4;
    color: #16a34a;
    border: 1px solid #86efac;
}
