/* Admin Area Stylesheet */

.admin-container {
    max-width: 1200px;
    margin: 40px auto;
    padding: 0 20px;
}

.back-link {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    color: #475569;
    font-size: 0.9rem;
    font-weight: 500;
    text-decoration: none;
    margin-bottom: 20px;
    padding: 8px 14px;
    border-radius: 8px;
    border: 1px solid #e2e8f0;
    background-color: #f8fafc;
    transition: all 0.2s ease;
}

.back-link:hover {
    background-color: #e2e8f0;
    color: var(--dark);
    border-color: #94a3b8;
}

.admin-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
    border-bottom: 2px solid #e2e8f0;
    padding-bottom: 16px;
    gap: 16px;
    flex-wrap: wrap;
}

.admin-title {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

.admin-title h1,
.admin-title h2 {
    font-size: 1.35rem;
    font-weight: 700;
    color: var(--dark);
    margin: 0;
    line-height: 1.3;
}

.admin-title span {
    font-size: 0.78rem;
    background-color: var(--primary);
    color: white;
    padding: 3px 10px;
    border-radius: 20px;
    font-weight: 600;
    letter-spacing: 0.3px;
    display: inline-flex;
    align-items: center;
    white-space: nowrap;
}

.admin-header-actions {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.admin-header-actions .btn {
    height: 38px;
    padding: 0 16px;
    font-size: 0.88rem;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

/* Info & Alerts styling */
.alert {
    padding: 16px 20px;
    border-radius: 8px;
    margin-bottom: 24px;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 12px;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05);
}

.alert-success {
    background-color: #d1fae5;
    color: #065f46;
    border-left: 5px solid #10b981;
}

.alert-danger {
    background-color: #fee2e2;
    color: #991b1b;
    border-left: 5px solid #ef4444;
}

.alert-warning {
    background-color: #fef3c7;
    color: #92400e;
    border-left: 5px solid #f59e0b;
}

/* Tree Grid Layout */
.menu-manager-grid {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 340px;
    gap: 30px;
}

@media (max-width: 992px) {
    .menu-manager-grid {
        grid-template-columns: minmax(0, 1fr);
    }
}

.menu-tree-card {
    background-color: white;
    border-radius: 12px;
    border: 1px solid #e2e8f0;
    padding: 24px;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05);
}

.sidebar-card {
    background-color: white;
    border-radius: 12px;
    border: 1px solid #e2e8f0;
    padding: 24px;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05);
    height: fit-content;
}

.sidebar-card h3 {
    margin-bottom: 16px;
    font-size: 1.1rem;
    font-weight: 600;
    border-bottom: 1px solid #e2e8f0;
    padding-bottom: 10px;
}

.sidebar-card p {
    font-size: 0.9rem;
    color: #475569;
    margin-bottom: 12px;
}

/* Tree Node Styling */
.tree-list {
    list-style: none;
}

.tree-list ul {
    list-style: none;
    padding-left: 32px;
    border-left: 2px dashed #cbd5e1;
    margin-top: 10px;
    margin-bottom: 10px;
}

.tree-node {
    margin-bottom: 12px;
}

.node-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background-color: #f8fafc;
    border-radius: 8px;
    padding: 12px 16px;
    border: 1px solid #e2e8f0;
    transition: all 0.2s ease;
}

.node-row:hover {
    border-color: #94a3b8;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

/* Visual Level Distinction */
.depth-1 > .node-row {
    border-left: 4px solid var(--primary);
    background-color: #ffffff;
}

.depth-2 > .node-row {
    border-left: 4px solid #3b82f6; /* Blue border */
}

.depth-3 > .node-row {
    border-left: 4px solid #8b5cf6; /* Purple border */
}

.node-info {
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-width: 0;
    flex: 1;
    margin-right: 16px;
    overflow: hidden;
}

.node-title {
    font-weight: 600;
    color: var(--dark);
    font-size: 1rem;
    word-break: break-word;
}

.node-url {
    font-size: 0.8rem;
    color: #64748b;
    font-family: var(--font-en);
    white-space: nowrap;
    overflow-x: auto;
    scrollbar-width: thin;
    scrollbar-color: #cbd5e1 transparent;
}

.node-url::-webkit-scrollbar {
    height: 4px;
}

.node-url::-webkit-scrollbar-track {
    background: transparent;
}

.node-url::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 2px;
}

.node-url::-webkit-scrollbar-thumb:hover {
    background: #94a3b8;
}

