/* 
 * 次世代運行管理・見積システム - 管理画面スタイル
 */

/* Reset */
*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

.hidden {
    display: none !important;
}

:root {
    --primary: #2563eb;
    --primary-dark: #1d4ed8;
    --success: #10b981;
    --warning: #f59e0b;
    --danger: #ef4444;
    --text: #1e293b;
    --text-light: #64748b;
    --bg: #f1f5f9;
    --white: #ffffff;
    --border: #e2e8f0;
    --sidebar-width: 260px;
}

body {
    font-family: 'Inter', 'Noto Sans JP', -apple-system, BlinkMacSystemFont, "Segoe UI", "Hiragino Kaku Gothic ProN", "Hiragino Sans", "Meiryo", sans-serif;
    font-size: 14px;
    line-height: 1.6;
    color: var(--text);
    background: var(--bg);
}

/* ============================================
   Admin Layout
   ============================================ */
.admin-layout {
    display: flex;
    min-height: 100vh;
}

/* Sidebar */
.sidebar {
    width: var(--sidebar-width);
    background: #1e293b;
    color: white;
    display: flex;
    flex-direction: column;
    position: fixed;
    height: 100vh;
    overflow-y: auto;
}

.sidebar-header {
    padding: 20px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.sidebar-header .logo {
    font-size: 20px;
    font-weight: 700;
    color: white;
}

.sidebar-nav {
    flex: 1;
    padding: 20px 0;
}

.nav-item {
    display: flex;
    align-items: center;
    padding: 12px 20px;
    color: rgba(255, 255, 255, 0.7);
    text-decoration: none;
    transition: all 0.2s;
}

.nav-item:hover {
    background: rgba(255, 255, 255, 0.1);
    color: white;
}

.nav-item.active {
    background: var(--primary);
    color: white;
}

.nav-icon {
    margin-right: 12px;
    font-size: 18px;
}

.sidebar-footer {
    padding: 20px;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.user-info {
    margin-bottom: 10px;
}

.user-email {
    display: block;
    font-size: 13px;
    color: white;
}

.user-role {
    display: block;
    font-size: 11px;
    color: rgba(255, 255, 255, 0.5);
    text-transform: uppercase;
}

.btn-logout {
    width: 100%;
    padding: 8px;
    background: rgba(255, 255, 255, 0.1);
    border: none;
    border-radius: 4px;
    color: white;
    cursor: pointer;
}

.btn-logout:hover {
    background: rgba(255, 255, 255, 0.2);
}

/* Main Content */
.main-content {
    margin-left: var(--sidebar-width);
    flex: 1;
    display: flex;
    flex-direction: column;
}

.content-header {
    background: var(--white);
    padding: 20px 30px;
    border-bottom: 1px solid var(--border);
}

.content-header h2 {
    font-size: 20px;
    font-weight: 600;
}

.content-body {
    padding: 30px;
    flex: 1;
}

/* ============================================
   Dashboard
   ============================================ */
.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

.stat-card {
    background: var(--white);
    padding: 24px;
    border-radius: 8px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    display: flex;
    align-items: center;
}

.stat-icon {
    font-size: 32px;
    margin-right: 16px;
}

.stat-value {
    font-size: 28px;
    font-weight: 700;
    color: var(--primary);
}

.stat-label {
    font-size: 13px;
    color: var(--text-light);
}

.dashboard-section {
    background: var(--white);
    padding: 24px;
    border-radius: 8px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.dashboard-section h3 {
    margin-bottom: 20px;
    font-size: 16px;
}

/* ============================================
   Data Table
   ============================================ */
.table-container {
    overflow-x: auto;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
}

.data-table th,
.data-table td {
    padding: 12px 16px;
    text-align: left;
    border-bottom: 1px solid var(--border);
}

.data-table th {
    background: #f8fafc;
    font-weight: 600;
    font-size: 12px;
    text-transform: uppercase;
    color: var(--text-light);
}

.data-table tbody tr:hover {
    background: #f8fafc;
}

.status-badge {
    display: inline-block;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 500;
}

.status-pending {
    background: #fef3c7;
    color: #92400e;
}

.status-booked {
    background: #d1fae5;
    color: #065f46;
}

.status-cancelled {
    background: #fee2e2;
    color: #991b1b;
}

/* ============================================
   Login Page
   ============================================ */
.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

.login-container {
    width: 100%;
    max-width: 400px;
    padding: 20px;
}

.login-box {
    background: var(--white);
    padding: 40px;
    border-radius: 12px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
}

.login-box h1 {
    text-align: center;
    margin-bottom: 30px;
    font-size: 24px;
}

/* ============================================
   Forms
   ============================================ */
.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    margin-bottom: 6px;
    font-weight: 500;
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 12px;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 14px;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.form-group input::placeholder,
.form-group textarea::placeholder {
    color: #c0c8d4;
}

/* Buttons */
.btn {
    display: inline-block;
    padding: 12px 24px;
    font-size: 14px;
    font-weight: 600;
    border-radius: 6px;
    border: none;
    cursor: pointer;
    text-decoration: none;
    transition: all 0.2s;
}

.btn-primary {
    background: var(--primary);
    color: white;
}

.btn-primary:hover {
    background: var(--primary-dark);
}

.btn-block {
    display: block;
    width: 100%;
}

.error-message {
    background: #fee2e2;
    color: #991b1b;
    padding: 12px;
    border-radius: 6px;
    margin-bottom: 20px;
    font-size: 13px;
}

.loading {
    text-align: center;
    color: var(--text-light);
    padding: 40px;
}

/* ============================================
   Toolbar
   ============================================ */
.toolbar {
    margin-bottom: 20px;
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}

/* Button Variants */
.btn-secondary {
    background: #6b7280;
    color: white;
}

.btn-secondary:hover {
    background: #4b5563;
}

.btn-danger {
    background: var(--danger);
    color: white;
}

.btn-danger:hover {
    background: #dc2626;
}

.btn-sm {
    padding: 6px 12px;
    font-size: 12px;
}

/* ============================================
   Modal
   ============================================ */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
}

.modal-content {
    position: relative;
    background: var(--white);
    padding: 32px;
    border-radius: 12px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    width: 90%;
    max-width: 500px;
    max-height: 80vh;
    overflow-y: auto;
}

.modal-content h3 {
    margin-bottom: 24px;
    font-size: 18px;
}

.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 24px;
}

/* Form Row (side by side) */
.form-row {
    display: flex;
    gap: 16px;
}

.form-row .form-group {
    flex: 1;
}

/* Checkbox Group */
.checkbox-group {
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
}

.checkbox-group label {
    display: flex;
    align-items: center;
    gap: 6px;
    font-weight: 400;
    cursor: pointer;
}

.checkbox-group input[type="checkbox"] {
    width: auto;
}

/* Geocode Result */
.geocode-result {
    background: #ecfdf5;
    border: 1px solid #a7f3d0;
    border-radius: 6px;
    padding: 12px;
    margin-bottom: 16px;
    font-size: 13px;
    line-height: 1.5;
}

.geocode-label {
    font-weight: 600;
    color: #065f46;
    display: block;
    margin-bottom: 4px;
}

/* ============================================
   Fleet Management (空車管理)
   ============================================ */
.fleet-layout {
    display: grid;
    grid-template-columns: 300px 1fr;
    gap: 24px;
    min-height: 600px;
}

.garage-panel {
    background: var(--white);
    border-radius: 12px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, .08);
    padding: 20px;
}

