/* ========================================
   予約システム スタイルシート
   ======================================== */

:root {
    --primary: #2563eb;
    --primary-dark: #1d4ed8;
    --primary-light: #dbeafe;
    --success: #16a34a;
    --success-light: #dcfce7;
    --danger: #dc2626;
    --danger-light: #fee2e2;
    --warning: #d97706;
    --gray-50: #f9fafb;
    --gray-100: #f3f4f6;
    --gray-200: #e5e7eb;
    --gray-300: #d1d5db;
    --gray-500: #6b7280;
    --gray-700: #374151;
    --gray-900: #111827;
    --border-radius: 12px;
    --shadow: 0 1px 3px rgba(0,0,0,0.1), 0 1px 2px rgba(0,0,0,0.06);
    --shadow-md: 0 4px 6px rgba(0,0,0,0.07), 0 2px 4px rgba(0,0,0,0.06);
    --shadow-lg: 0 10px 15px rgba(0,0,0,0.1), 0 4px 6px rgba(0,0,0,0.05);
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Hiragino Sans',
                 'Hiragino Kaku Gothic ProN', 'Noto Sans JP', sans-serif;
    background: var(--gray-50);
    color: var(--gray-900);
    line-height: 1.6;
    min-height: 100vh;
}

.container {
    max-width: 900px;
    margin: 0 auto;
    padding: 0 16px;
}

/* ─── Headers ──────────────────────────────── */

.admin-header, .booking-header {
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: white;
    padding: 24px 0;
    margin-bottom: 32px;
}

.admin-header h1, .booking-header h1 {
    font-size: clamp(1.4rem, 4vw, 1.8rem);
    font-weight: 700;
    margin-bottom: 4px;
}

.subtitle {
    opacity: 0.85;
    font-size: 0.9rem;
}

.back-link {
    display: inline-block;
    color: rgba(255,255,255,0.85);
    text-decoration: none;
    font-size: 0.9rem;
    margin-bottom: 8px;
}

.back-link:hover { color: white; }

/* ─── Cards ──────────────────────────────── */

.card {
    background: white;
    border-radius: var(--border-radius);
    padding: 24px;
    margin-bottom: 24px;
    box-shadow: var(--shadow);
}

.card h2 {
    font-size: 1.1rem;
    font-weight: 700;
    margin-bottom: 20px;
    color: var(--gray-700);
    padding-bottom: 12px;
    border-bottom: 2px solid var(--gray-100);
}

/* ─── Forms ──────────────────────────────── */

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

.form-group label {
    display: block;
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--gray-700);
    margin-bottom: 6px;
}

.required {
    color: var(--danger);
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid var(--gray-300);
    border-radius: 8px;
    font-size: 0.95rem;
    color: var(--gray-900);
    background: white;
    transition: border-color 0.2s, box-shadow 0.2s;
}

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

.form-row {
    display: flex;
    gap: 16px;
    flex-wrap: wrap;
}

.flex-1 { flex: 1; min-width: 200px; }
.flex-2 { flex: 2; min-width: 250px; }

/* ─── Buttons ──────────────────────────────── */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 10px 20px;
    border: none;
    border-radius: 8px;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    transition: all 0.2s;
    white-space: nowrap;
}

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

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