/* Actions styling */
.node-actions {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-shrink: 0;
}

.btn-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: 6px;
    border: 1px solid #cbd5e1;
    background-color: white;
    cursor: pointer;
    transition: all 0.2s ease;
    color: #475569;
}

.btn-icon:hover {
    background-color: #f1f5f9;
    color: var(--dark);
}

.btn-icon.btn-delete:hover {
    background-color: #fee2e2;
    color: #ef4444;
    border-color: #fca5a5;
}

.btn-icon.btn-add-child:hover {
    background-color: #d1fae5;
    color: #059669;
    border-color: #a7f3d0;
}

/* Modal Popup Dialog */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(15, 23, 42, 0.6);
    backdrop-filter: blur(4px);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1100;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
}

.modal-overlay.active {
    opacity: 1;
    visibility: visible;
}

.modal-card {
    background-color: white;
    border-radius: 12px;
    width: 100%;
    max-width: 480px;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
    transform: scale(0.9);
    transition: all 0.3s ease;
    overflow: hidden;
}

.modal-overlay.active .modal-card {
    transform: scale(1);
}

.modal-header {
    background-color: #f8fafc;
    padding: 16px 24px;
    border-bottom: 1px solid #e2e8f0;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h3 {
    font-size: 1.15rem;
    font-weight: 600;
    color: var(--dark);
}

.modal-close {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 1.5rem;
    color: #64748b;
}

.modal-body {
    padding: 24px;
}

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

.form-group label {
    display: block;
    font-size: 0.9rem;
    font-weight: 500;
    color: #334155;
    margin-bottom: 6px;
}

.form-input {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid #cbd5e1;
    border-radius: 6px;
    font-size: 0.95rem;
    font-family: inherit;
    transition: border-color 0.2s;
}

.form-input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(5, 150, 105, 0.15);
}

.modal-footer {
    padding: 16px 24px;
    background-color: #f8fafc;
    border-top: 1px solid #e2e8f0;
    display: flex;
    justify-content: flex-end;
    gap: 12px;
}

.btn-secondary {
    background-color: #64748b;
}

.btn-secondary:hover {
    background-color: #475569;
}

.btn-sm {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: none;
    border-radius: 6px;
    background-color: var(--primary);
    color: #fff;
    cursor: pointer;
    font-family: inherit;
    font-size: 0.85rem;
    font-weight: 600;
    padding: 8px 12px;
    transition: all 0.2s ease;
}

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

.footer-section-card {
    background-color: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    padding: 18px;
    margin-bottom: 18px;
}

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

.compact-section-header {
    margin-bottom: 10px;
}

.compact-section-header h3 {
    border-bottom: none;
    margin: 0;
    padding: 0;
}

.section-title-group {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
}

.section-title {
    color: var(--dark);
    font-size: 1.05rem;
    font-weight: 700;
    margin: 0;
    overflow-wrap: anywhere;
}

.section-badge {
    border-radius: 999px;
    color: #fff;
    flex: 0 0 auto;
    font-size: 0.75rem;
    font-weight: 700;
    line-height: 1;
    padding: 6px 9px;
}

.badge-links {
    background-color: #2563eb;
}

.badge-contact {
    background-color: #059669;
}

.section-actions {
    display: flex;
    gap: 6px;
    flex: 0 0 auto;
}

.items-list,
.contact-items-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.contact-edit-group {
    margin-bottom: 14px;
}

.contact-edit-group label {
    display: block;
    font-size: 0.9rem;
    font-weight: 600;
    margin-bottom: 6px;
}

.empty-state {
    background-color: #f8fafc;
    border: 1px dashed #cbd5e1;
    border-radius: 8px;
    color: #64748b;
    font-size: 0.9rem;
    padding: 18px;
    text-align: center;
}

.asset-manager-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 18px;
}

@media (max-width: 768px) {
    .asset-manager-grid {
        grid-template-columns: 1fr;
    }
}

.asset-panel {
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    padding: 18px;
}

.asset-panel h3 {
    color: var(--dark);
    font-size: 1.05rem;
    margin-bottom: 12px;
}

.asset-preview {
    align-items: center;
    background-color: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    display: flex;
    height: 150px;
    justify-content: center;
    margin-bottom: 10px;
    padding: 16px;
}

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

.favicon-preview {
    height: 96px;
}

.favicon-preview img {
    max-height: 48px;
    max-width: 48px;
}

.asset-path {
    color: #64748b;
    font-family: var(--font-en);
    font-size: 0.82rem;
    margin-bottom: 12px;
    overflow-wrap: anywhere;
}