.garage-panel h3 {
    font-size: 14px;
    color: var(--text-light);
    margin-bottom: 12px;
    text-transform: uppercase;
    letter-spacing: .5px;
}

.garage-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.garage-list li {
    padding: 10px 14px;
    border-radius: 8px;
    cursor: pointer;
    transition: all .15s;
    margin-bottom: 4px;
    font-size: 14px;
}

.garage-list li:hover {
    background: #f3f4f6;
}

.garage-list li.active {
    background: var(--primary);
    color: white;
}

.calendar-panel {
    background: var(--white);
    border-radius: 12px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, .08);
    padding: 24px;
}

.calendar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
}

.calendar-nav {
    display: flex;
    align-items: center;
    gap: 12px;
}

.calendar-nav button {
    background: #f3f4f6;
    border: none;
    border-radius: 8px;
    padding: 8px 14px;
    cursor: pointer;
    font-size: 14px;
    transition: background .15s;
}

.calendar-nav button:hover {
    background: #e5e7eb;
}

.calendar-nav .month-label {
    font-size: 16px;
    font-weight: 600;
    min-width: 100px;
    text-align: center;
}

.fleet-settings {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 12px;
    margin-bottom: 24px;
    padding: 16px;
    background: #f8fafc;
    border-radius: 10px;
}