.btn-primary:hover:not(:disabled) {
    background: var(--primary-dark);
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

.btn-secondary {
    background: var(--gray-100);
    color: var(--gray-700);
}

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

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

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

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

.btn-outline {
    background: transparent;
    color: var(--primary);
    border: 1px solid var(--primary);
}

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

.btn-sm {
    padding: 6px 12px;
    font-size: 0.8rem;
}

.btn-full {
    width: 100%;
}

/* ─── Login Page ──────────────────────────── */

.login-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

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

.login-card {
    background: white;
    border-radius: 16px;
    padding: 36px;
    box-shadow: var(--shadow-lg);
    text-align: center;
}

.login-card h1 {
    font-size: 1.6rem;
    margin-bottom: 8px;
}

.login-card .subtitle {
    color: var(--gray-500);
    font-size: 0.9rem;
    margin-bottom: 28px;
}

/* ─── Alerts ──────────────────────────────── */

.alert {
    padding: 12px 16px;
    border-radius: 8px;
    margin-bottom: 16px;
    font-size: 0.9rem;
}

.alert-error {
    background: var(--danger-light);
    color: var(--danger);
    border: 1px solid #fca5a5;
}

/* ─── Admin URL List ───────────────────────── */

.url-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.url-item {
    background: var(--gray-50);
    border: 1px solid var(--gray-200);
    border-radius: 10px;
    padding: 16px;
    transition: box-shadow 0.2s;
}

.url-item:hover {
    box-shadow: var(--shadow-md);
}

.url-item--inactive {
    opacity: 0.7;
    background: var(--gray-100);
}

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

.url-item-title {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 1rem;
}

.url-item-meta {
    display: flex;
    gap: 12px;
    font-size: 0.8rem;
    color: var(--gray-500);
    flex-wrap: wrap;
}

.url-item-memo {
    font-size: 0.85rem;
    color: var(--gray-500);
    margin-bottom: 10px;
    padding: 6px 10px;
    background: white;
    border-radius: 6px;
}

.url-item-link {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.url-text {
    font-size: 0.8rem;
    color: var(--gray-500);
    background: white;
    padding: 6px 10px;
    border-radius: 6px;
    border: 1px solid var(--gray-200);
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 300px;
}

.url-actions {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}

/* ─── Status Badges ─────────────────────────── */

.status-badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 700;
}

.badge-active {
    background: var(--success-light);
    color: var(--success);
}

.badge-inactive {
    background: var(--gray-200);
    color: var(--gray-500);
}

.duration-badge {
    display: inline-block;
    padding: 2px 8px;
    background: var(--primary-light);
    color: var(--primary);
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 600;
}

/* ─── Booking Page ────────────────────────── */

.booking-meta {
    margin-top: 8px;
}

.duration-badge-lg {
    display: inline-block;
    background: rgba(255,255,255,0.2);
    color: white;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 0.9rem;
    font-weight: 600;
}

.booking-memo {
    margin-top: 8px;
    opacity: 0.9;
    font-size: 0.9rem;
}

.hint {
    font-size: 0.85rem;
    color: var(--gray-500);
    margin-bottom: 16px;
    margin-top: -8px;
}

.booking-form-card {
    position: sticky;
    top: 16px;
    z-index: 10;
}

.selected-slot-display {
    background: var(--primary-light);
    border: 1px solid var(--primary);
    border-radius: 8px;
    padding: 10px 14px;
    margin-bottom: 12px;
    font-size: 0.9rem;
    color: var(--primary-dark);
}

/* ─── Calendar Grid ────────────────────────── */

.calendar-grid {
    display: flex;
    gap: 12px;
    overflow-x: auto;
    padding-bottom: 8px;
    -webkit-overflow-scrolling: touch;
}

.date-column {
    flex: 0 0 auto;
    min-width: 90px;
    max-width: 110px;
}

.date-header {
    text-align: center;
    margin-bottom: 8px;
}

.date-label {
    display: inline-block;
    font-size: 0.8rem;
    font-weight: 700;
    color: var(--gray-700);
    background: var(--gray-100);
    padding: 4px 6px;
    border-radius: 6px;
    text-align: center;
    width: 100%;
}

.slots-list {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.slot-btn {
    display: block;
    width: 100%;
    padding: 8px 4px;
    background: white;
    border: 1.5px solid var(--gray-300);
    border-radius: 8px;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--primary);
    cursor: pointer;
    text-align: center;
    transition: all 0.15s;
}

.slot-btn:hover {
    background: var(--primary-light);
    border-color: var(--primary);
    transform: scale(1.03);
}

.slot-btn.selected {
    background: var(--primary);
    border-color: var(--primary);
    color: white;
    box-shadow: 0 2px 8px rgba(37,99,235,0.4);
    transform: scale(1.05);
}

/* ─── Confirmed Page ─────────────────────── */

.confirmed-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 16px;
}

.confirmed-card {
    background: white;
    border-radius: 16px;
    padding: 40px 32px;
    max-width: 500px;
    width: 100%;
    text-align: center;
    box-shadow: var(--shadow-lg);
}

.confirmed-icon {
    font-size: 4rem;
    margin-bottom: 16px;
}

.confirmed-card h1 {
    font-size: 1.5rem;
    color: var(--success);
    margin-bottom: 24px;
}

