/* ===== CSS Variables & Reset ===== */
:root {
    /* LINE Colors */
    --line-green: #00B900;
    --line-green-dark: #009900;
    --line-bg: #7FCCB8;
    --line-chat-bg: #8BC8D6;
    
    /* Admin Colors */
    --admin-primary: #6366F1;
    --admin-primary-dark: #4F46E5;
    --admin-sidebar: #1E1E2D;
    --admin-sidebar-hover: #2D2D3A;
    --admin-bg: #F4F6F9;
    
    /* Status Colors */
    --status-pending: #F59E0B;
    --status-quoted: #3B82F6;
    --status-completed: #10B981;
    --status-closed: #6B7280;
    
    /* General */
    --text-primary: #1F2937;
    --text-secondary: #6B7280;
    --border-color: #E5E7EB;
    --white: #FFFFFF;
    --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
}

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

body {
    font-family: 'Noto Sans JP', -apple-system, BlinkMacSystemFont, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    color: var(--text-primary);
}

/* ===== Main Layout ===== */
.app-container {
    display: flex;
    min-height: 100vh;
    gap: 20px;
    padding: 20px;
}

/* ===== LINE Simulator ===== */
.line-simulator {
    flex: 0 0 380px;
    display: flex;
    justify-content: center;
    align-items: flex-start;
    padding-top: 20px;
}

.phone-frame {
    width: 375px;
    height: 812px;
    background: #1a1a1a;
    border-radius: 50px;
    padding: 15px;
    box-shadow: 
        0 0 0 3px #333,
        0 0 0 6px #1a1a1a,
        0 25px 50px rgba(0, 0, 0, 0.5);
    position: relative;
}

.phone-notch {
    position: absolute;
    top: 15px;
    left: 50%;
    transform: translateX(-50%);
    width: 150px;
    height: 30px;
    background: #1a1a1a;
    border-radius: 0 0 20px 20px;
    z-index: 10;
}

