/* ==========================================
   Design System & Global Rules (Simple & Flat)
   ========================================== */
:root {
    /* Color Palette */
    --bg-app: #121216;
    --bg-card: #1e1e24;
    --border-color: #2e2e38;
    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    
    /* Accents (Simple Flat Colors) */
    --accent-color: #f97316; /* Clean Orange */
    --accent-hover: #ea580c;
    --accent-light: rgba(249, 115, 22, 0.1);
    
    /* Status Colors */
    --color-success: #10b981;
    --color-failed: #ef4444;
    --color-pending: #f59e0b;

    /* Fonts & Radii */
    --font-main: 'Noto Sans JP', sans-serif;
    --font-outfit: 'Outfit', sans-serif;
    --radius-md: 8px;
    --radius-sm: 4px;
    --transition-fast: all 0.2s ease;
}

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

body {
    background-color: var(--bg-app);
    color: var(--text-primary);
    font-family: var(--font-main);
    min-height: 100vh;
    line-height: 1.6;
    padding-bottom: 2rem;
}

code {
    background: rgba(0, 0, 0, 0.3);
    padding: 2px 4px;
    border-radius: var(--radius-sm);
    color: #38bdf8;
    font-family: monospace;
}

/* ==========================================
   Login Screen Styles
   ========================================== */
.login-container {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    padding: 1.5rem;
}

.login-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 2.5rem;
    width: 100%;
    max-width: 400px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.25);
    text-align: center;
}

.login-subtitle {
    color: var(--text-secondary);
    font-size: 0.95rem;
    margin-bottom: 2rem;
}

input[type="password"] {
    width: 100%;
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 0.8rem 1rem;
    color: var(--text-primary);
    font-family: var(--font-main);
    font-size: 0.95rem;
    transition: var(--transition-fast);
    outline: none;
}

input[type="password"]:focus {
    border-color: var(--accent-color);
    background: rgba(0, 0, 0, 0.3);
}

/* ==========================================
   Layout Containers
   ========================================== */
.app-container {
    max-width: 1100px;
    margin: 0 auto;
    padding: 2rem 1.5rem;
}

.app-header {
    margin-bottom: 2.5rem;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 1.5rem;
}

.header-main {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.logo {
    font-family: var(--font-outfit);
    font-size: 2.2rem;
    font-weight: 800;
    color: var(--text-primary);
}

.logo-accent {
    color: var(--accent-color);
    font-weight: 900;
}

.subtitle {
    color: var(--text-secondary);
    font-size: 0.95rem;
    margin-top: 0.25rem;
}

.app-main {
    display: grid;
    grid-template-columns: 1.1fr 0.9fr;
    gap: 2rem;
    align-items: start;
}

@media (max-width: 968px) {
    .app-main {
        grid-template-columns: 1fr;
    }
}

/* ==========================================
   Simple Cards
   ========================================== */
.admin-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 2rem;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.section-title {
    font-size: 1.25rem;
    font-weight: 700;
    margin-bottom: 1.5rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--text-primary);
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 0.5rem;
}

.section-title i {
    color: var(--accent-color);
}

/* ==========================================
   Forms & Inputs
   ========================================== */
.form-group {
    margin-bottom: 1.5rem;
    text-align: left;
}

.form-label {
    display: block;
    font-size: 0.9rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
    color: var(--text-primary);
}

.required {
    color: var(--color-failed);
    font-size: 0.8rem;
    margin-left: 0.2rem;
}

input[type="text"],
select {
    width: 100%;
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 0.8rem 1rem;
    color: var(--text-primary);
    font-family: var(--font-main);
    font-size: 0.95rem;
    transition: var(--transition-fast);
    outline: none;
}

input[type="text"]::placeholder {
    color: var(--text-muted);
}

input[type="text"]:focus,
select:focus {
    border-color: var(--accent-color);
    background: rgba(0, 0, 0, 0.3);
}

/* Category Input Group */
.category-input-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

/* Date Input Group */
.date-input-group {
    display: flex;
    gap: 0.5rem;
    position: relative;
    align-items: center;
}

.date-input-group input[type="text"] {
    flex: 1;
}

.date-helper-input {
    width: 42px;
    height: 42px;
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
}

.date-helper-input::-webkit-calendar-picker-indicator {
    background: transparent;
    bottom: 0;
    color: transparent;
    cursor: pointer;
    left: 0;
    position: absolute;
    right: 0;
    top: 0;
    width: auto;
    height: auto;
}

.date-helper-input::before {
    content: "\f073";
    font-family: "Font Awesome 6 Free";
    font-weight: 900;
    color: var(--text-secondary);
    font-size: 1.1rem;
}

.date-helper-input:hover {
    border-color: var(--text-primary);
}

.form-helper-text {
    display: block;
    margin-top: 0.4rem;
    font-size: 0.78rem;
    color: var(--text-secondary);
}

/* ==========================================
   Upload Area (Drag & Drop)
   ========================================== */