.fleet-item {
    display: flex;
    align-items: center;
    gap: 8px;
}

.fleet-item label {
    font-size: 13px;
    color: #374151;
    min-width: 80px;
}

.fleet-item input {
    width: 60px;
    padding: 4px 8px;
    border: 1px solid var(--border);
    border-radius: 6px;
    text-align: center;
    font-size: 14px;
}

.fleet-item .unit {
    font-size: 12px;
    color: #9ca3af;
}

.btn-save-fleet {
    background: var(--primary);
    color: white;
    border: none;
    padding: 8px 20px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 13px;
    transition: background .15s;
}

.btn-save-fleet:hover {
    background: var(--primary-dark);
}

.vtype-tabs {
    display: flex;
    gap: 4px;
    margin-bottom: 16px;
}

.vtype-tab {
    padding: 6px 16px;
    border: 1px solid var(--border);
    border-radius: 20px;
    background: var(--white);
    cursor: pointer;
    font-size: 13px;
    transition: all .15s;
}

.vtype-tab:hover {
    background: #f3f4f6;
}

.vtype-tab.active {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

.calendar-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 2px;
}

.calendar-grid .weekday-header {
    text-align: center;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-light);
    padding: 8px 0;
}

.calendar-grid .weekday-header.sun {
    color: #dc2626;
}

.calendar-grid .weekday-header.sat {
    color: var(--primary);
}

.day-cell {
    border: 1px solid #e5e7eb;
    border-radius: 6px;
    padding: 4px;
    min-height: 60px;
    position: relative;
    cursor: pointer;
    transition: all .15s;
}

.day-cell:hover {
    border-color: var(--primary);
    box-shadow: 0 0 0 1px var(--primary);
}

.day-cell.empty {
    border: none;
    cursor: default;
}

.day-cell.empty:hover {
    border: none;
    box-shadow: none;
}

.day-cell .day-num {
    font-size: 11px;
    color: var(--text-light);
    margin-bottom: 2px;
}

.day-cell .day-num.sun {
    color: #dc2626;
}

.day-cell .day-num.sat {
    color: var(--primary);
}

.day-cell .avail-count {
    font-size: 18px;
    font-weight: 700;
    text-align: center;
    padding: 4px 0;
}

.day-cell .avail-count.full {
    color: #059669;
}

.day-cell .avail-count.partial {
    color: #d97706;
}

.day-cell .avail-count.zero {
    color: #dc2626;
}

.day-cell .avail-note {
    font-size: 9px;
    color: #9ca3af;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.day-cell.past {
    opacity: .4;
    pointer-events: none;
}

.day-edit-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, .5);
    z-index: 1000;
    justify-content: center;
    align-items: center;
}

.day-edit-modal.active {
    display: flex;
}

.day-edit-content {
    background: var(--white);
    border-radius: 12px;
    padding: 24px;
    min-width: 320px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, .2);
}

.day-edit-content h4 {
    font-size: 16px;
    margin-bottom: 16px;
}

.day-edit-content .form-row {
    margin-bottom: 12px;
}

.day-edit-content label {
    display: block;
    font-size: 13px;
    color: #374151;
    margin-bottom: 4px;
}