.phone-screen {
    width: 100%;
    height: 100%;
    background: var(--line-chat-bg);
    border-radius: 40px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

/* LINE Header */
.line-header {
    background: var(--white);
    padding: 50px 15px 15px;
    display: flex;
    align-items: center;
    gap: 10px;
    border-bottom: 1px solid var(--border-color);
}

.back-btn, .action-btn {
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 5px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.account-info {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 10px;
}

.account-avatar img {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    object-fit: cover;
}

.account-name {
    font-weight: 600;
    font-size: 16px;
}

/* Chat Container */
.chat-container {
    flex: 1;
    overflow-y: auto;
    padding: 15px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.message {
    max-width: 80%;
    animation: messageIn 0.3s ease;
}

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

.message.bot {
    align-self: flex-start;
}

.message.user {
    align-self: flex-end;
}

.message-content {
    padding: 10px 15px;
    border-radius: 18px;
    font-size: 14px;
    line-height: 1.5;
    white-space: pre-wrap;
}

.message.bot .message-content {
    background: var(--white);
    border-bottom-left-radius: 5px;
}

.message.user .message-content {
    background: var(--line-green);
    color: var(--white);
    border-bottom-right-radius: 5px;
}

.message-time {
    font-size: 11px;
    color: var(--text-secondary);
    margin-top: 3px;
}

.message.bot .message-time {
    text-align: left;
}

.message.user .message-time {
    text-align: right;
}

/* Image Message */
.message-image {
    max-width: 200px;
    border-radius: 12px;
    overflow: hidden;
}

.message-image img {
    width: 100%;
    height: auto;
    display: block;
}

/* Flex Message (Card) */
.flex-message {
    background: var(--white);
    border-radius: 12px;
    overflow: hidden;
    box-shadow: var(--shadow);
}

.flex-header {
    background: linear-gradient(135deg, var(--line-green) 0%, var(--line-green-dark) 100%);
    color: var(--white);
    padding: 15px;
    text-align: center;
}

.flex-header h3 {
    font-size: 16px;
    margin-bottom: 5px;
}

.flex-header .case-id {
    font-size: 12px;
    opacity: 0.9;
}

.flex-body {
    padding: 15px;
}

.flex-row {
    display: flex;
    justify-content: space-between;
    padding: 8px 0;
    border-bottom: 1px solid var(--border-color);
    font-size: 13px;
}

.flex-row:last-child {
    border-bottom: none;
}

.flex-row .label {
    color: var(--text-secondary);
}

.flex-row .value {
    font-weight: 500;
}

.flex-footer {
    padding: 15px;
    display: flex;
    gap: 10px;
}

.flex-btn {
    flex: 1;
    padding: 12px;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

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

.flex-btn.primary:hover {
    background: var(--line-green-dark);
}

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

.flex-btn.secondary:hover {
    background: #d1d5db;
}

/* Quick Reply */
.quick-reply-container {
    padding: 10px 15px;
    display: flex;
    gap: 8px;
    overflow-x: auto;
    background: rgba(255, 255, 255, 0.9);
    display: none;
}

.quick-reply-container.active {
    display: flex;
}

.quick-reply-btn {
    flex-shrink: 0;
    padding: 10px 18px;
    background: var(--white);
    border: 1.5px solid var(--line-green);
    border-radius: 20px;
    color: var(--line-green);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
}

.quick-reply-btn:hover {
    background: var(--line-green);
    color: var(--white);
}

/* Rich Menu */
.rich-menu {
    background: var(--white);
    border-top: 1px solid var(--border-color);
}

.rich-menu-toggle {
    display: flex;
    justify-content: center;
    padding: 10px;
    cursor: pointer;
    color: var(--text-secondary);
    transition: color 0.2s;
}

.rich-menu-toggle:hover {
    color: var(--line-green);
}

.rich-menu-content {
    display: none;
    grid-template-columns: repeat(2, 1fr);
    gap: 1px;
    background: var(--border-color);
    padding: 1px;
}

.rich-menu-content.active {
    display: grid;
}

.rich-menu-item {
    background: var(--white);
    padding: 20px;
    text-align: center;
    cursor: pointer;
    transition: background 0.2s;
}

.rich-menu-item:hover {
    background: #f9fafb;
}

.menu-icon {
    font-size: 28px;
    margin-bottom: 8px;
}

.rich-menu-item span {
    font-size: 12px;
    color: var(--text-primary);
    font-weight: 500;
}

/* Input Area */
.input-area {
    background: var(--white);
    padding: 10px 15px;
    display: flex;
    align-items: center;
    gap: 10px;
    border-top: 1px solid var(--border-color);
}

.attach-btn, .send-btn {
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: all 0.2s;
}

.attach-btn:hover {
    background: #f3f4f6;
    color: var(--text-primary);
}

.send-btn {
    color: var(--line-green);
}

.send-btn:hover {
    background: var(--line-green);
    color: var(--white);
}

.message-input {
    flex: 1;
    padding: 10px 15px;
    border: 1px solid var(--border-color);
    border-radius: 20px;
    font-size: 14px;
    outline: none;
    transition: border-color 0.2s;
}

.message-input:focus {
    border-color: var(--line-green);
}

/* ===== Admin Panel ===== */
.admin-panel {
    flex: 1;
    display: flex;
    background: var(--admin-bg);
    border-radius: 20px;
    overflow: hidden;
    box-shadow: var(--shadow-lg);
}

/* Sidebar */
.admin-sidebar {
    width: 260px;
    background: var(--admin-sidebar);
    color: var(--white);
    display: flex;
    flex-direction: column;
    padding: 20px 0;
}

.admin-logo {
    padding: 10px 25px 30px;
    display: flex;
    align-items: center;
    gap: 12px;
}

.logo-icon {
    font-size: 32px;
}

.logo-text {
    font-size: 18px;
    font-weight: 700;
}

.admin-nav {
    flex: 1;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 15px 25px;
    color: rgba(255, 255, 255, 0.7);
    text-decoration: none;
    font-size: 14px;
    transition: all 0.2s;
    border-left: 3px solid transparent;
}

.nav-item:hover {
    background: var(--admin-sidebar-hover);
    color: var(--white);
}

.nav-item.active {
    background: var(--admin-sidebar-hover);
    color: var(--white);
    border-left-color: var(--admin-primary);
}

.admin-user {
    padding: 20px 25px;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    display: flex;
    align-items: center;
    gap: 12px;
}

.user-avatar {
    width: 40px;
    height: 40px;
    background: var(--admin-primary);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 14px;
}

.user-info {
    display: flex;
    flex-direction: column;
}

.user-name {
    font-size: 14px;
    font-weight: 500;
}

.user-role {
    font-size: 12px;
    color: rgba(255, 255, 255, 0.6);
}

/* Admin Content */
.admin-content {
    flex: 1;
    padding: 30px;
    overflow-y: auto;
}

.admin-section {
    display: none;
}

.admin-section.active {
    display: block;
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 25px;
}

.section-header h1 {
    font-size: 24px;
    font-weight: 700;
}

.current-date {
    color: var(--text-secondary);
    font-size: 14px;
}

/* Stats Grid */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 20px;
    margin-bottom: 30px;
}

.stat-card {
    background: var(--white);
    border-radius: 16px;
    padding: 25px;
    display: flex;
    align-items: center;
    gap: 20px;
    box-shadow: var(--shadow);
    transition: transform 0.2s;
}

.stat-card:hover {
    transform: translateY(-2px);
}

.stat-icon {
    width: 60px;
    height: 60px;
    border-radius: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 28px;
}

.stat-icon.pending { background: rgba(245, 158, 11, 0.15); }
.stat-icon.completed { background: rgba(16, 185, 129, 0.15); }
.stat-icon.appointments { background: rgba(59, 130, 246, 0.15); }
.stat-icon.revenue { background: rgba(99, 102, 241, 0.15); }

.stat-info {
    display: flex;
    flex-direction: column;
}

.stat-value {
    font-size: 28px;
    font-weight: 700;
    color: var(--text-primary);
}

.stat-label {
    font-size: 13px;
    color: var(--text-secondary);
}

/* Cases List */
.recent-cases h2 {
    font-size: 18px;
    margin-bottom: 15px;
}

.cases-list {
    background: var(--white);
    border-radius: 16px;
    overflow: hidden;
    box-shadow: var(--shadow);
}

.case-item {
    display: flex;
    align-items: center;
    gap: 15px;
    padding: 15px 20px;
    border-bottom: 1px solid var(--border-color);
    transition: background 0.2s;
    cursor: pointer;
}

.case-item:last-child {
    border-bottom: none;
}

.case-item:hover {
    background: #f9fafb;
}

.case-thumb {
    width: 50px;
    height: 50px;
    border-radius: 8px;
    object-fit: cover;
}

.case-info {
    flex: 1;
}

.case-title {
    font-weight: 600;
    font-size: 14px;
    margin-bottom: 3px;
}

.case-meta {
    font-size: 12px;
    color: var(--text-secondary);
}

.case-status {
    padding: 5px 12px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 500;
}

.case-status.pending {
    background: rgba(245, 158, 11, 0.15);
    color: #D97706;
}

.case-status.quoted {
    background: rgba(59, 130, 246, 0.15);
    color: #2563EB;
}

.case-status.completed {
    background: rgba(16, 185, 129, 0.15);
    color: #059669;
}

.case-status.closed {
    background: rgba(107, 114, 128, 0.15);
    color: #4B5563;
}

/* Cases Table */
.filter-controls {
    display: flex;
    gap: 15px;
}

.filter-select, .search-input {
    padding: 10px 15px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    font-size: 14px;
    outline: none;
}

.filter-select:focus, .search-input:focus {
    border-color: var(--admin-primary);
}

.search-input {
    width: 250px;
}

.cases-table {
    background: var(--white);
    border-radius: 16px;
    overflow: hidden;
    box-shadow: var(--shadow);
}

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

th, td {
    padding: 15px;
    text-align: left;
    font-size: 14px;
}

th {
    background: #f9fafb;
    font-weight: 600;
    color: var(--text-secondary);
    border-bottom: 1px solid var(--border-color);
}

td {
    border-bottom: 1px solid var(--border-color);
}

tr:last-child td {
    border-bottom: none;
}

tr:hover td {
    background: #f9fafb;
}

.table-thumb {
    width: 40px;
    height: 40px;
    border-radius: 6px;
    object-fit: cover;
}

.btn-action {
    padding: 8px 16px;
    background: var(--admin-primary);
    color: var(--white);
    border: none;
    border-radius: 6px;
    font-size: 13px;
    cursor: pointer;
    transition: background 0.2s;
}

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

/* Modal */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.modal.active {
    display: flex;
}

.modal-content {
    background: var(--white);
    border-radius: 20px;
    width: 90%;
    max-width: 800px;
    max-height: 90vh;
    overflow-y: auto;
    animation: modalIn 0.3s ease;
}

@keyframes modalIn {
    from {
        opacity: 0;
        transform: scale(0.9);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

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

.modal-header h2 {
    font-size: 20px;
}

.modal-close {
    background: none;
    border: none;
    font-size: 28px;
    color: var(--text-secondary);
    cursor: pointer;
    line-height: 1;
}

.modal-close:hover {
    color: var(--text-primary);
}

.modal-body {
    padding: 25px;
}

.case-detail-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 30px;
    margin-bottom: 30px;
}

.case-images img {
    width: 100%;
    border-radius: 12px;
}

.info-group {
    margin-bottom: 15px;
}

.info-group label {
    display: block;
    font-size: 12px;
    color: var(--text-secondary);
    margin-bottom: 5px;
}

.info-group span {
    font-size: 15px;
    font-weight: 500;
}

.quote-section {
    background: #f9fafb;
    border-radius: 12px;
    padding: 25px;
}

.quote-section h3 {
    font-size: 16px;
    margin-bottom: 20px;
}

.quote-form {
    display: grid;
    gap: 15px;
}

.form-group label {
    display: block;
    font-size: 13px;
    margin-bottom: 8px;
    color: var(--text-secondary);
}

.form-group input,
.form-group textarea {
    width: 100%;
    padding: 12px 15px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    font-size: 14px;
    outline: none;
}

.form-group input:focus,
.form-group textarea:focus {
    border-color: var(--admin-primary);
}

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

.btn-primary {
    padding: 12px 24px;
    background: var(--admin-primary);
    color: var(--white);
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.2s;
}

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

/* Appointments */
.appointments-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 20px;
}

.appointment-card {
    background: var(--white);
    border-radius: 16px;
    padding: 25px;
    box-shadow: var(--shadow);
}

.appointment-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 15px;
}

.appointment-date {
    font-size: 13px;
    color: var(--text-secondary);
}

.appointment-time {
    font-size: 24px;
    font-weight: 700;
    color: var(--admin-primary);
}

.appointment-status {
    padding: 5px 12px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 500;
    background: rgba(16, 185, 129, 0.15);
    color: #059669;
}

.appointment-status.pending {
    background: rgba(245, 158, 11, 0.15);
    color: #D97706;
}

.appointment-customer {
    margin-bottom: 15px;
}

.customer-name {
    font-weight: 600;
    font-size: 15px;
    margin-bottom: 3px;
}

.customer-phone {
    font-size: 13px;
    color: var(--text-secondary);
}

.appointment-case {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    background: #f9fafb;
    border-radius: 8px;
}

.appointment-case img {
    width: 45px;
    height: 45px;
    border-radius: 6px;
    object-fit: cover;
}

.case-brief {
    font-size: 13px;
}

.case-brief .brand {
    font-weight: 600;
}

.case-brief .model {
    color: var(--text-secondary);
}

/* Settings */
.settings-content {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(400px, 1fr));
    gap: 25px;
}

.settings-card {
    background: var(--white);
    border-radius: 16px;
    padding: 25px;
    box-shadow: var(--shadow);
}

.settings-card h3 {
    font-size: 16px;
    margin-bottom: 20px;
    padding-bottom: 15px;
    border-bottom: 1px solid var(--border-color);
}

.settings-card .form-group {
    margin-bottom: 20px;
}

.settings-card textarea {
    min-height: 100px;
}

.business-hours {
    margin-bottom: 20px;
}

.hour-row {
    display: flex;
    align-items: center;
    gap: 15px;
    margin-bottom: 12px;
    font-size: 14px;
}

.hour-row span {
    width: 150px;
}

.hour-row input {
    padding: 8px 12px;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    outline: none;
}

/* Typing Indicator */
.typing-indicator {
    display: flex;
    gap: 4px;
    padding: 10px 15px;
    background: var(--white);
    border-radius: 18px;
    border-bottom-left-radius: 5px;
    width: fit-content;
}

.typing-indicator span {
    width: 8px;
    height: 8px;
    background: #9ca3af;
    border-radius: 50%;
    animation: typing 1.4s infinite;
}

.typing-indicator span:nth-child(2) {
    animation-delay: 0.2s;
}

.typing-indicator span:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes typing {
    0%, 100% {
        transform: translateY(0);
        opacity: 0.5;
    }
    50% {
        transform: translateY(-5px);
        opacity: 1;
    }
}

/* Toast Notification */
.toast {
    position: fixed;
    bottom: 30px;
    right: 30px;
    background: #1F2937;
    color: var(--white);
    padding: 15px 25px;
    border-radius: 12px;
    box-shadow: var(--shadow-lg);
    display: flex;
    align-items: center;
    gap: 12px;
    z-index: 2000;
    animation: toastIn 0.3s ease;
}

@keyframes toastIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.toast.success {
    background: var(--status-completed);
}

.toast.error {
    background: #EF4444;
}

/* Scrollbar */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: #d1d5db;
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: #9ca3af;
}

/* Responsive */
@media (max-width: 1400px) {
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 1200px) {
    .app-container {
        flex-direction: column;
    }
    
    .line-simulator {
        flex: none;
    }
    
    .admin-panel {
        border-radius: 20px;
    }
}

@media (max-width: 768px) {
    .admin-sidebar {
        width: 80px;
    }
    
    .admin-logo .logo-text,
    .nav-item span,
    .user-info {
        display: none;
    }
    
    .nav-item {
        justify-content: center;
        padding: 15px;
    }
    
    .admin-user {
        justify-content: center;
    }
    
    .case-detail-grid {
        grid-template-columns: 1fr;
    }
}