.upload-area {
    border: 2px dashed var(--border-color);
    background: rgba(0, 0, 0, 0.1);
    border-radius: var(--radius-md);
    padding: 2rem 1rem;
    text-align: center;
    cursor: pointer;
    position: relative;
    transition: var(--transition-fast);
    min-height: 140px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.upload-area.dragover {
    border-color: var(--accent-color);
    background: var(--accent-light);
}

.upload-icon {
    font-size: 2rem;
    color: var(--text-muted);
    margin-bottom: 0.5rem;
    transition: var(--transition-fast);
}

.upload-area:hover .upload-icon {
    color: var(--accent-color);
}

.upload-text-main {
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--text-primary);
}

.upload-text-sub {
    font-size: 0.78rem;
    color: var(--text-muted);
    margin-top: 0.15rem;
}

.preview-container {
    position: relative;
    width: 100%;
    max-height: 200px;
    display: flex;
    justify-content: center;
    align-items: center;
    border-radius: var(--radius-md);
    overflow: hidden;
}

.preview-container img {
    max-width: 100%;
    max-height: 200px;
    object-fit: contain;
}

.btn-remove-image {
    position: absolute;
    top: 8px;
    right: 8px;
    background: rgba(239, 68, 68, 0.9);
    border: none;
    color: white;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.9rem;
}

.btn-remove-image:hover {
    background: #dc2626;
}

.hidden {
    display: none !important;
}

/* ==========================================
   Buttons & Loaders
   ========================================== */
.btn-submit {
    width: 100%;
    background: var(--accent-color);
    border: none;
    border-radius: var(--radius-md);
    padding: 0.9rem;
    color: white;
    font-family: var(--font-main);
    font-weight: 700;
    font-size: 1rem;
    cursor: pointer;
    transition: var(--transition-fast);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

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

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

.btn-logout {
    background: transparent;
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    padding: 0.5rem 0.8rem;
    border-radius: var(--radius-md);
    font-size: 0.85rem;
    cursor: pointer;
    font-family: var(--font-main);
    transition: var(--transition-fast);
}

.btn-logout:hover {
    border-color: var(--color-failed);
    color: var(--color-failed);
    background: rgba(239, 68, 68, 0.05);
}

/* Spinner Loader */
.loader {
    width: 20px;
    height: 20px;
    border: 2px solid rgba(255, 255, 255, 0.2);
    border-top: 2px solid white;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

/* ==========================================
   History Section (Flat & Clean)
   ========================================== */
.history-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 0.5rem;
}

.history-header .section-title {
    margin-bottom: 0;
    border-bottom: none;
    padding-bottom: 0;
}

.btn-refresh {
    background: transparent;
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    width: 34px;
    height: 34px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition-fast);
}

.btn-refresh:hover {
    color: var(--text-primary);
    border-color: var(--text-secondary);
}

.btn-refresh i {
    transition: transform 0.5s ease;
}

.btn-refresh:active i {
    transform: rotate(180deg);
}

.history-list {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    max-height: 520px;
    overflow-y: auto;
    padding-bottom: 0.5rem;
}

/* Custom scrollbar */
.history-list::-webkit-scrollbar {
    width: 4px;
}

.history-list::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.1);
}

.history-list::-webkit-scrollbar-thumb {
    background: var(--border-color);
}

.history-item {
    display: grid;
    grid-template-columns: 60px 1fr auto;
    gap: 0.75rem;
    align-items: center;
    background: rgba(0, 0, 0, 0.15);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 0.75rem;
    transition: var(--transition-fast);
}

.history-item:hover {
    background: rgba(0, 0, 0, 0.25);
    border-color: var(--text-muted);
}

.history-thumb {
    width: 60px;
    height: 60px;
    border-radius: var(--radius-sm);
    overflow: hidden;
    background: #000;
    display: flex;
    align-items: center;
    justify-content: center;
}

.history-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.history-info {
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
}

.history-item-title {
    font-size: 0.9rem;
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1.3;
}

.history-item-meta {
    font-size: 0.78rem;
    color: var(--text-secondary);
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem 0.75rem;
}

.history-item-meta span i {
    margin-right: 0.25rem;
    color: var(--text-muted);
}

.status-badge {
    font-size: 0.7rem;
    font-weight: 700;
    padding: 0.15rem 0.5rem;
    border-radius: 2px;
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
}

.status-badge.success {
    background: rgba(16, 185, 129, 0.1);
    color: var(--color-success);
    border: 1px solid rgba(16, 185, 129, 0.2);
}

.status-badge.failed {
    background: rgba(239, 68, 68, 0.1);
    color: var(--color-failed);
    border: 1px solid rgba(239, 68, 68, 0.2);
}

.status-badge.pending {
    background: rgba(245, 158, 11, 0.1);
    color: var(--color-pending);
    border: 1px solid rgba(245, 158, 11, 0.2);
}