.check-row {
    align-items: center;
    color: #475569;
    display: flex;
    gap: 8px;
    font-size: 0.9rem;
    margin-top: 12px;
}

/* ==========================================================================
   Admin Unified Navigation Bar & Tabs
   ========================================================================== */
.admin-nav-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: 14px;
    padding: 8px 12px;
    margin-bottom: 24px;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.04);
    flex-wrap: wrap;
    gap: 10px;
}

.admin-nav-tabs {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
}

.admin-nav-tab {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    height: 38px;
    padding: 0 14px;
    border-radius: 8px;
    color: #475569;
    font-size: 0.9rem;
    font-weight: 500;
    text-decoration: none;
    transition: all 0.2s ease;
    white-space: nowrap;
}

.admin-nav-tab:hover {
    background-color: #f1f5f9;
    color: var(--primary);
}

.admin-nav-tab.active {
    background-color: #059669;
    background: linear-gradient(135deg, #059669 0%, #047857 100%);
    color: #ffffff !important;
    font-weight: 600;
    box-shadow: 0 3px 10px rgba(5, 150, 105, 0.25);
}

.admin-nav-tab.active svg {
    stroke: #ffffff;
}

.admin-nav-tab .badge {
    font-size: 0.68rem;
    padding: 2px 7px;
    border-radius: 10px;
    background-color: #f59e0b;
    color: #ffffff;
    font-weight: 700;
    line-height: 1;
}

.admin-nav-tab.active .badge {
    background-color: #ffffff;
    color: #047857;
}

.admin-nav-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

.admin-nav-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    height: 38px;
    padding: 0 13px;
    border-radius: 8px;
    font-size: 0.88rem;
    text-decoration: none;
    font-weight: 500;
    border: 1px solid #e2e8f0;
    color: #64748b;
    background-color: #f8fafc;
    transition: all 0.2s ease;
    white-space: nowrap;
}

.admin-nav-btn:hover {
    background-color: #e2e8f0;
    color: var(--dark);
}

/* Mobile Icon Preview in Admin */
.icon-preview-box {
    width: 38px;
    height: 38px;
    border-radius: 10px;
    background: #ecfdf5;
    color: var(--primary);
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid #a7f3d0;
    flex-shrink: 0;
}

.icon-preview-box svg {
    width: 20px;
    height: 20px;
    stroke: currentColor;
    stroke-width: 2;
}

.icon-preview-box img {
    max-width: 24px;
    max-height: 24px;
    object-fit: contain;
    display: block;
}

.mobile-tag-badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 2px 8px;
    border-radius: 6px;
    background-color: #e0f2fe;
    color: #0369a1;
    font-size: 0.75rem;
    font-weight: 500;
    margin-left: 8px;
}

/* ==========================================================================
   Admin Mobile Responsive & Clean-up Styles
   ========================================================================== */

/* ซ่อนแถบ Floating Nav และ Drawer ของหน้าบ้าน เมื่ออยู่ในหน้า Admin ทั้งหมด */
.mobile-bottom-nav,
.mobile-drawer,
.mobile-sub-drawer,
.mobile-drawer-overlay {
    display: none !important;
}

body {
    padding-bottom: 0 !important;
}

@media (max-width: 768px) {
    .admin-container {
        margin: 20px auto;
        padding: 0 14px;
    }

    .admin-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 14px;
    }

    .admin-header > div:last-child {
        width: 100%;
        display: flex;
        flex-wrap: wrap;
        gap: 8px;
    }

    .admin-header > div:last-child .btn {
        flex: 1 1 auto;
        justify-content: center;
        text-align: center;
    }

    .admin-title {
        font-size: 1.35rem;
        flex-wrap: wrap;
        gap: 8px;
    }

    .menu-tree-card {
        padding: 16px 12px;
    }

    .tree-list ul {
        padding-left: 14px;
    }

    .node-row {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
        padding: 10px 12px;
    }

    .node-info {
        margin-right: 0;
        width: 100%;
    }

    .node-actions {
        width: 100%;
        justify-content: flex-end;
        padding-top: 8px;
        border-top: 1px dashed #e2e8f0;
    }

    .btn-icon {
        width: 36px;
        height: 36px;
    }

    .modal-card {
        margin: 14px;
        max-height: 90vh;
        display: flex;
        flex-direction: column;
    }

    .modal-body {
        overflow-y: auto;
        max-height: calc(85vh - 120px);
    }
}