.confirmed-details {
    text-align: left;
    margin: 24px 0;
}

.detail-table {
    width: 100%;
    border-collapse: collapse;
}

.detail-table th,
.detail-table td {
    padding: 10px 14px;
    border-bottom: 1px solid var(--gray-200);
    font-size: 0.9rem;
}

.detail-table th {
    color: var(--gray-500);
    font-weight: 600;
    width: 100px;
    white-space: nowrap;
}

.calendar-notice {
    background: var(--success-light);
    color: var(--success);
    padding: 10px 16px;
    border-radius: 8px;
    font-size: 0.875rem;
    font-weight: 600;
    margin-bottom: 20px;
}

.confirmed-message {
    color: var(--gray-500);
    font-size: 0.9rem;
    line-height: 1.8;
}

/* ─── Error Page ─────────────────────────── */

.error-card {
    background: white;
    border-radius: 16px;
    padding: 40px 32px;
    max-width: 500px;
    width: 100%;
    text-align: center;
    box-shadow: var(--shadow-lg);
    margin: 80px auto;
}

.error-icon {
    font-size: 3rem;
    margin-bottom: 16px;
}

.error-card h1 {
    font-size: 1.4rem;
    color: var(--danger);
    margin-bottom: 12px;
}

.error-message {
    color: var(--gray-500);
    margin-bottom: 24px;
    line-height: 1.7;
}

/* ─── Table ───────────────────────────────── */

.bookings-table-wrapper {
    overflow-x: auto;
}

.bookings-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.875rem;
}

.bookings-table th {
    background: var(--gray-100);
    padding: 10px 14px;
    text-align: left;
    font-weight: 700;
    color: var(--gray-700);
    border-bottom: 2px solid var(--gray-200);
    white-space: nowrap;
}

.bookings-table td {
    padding: 10px 14px;
    border-bottom: 1px solid var(--gray-100);
    color: var(--gray-700);
}

.bookings-table tr:hover td {
    background: var(--gray-50);
}

.bookings-table a {
    color: var(--primary);
    text-decoration: none;
}

/* ─── Empty State ───────────────────────────── */

.empty-state {
    text-align: center;
    color: var(--gray-500);
    padding: 32px;
    font-size: 0.95rem;
}

/* ─── Create Form ───────────────────────────── */

.create-form {
    padding-top: 4px;
}

/* ─── Responsive ────────────────────────────── */

@media (max-width: 640px) {
    .card {
        padding: 16px;
    }

    .admin-header, .booking-header {
        padding: 16px 0;
        margin-bottom: 16px;
    }

    .url-item-header {
        flex-direction: column;
    }

    .url-text {
        max-width: 200px;
        font-size: 0.75rem;
        word-break: break-all;
    }

    .url-actions {
        flex-wrap: wrap;
        gap: 6px;
    }

    .booking-form-card {
        position: static;
    }

    .confirmed-card, .error-card {
        padding: 28px 20px;
    }

    .detail-table th {
        width: 80px;
    }

    /* ── スロット選択：スマホは横スクロールから縦グリッドへ ── */
    .calendar-grid {
        display: grid;
        grid-template-columns: repeat(2, 1fr);
        gap: 8px;
        overflow-x: unset;
    }

    .date-column {
        min-width: unset;
        max-width: unset;
        width: 100%;
    }

    .date-label {
        font-size: 0.75rem;
        padding: 4px;
    }

    .slot-btn {
        padding: 12px 4px;
        font-size: 0.9rem;
        /* タップしやすいサイズに */
        min-height: 44px;
    }

    /* 予約フォームの入力フィールドを大きく */
    input[type="text"],
    input[type="email"],
    select,
    textarea {
        font-size: 16px !important; /* iOS自動ズーム防止 */
        padding: 12px !important;
    }

    .btn-primary {
        width: 100%;
        padding: 16px;
        font-size: 1.05rem;
    }
}

@media (max-width: 480px) {
    .form-row {
        flex-direction: column;
    }

    .flex-1, .flex-2 {
        min-width: 100%;
    }

    /* 管理者ページのボタンを縦並び */
    .url-item-link {
        flex-direction: column;
    }

    .bookings-table {
        font-size: 0.8rem;
    }
}