/* Item Action Controls */
.item-actions {
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.btn-action-control {
    background: transparent;
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    width: 28px;
    height: 28px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8rem;
    cursor: pointer;
    transition: var(--transition-fast);
}

.btn-action-control:hover {
    color: var(--text-primary);
    border-color: var(--text-secondary);
    background: rgba(255, 255, 255, 0.05);
}

.btn-action-control.btn-delete:hover {
    color: var(--color-failed);
    border-color: rgba(239, 68, 68, 0.3);
    background: rgba(239, 68, 68, 0.08);
}

.btn-wp-link {
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 0.8rem;
    width: 28px;
    height: 28px;
    border-radius: var(--radius-sm);
    background: transparent;
    border: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition-fast);
}

.btn-wp-link:hover {
    color: var(--text-primary);
    border-color: var(--text-secondary);
    background: rgba(255, 255, 255, 0.05);
}

/* Save order button layout */
.reorder-action-container {
    margin-top: 1.5rem;
    padding-top: 1.25rem;
    border-top: 1px solid var(--border-color);
}

.btn-save-order {
    background: #0ea5e9; /* Sky Blue for Save Action */
}

.btn-save-order:hover {
    background: #0284c7;
}

.loading-placeholder,
.empty-placeholder {
    text-align: center;
    padding: 2rem 1rem;
    color: var(--text-muted);
    font-size: 0.85rem;
}

/* ==========================================
   Toast Notification System
   ========================================== */
.toast-container {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 1000;
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-width: 340px;
    width: 100%;
}

.toast {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-left: 3px solid var(--text-secondary);
    border-radius: var(--radius-sm);
    padding: 0.8rem 1rem;
    color: var(--text-primary);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    display: flex;
    align-items: start;
    gap: 0.6rem;
    transform: translateX(120%);
    transition: transform 0.25s ease-out;
}

.toast.show {
    transform: translateX(0);
}

.toast-icon {
    font-size: 1rem;
    margin-top: 1px;
}

.toast.success {
    border-left-color: var(--color-success);
}
.toast.success .toast-icon {
    color: var(--color-success);
}

.toast.error {
    border-left-color: var(--color-failed);
}
.toast.error .toast-icon {
    color: var(--color-failed);
}

.toast-content {
    flex: 1;
}

.toast-title {
    font-weight: 700;
    font-size: 0.88rem;
}

.toast-message {
    font-size: 0.8rem;
    color: var(--text-secondary);
    line-height: 1.3;
    margin-top: 0.1rem;
}

/* ==========================================
   Footer & Mobile Responsive System
   ========================================== */
.app-footer {
    text-align: center;
    margin-top: 3rem;
    color: var(--text-muted);
    font-size: 0.8rem;
}

/* ==========================================
   Mobile & Tablet Responsive Enhancements
   ========================================== */
@media (max-width: 768px) {
    body {
        padding-bottom: 1rem;
    }

    .app-container {
        padding: 1rem 0.75rem;
    }

    .app-header {
        margin-bottom: 1.5rem;
        padding-bottom: 1rem;
    }

    .logo {
        font-size: 1.75rem;
    }

    .btn-logout {
        padding: 0.4rem 0.7rem;
        font-size: 0.8rem;
    }

    .admin-card {
        padding: 1.25rem 1rem;
        border-radius: var(--radius-md);
    }

    /* iPhone / iOS サファリでの自動ズーム防止 (16px化) */
    input[type="text"],
    input[type="password"],
    select {
        font-size: 16px !important;
        padding: 0.85rem 0.9rem;
    }

    .upload-area {
        padding: 1.5rem 0.75rem;
        min-height: 150px;
    }

    .upload-icon {
        font-size: 2.2rem;
    }

    .upload-text-main {
        font-size: 1rem;
    }

    /* スマホで押しやすい大きなボタン */
    .btn-submit {
        padding: 1rem;
        font-size: 1.05rem;
        border-radius: var(--radius-md);
    }

    /* 履歴アイテムのモバイル最適化 */
    .history-item {
        grid-template-columns: 55px 1fr;
        grid-template-areas: 
            "thumb info"
            "actions actions";
        gap: 0.75rem;
        padding: 0.85rem;
    }

    .history-thumb {
        grid-area: thumb;
        width: 55px;
        height: 55px;
    }

    .history-info {
        grid-area: info;
    }

    .history-item-title {
        font-size: 0.95rem;
    }

    .item-actions {
        grid-area: actions;
        display: flex;
        justify-content: flex-end;
        gap: 0.6rem;
        padding-top: 0.5rem;
        border-top: 1px solid rgba(255, 255, 255, 0.08);
        width: 100%;
    }

    /* スマホで指タップしやすい大きめボタン (36px) */
    .btn-action-control,
    .btn-wp-link {
        width: 36px;
        height: 36px;
        font-size: 0.95rem;
    }

    /* トースト通知のスマホ対応 */
    .toast-container {
        right: 12px;
        left: 12px;
        bottom: 12px;
        max-width: calc(100% - 24px);
    }
}