.day-edit-content input,
.day-edit-content textarea {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 14px;
    box-sizing: border-box;
}

.day-edit-content textarea {
    height: 60px;
    resize: vertical;
}

.day-edit-actions {
    display: flex;
    gap: 8px;
    justify-content: flex-end;
    margin-top: 16px;
}

.day-edit-actions button {
    padding: 8px 20px;
    border-radius: 8px;
    border: none;
    cursor: pointer;
    font-size: 13px;
}

.day-edit-actions .btn-cancel {
    background: #f3f4f6;
    color: #374151;
}

.day-edit-actions .btn-save {
    background: var(--primary);
    color: white;
}

.no-garage-msg {
    text-align: center;
    color: #9ca3af;
    padding: 60px 20px;
    font-size: 15px;
}

.fleet-garage-title {
    font-size: 15px;
    margin-bottom: 12px;
}

.fleet-toolbar {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 16px;
}

.fleet-toolbar-label {
    font-size: 13px;
    color: var(--text-light);
}

.garage-vtype-label {
    font-size: 11px;
    color: #9ca3af;
}

/* プロファイルバッジ（カレンダーセル内） */
.day-profiles {
    display: flex;
    gap: 2px;
    justify-content: center;
    margin-top: 2px;
}

.day-pf-badge {
    font-size: 9px;
    font-weight: 600;
    padding: 1px 4px;
    border-radius: 3px;
    line-height: 1.3;
}

/* プロファイル選択ドロップダウン */
.profile-select {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 13px;
    box-sizing: border-box;
    background: #fff;
}

.profile-edit-section {
    margin: 8px 0;
    padding: 10px;
    background: #f8fafc;
    border-radius: 8px;
    border: 1px solid #e2e8f0;
}

.profile-edit-section .form-row {
    display: block;
    margin-bottom: 8px;
}

.profile-edit-section .form-row:last-child {
    margin-bottom: 0;
}

.profile-edit-section label {
    display: block;
    font-size: 12px;
    color: #64748b;
    margin-bottom: 4px;
    font-weight: 500;
}

/* 一括設定ボタン */
.btn-bulk-assign {
    background: #7c3aed;
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
    transition: background .15s;
}

.btn-bulk-assign:hover {
    background: #6d28d9;
}

/* 一括設定パネル */
.bulk-panel {
    margin-top: 20px;
    padding: 16px;
    background: #f5f3ff;
    border: 1.5px solid #c4b5fd;
    border-radius: 10px;
}

.bulk-panel.hidden {
    display: none;
}

.bulk-panel h4 {
    margin: 0 0 12px;
    font-size: 14px;
    color: #5b21b6;
}

.bulk-row {
    display: flex;
    gap: 12px;
    margin-bottom: 12px;
}

.bulk-field {
    flex: 1;
    display: flex;
    flex-direction: column;
}

.bulk-field input[type="date"] {
    flex: 1;
}

.bulk-field label {
    display: block;
    font-size: 12px;
    color: #64748b;
    margin-bottom: 4px;
    font-weight: 500;
}

.bulk-field input,
.bulk-field select,
.bulk-field textarea {
    width: 100%;
    padding: 8px 10px;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    font-size: 13px;
    box-sizing: border-box;
}

.bulk-field textarea {
    resize: vertical;
    font-family: inherit;
}

.bulk-field-wide {
    flex: 3;
}

/* 一括設定: 日付/期間モード切替 */
.bulk-mode-label {
    display: flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 600;
    color: #1e293b;
    margin-bottom: 6px;
    user-select: none;
}

.bulk-mode-label input[type="radio"] {
    width: auto;
    margin: 0;
    accent-color: #7c3aed;
    cursor: pointer;
}

.bulk-mode-group {
    transition: opacity .2s ease;
    position: relative;
}

.bulk-mode-group.disabled {
    opacity: .45;
}

.bulk-mode-group.disabled .bulk-mode-text {
    color: #9ca3af;
}

.bulk-mode-group.disabled input:not([type="radio"]),
.bulk-mode-group.disabled textarea,
.bulk-mode-group.disabled select {
    background: #f1f5f9;
    color: #94a3b8;
    cursor: not-allowed;
    border-color: #e2e8f0;
}

.bulk-mode-group:not(.disabled) .bulk-mode-text {
    color: #1e293b;
}

.bulk-actions {
    display: flex;
    gap: 8px;
    justify-content: flex-end;
}

.bulk-actions button {
    padding: 8px 20px;
    border-radius: 8px;
    border: none;
    cursor: pointer;
    font-size: 13px;
}

.bulk-actions .btn-cancel {
    background: #f3f4f6;
    color: #374151;
}

.bulk-actions .btn-save {
    background: #7c3aed;
    color: white;
}

/* ============================================
   Responsive
   ============================================ */
@media (max-width: 768px) {
    .sidebar {
        width: 100%;
        height: auto;
        position: relative;
        display: none;
    }

    .sidebar.mobile-open {
        display: block;
    }

    .main-content {
        margin-left: 0;
    }

    .admin-layout {
        flex-direction: column;
    }

    .fleet-layout {
        grid-template-columns: 1fr;
    }

    .content-header {
        padding: 14px 16px;
    }

    .content-header h2 {
        font-size: 17px;
    }

    .content-body {
        padding: 16px;
    }

    .toolbar {
        flex-direction: column;
    }

    .form-row {
        flex-direction: column;
        gap: 0;
    }

    .modal-content {
        width: 95%;
        padding: 20px;
    }

    .dashboard-grid {
        grid-template-columns: 1fr;
    }

    .stat-value {
        font-size: 22px;
    }

    /* テーブル横スクロール */
    .table-container {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    /* カレンダー */
    .calendar-grid {
        gap: 1px;
    }

    .day-cell {
        min-height: 45px;
        padding: 2px;
    }

    .day-cell .avail-count {
        font-size: 14px;
    }

    .fleet-settings {
        grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    }
}

/* ハンバーガーメニューボタン（モバイル用） */
.mobile-menu-btn {
    display: none;
    position: fixed;
    top: 10px;
    left: 10px;
    z-index: 1001;
    background: var(--primary);
    color: white;
    border: none;
    border-radius: 8px;
    padding: 10px 14px;
    font-size: 20px;
    cursor: pointer;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

@media (max-width: 768px) {
    .mobile-menu-btn {
        display: block;
    }
}

/* ============================================
   Print Styles
   ============================================ */
@media print {
    .sidebar {
        display: none !important;
    }

    .main-content {
        margin-left: 0 !important;
    }

    .content-header {
        padding: 10px 0 !important;
        border-bottom: 2px solid #ccc !important;
    }

    .no-print {
        display: none !important;
    }

    body {
        background: white !important;
        color: black !important;
        padding: 0 !important;
        margin: 0 !important;
    }

    /* Hide pagination and search */
    .pagination,
    .search-box {
        display: none !important;
    }

    /* Modal Print Overrides */
    .modal-overlay.active {
        position: absolute !important;
        background: none !important;
        display: block !important;
        height: auto !important;
    }

    .modal-content {
        box-shadow: none !important;
        width: 100% !important;
        max-width: 100% !important;
        max-height: none !important;
        border: none !important;
        padding: 0 !important;
        overflow: visible !important;
        background: transparent !important;
    }

    /* Tab hiding for print detail */
    .modal-tabs {
        display: none !important;
    }

    .modal-tab-content {
        display: block !important;
    }

    /* In print, maybe show all content, but we usually want only active tab, actually active tab is already active */
    .modal-tab-content:not(.active) {
        display: none !important;
    }

    /* Ensure hidden tabs stay hidden */

    .data-table th,
    .data-table td {
        border-bottom: 1px solid #ccc !important;
        color: black !important;
    }

    .status-badge {
        border: 1px solid #ccc !important;
        background: transparent !important;
        color: black !important;
    }
}