/* ==========================================================================
   DGA Dashboard - Main Layout CSS
   ========================================================================== */

/* --------------------------------------------------------------------------
   1. Base / Wrapper
   -------------------------------------------------------------------------- */
*,
*::before,
*::after {
    box-sizing: border-box;
}

.dga-dashboard-wrapper {
    width: 100%;
    min-height: 100vh;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
        Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
    font-size: 14px;
    line-height: 1.5;
    color: #3c434a;
    background: #f0f0f1;
}

/* --------------------------------------------------------------------------
   2. Sidebar Header & Footer (user info + logout inside sidebar)
   -------------------------------------------------------------------------- */
.dga-dashboard-wrapper .dga-sidebar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.dga-dashboard-wrapper .dga-sidebar-user {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
}

.dga-dashboard-wrapper .dga-sidebar-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid #50575e;
    flex-shrink: 0;
}

.dga-dashboard-wrapper .dga-sidebar-username {
    color: #eee;
    font-size: 14px;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.dga-dashboard-wrapper .dga-sidebar-close {
    display: none;
    background: none;
    border: none;
    color: #aaa;
    font-size: 20px;
    cursor: pointer;
    padding: 2px;
    line-height: 1;
    flex-shrink: 0;
}

.dga-dashboard-wrapper .dga-sidebar-close:hover {
    color: #fff;
}

/* Profile button in sidebar header */
.dga-dashboard-wrapper .dga-sidebar-profile-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.15);
    color: #ccc;
    padding: 5px 8px;
    border-radius: 4px;
    cursor: pointer;
    transition: background 0.2s ease, color 0.2s ease;
    flex-shrink: 0;
    margin-left: auto;
    line-height: 1;
}

.dga-dashboard-wrapper .dga-sidebar-profile-btn:hover,
.dga-dashboard-wrapper .dga-sidebar-profile-btn.active {
    background: rgba(255, 255, 255, 0.2);
    color: #fff;
}

.dga-dashboard-wrapper .dga-sidebar-profile-btn .dashicons {
    font-size: 18px;
    width: 18px;
    height: 18px;
    line-height: 18px;
}

/* --------------------------------------------------------------------------
   Profile Popover
   -------------------------------------------------------------------------- */
.dga-profile-popover {
    position: fixed;
    top: 10px;
    left: 270px;
    width: 420px;
    max-height: calc(100vh - 20px);
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 8px 40px rgba(0, 0, 0, 0.2);
    z-index: 100;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    opacity: 0;
    visibility: hidden;
    transform: translateX(-20px) scale(0.97);
    transition: opacity 0.25s ease, visibility 0.25s ease, transform 0.25s ease;
}

.dga-profile-popover.open {
    opacity: 1;
    visibility: visible;
    transform: translateX(0) scale(1);
}

.dga-profile-popover-arrow {
    position: absolute;
    top: 22px;
    left: -8px;
    width: 16px;
    height: 16px;
    background: #fff;
    transform: rotate(45deg);
    box-shadow: -2px 2px 4px rgba(0, 0, 0, 0.08);
    z-index: -1;
}

.dga-profile-popover-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 20px;
    border-bottom: 1px solid #e2e8f0;
    flex-shrink: 0;
}

.dga-profile-popover-header h3 {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
    color: #1d2327;
}

.dga-profile-popover-close {
    background: none;
    border: none;
    color: #646970;
    cursor: pointer;
    padding: 4px;
    border-radius: 4px;
    line-height: 1;
    transition: background 0.2s ease, color 0.2s ease;
}

.dga-profile-popover-close:hover {
    background: #f0f0f1;
    color: #1d2327;
}

.dga-profile-popover-close .dashicons {
    font-size: 20px;
    width: 20px;
    height: 20px;
    line-height: 20px;
}

.dga-profile-popover-body {
    overflow-y: auto;
    flex: 1;
    max-height: calc(100vh - 80px);
}

/* Profile popover backdrop */
.dga-profile-popover-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.15);
    z-index: 99;
    display: none;
}

.dga-profile-popover-backdrop.active {
    display: block;
}

.dga-dashboard-wrapper .dga-sidebar-footer {
    margin-top: auto;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    padding: 0;
}

.dga-dashboard-wrapper .dga-sidebar-logout {
    display: flex !important;
    align-items: center;
    gap: 10px;
    padding: 13px 20px !important;
    color: #e0e0e0 !important;
    text-decoration: none !important;
    font-size: 14px;
    transition: background 0.2s ease, color 0.2s ease;
}

.dga-dashboard-wrapper .dga-sidebar-logout:hover,
.dga-dashboard-wrapper .dga-sidebar-logout:focus {
    background: rgba(220, 50, 50, 0.15) !important;
    color: #ff6b6b !important;
    text-decoration: none !important;
}

.dga-dashboard-wrapper .dga-sidebar-logout .dashicons {
    font-size: 20px;
    width: 20px;
    height: 20px;
    line-height: 20px;
    color: inherit !important;
}

/* Mobile sidebar toggle button */
.dga-dashboard-wrapper .dga-sidebar-toggle {
    display: none;
    position: fixed;
    top: 12px;
    left: 12px;
    z-index: 95;
    background: #1d2327;
    color: #fff;
    border: none;
    border-radius: 6px;
    width: 40px;
    height: 40px;
    cursor: pointer;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
    font-size: 20px;
    line-height: 1;
}

.dga-dashboard-wrapper .dga-sidebar-toggle:hover {
    background: #2c3338;
}

/* --------------------------------------------------------------------------
   3. Body (below header)
   -------------------------------------------------------------------------- */
.dga-dashboard-body {
    display: flex;
    padding-top: 0;
}

/* --------------------------------------------------------------------------
   4. Sidebar
   -------------------------------------------------------------------------- */
.dga-dashboard-wrapper .dga-dashboard-sidebar {
    width: 260px;
    background: #1d2327 !important;
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    overflow-y: auto;
    transition: transform 0.3s ease;
    z-index: 90;
    border-right: 1px solid #101517;
    display: flex;
    flex-direction: column;
}

.dga-dashboard-wrapper .dga-sidebar-menu {
    list-style: none !important;
    padding: 0 !important;
    margin: 0 !important;
    flex: 1;
    overflow-y: auto;
}

.dga-dashboard-wrapper .dga-sidebar-item {
    border-bottom: 1px solid rgba(255, 255, 255, 0.07);
    list-style: none !important;
    margin: 0 !important;
    padding: 0 !important;
}

.dga-dashboard-wrapper .dga-sidebar-link {
    display: flex !important;
    align-items: center;
    padding: 13px 20px !important;
    color: #eee !important;
    text-decoration: none !important;
    transition: background 0.2s ease, color 0.2s ease, border-left-color 0.2s ease;
    font-size: 14px;
    font-weight: 400;
    line-height: 1.4;
    border-left: 3px solid transparent;
    background: transparent !important;
}

.dga-dashboard-wrapper .dga-sidebar-link:hover,
.dga-dashboard-wrapper .dga-sidebar-link:focus {
    background: rgba(255, 255, 255, 0.08) !important;
    color: #fff !important;
    text-decoration: none !important;
    border-left-color: rgba(255, 255, 255, 0.3);
}

.dga-dashboard-wrapper .dga-sidebar-item.active .dga-sidebar-link {
    background: #0073aa !important;
    color: #fff !important;
    border-left-color: #fff;
    font-weight: 500;
}

.dga-dashboard-wrapper .dga-sidebar-link .dashicons {
    font-size: 20px;
    width: 20px;
    height: 20px;
    line-height: 20px;
    flex-shrink: 0;
    color: inherit !important;
    opacity: 0.85;
}

.dga-dashboard-wrapper .dga-sidebar-item.active .dga-sidebar-link .dashicons {
    opacity: 1;
}

.dga-dashboard-wrapper .dga-sidebar-label {
    margin-left: 12px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Sidebar overlay (mobile) */
.dga-dashboard-wrapper .dga-sidebar-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 85;
    display: none;
}

.dga-dashboard-wrapper .dga-sidebar-overlay.active {
    display: block;
}

/* --------------------------------------------------------------------------
   5. Content Area
   -------------------------------------------------------------------------- */
.dga-dashboard-content {
    margin-left: 260px;
    padding: 30px;
    min-height: 100vh;
    background: #f0f0f1;
    transition: margin-left 0.3s ease;
    width: 100%;
}

.dga-module-panel {
    background: #fff;
    border-radius: 8px;
    padding: 30px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

.dga-module-panel h2 {
    margin-top: 0;
    margin-bottom: 20px;
    font-size: 22px;
    color: #1d2327;
}

/* --------------------------------------------------------------------------
   6. Login Required
   -------------------------------------------------------------------------- */
.dga-dashboard-login-required {
    text-align: center;
    padding: 60px;
    background: #fff;
    border-radius: 8px;
    max-width: 480px;
    margin: 60px auto;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

.dga-dashboard-login-required h2 {
    margin-bottom: 12px;
    color: #1d2327;
}

.dga-dashboard-login-required p {
    color: #646970;
    margin-bottom: 24px;
}

/* Shared button system */
.dga-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    border: none;
    border-radius: 6px;
    font-weight: 600;
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
    text-decoration: none;
}

.dga-btn .dashicons {
    font-size: 16px;
    width: 16px;
    height: 16px;
}

.dga-btn-primary {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: #2563eb;
    color: #fff;
    padding: 8px 16px;
    border: none;
    border-radius: 6px;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    transition: all 0.2s;
}

.dga-btn-primary:hover,
.dga-btn-primary:focus {
    background: #1e40af;
    color: #fff;
    text-decoration: none;
}

.dga-btn-danger {
    background: #ef4444;
    color: #fff;
}

.dga-btn-danger:hover:not(:disabled) {
    background: #dc2626;
}

.dga-btn-outline {
    background: #fff;
    color: #374151;
    border: 1px solid #d1d5db;
}

.dga-btn-outline:hover:not(:disabled) {
    background: #f3f4f6;
    border-color: #9ca3af;
}

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

/* Small icon buttons (table actions) */
.dga-btn-sm {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    padding: 0;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s;
}

.dga-btn-sm .dashicons {
    font-size: 16px;
    width: 16px;
    height: 16px;
}

.dga-btn-sm.dga-btn-primary {
    background: #2563eb;
    color: #fff;
    padding: 0;
}

.dga-btn-sm.dga-btn-primary:hover { background: #1e40af; }

.dga-btn-sm.dga-btn-info {
    background: #06b6d4;
    color: #fff;
}

.dga-btn-sm.dga-btn-info:hover { background: #0891b2; }

.dga-btn-sm.dga-btn-outline {
    background: #fff;
    color: #374151;
    border: 1px solid #d1d5db;
}

.dga-btn-sm.dga-btn-outline:hover { background: #f3f4f6; }

.dga-btn-sm.dga-btn-danger {
    background: #fff;
    color: #ef4444;
    border: 1px solid #fca5a5;
}

.dga-btn-sm.dga-btn-danger:hover {
    background: #ef4444;
    color: #fff;
}

/* Shared badge system */
.dga-badge {
    display: inline-block;
    padding: 2px 10px;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 600;
}

/* --------------------------------------------------------------------------
   7. Tabs (shared utility)
   -------------------------------------------------------------------------- */
.dga-tabs {
    display: flex;
    border-bottom: 2px solid #e0e0e0;
    margin-bottom: 20px;
    gap: 0;
}

.dga-tab {
    padding: 10px 20px;
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    color: #646970;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: color 0.2s ease, border-color 0.2s ease;
    white-space: nowrap;
}

.dga-tab:hover {
    color: #0073aa;
}

.dga-tab.active {
    color: #0073aa;
    border-bottom-color: #0073aa;
    font-weight: 600;
}

.dga-tab-content {
    display: none;
}

.dga-tab-content.active {
    display: block;
}

/* --------------------------------------------------------------------------
   8. Modal (shared utility — used by posts, token, logo modules)
   Uses display:none + jQuery fadeIn()/fadeOut()
   -------------------------------------------------------------------------- */
.dga-modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
    z-index: 100000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.dga-modal-dialog {
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
    width: 100%;
    max-width: 560px;
    max-height: 90vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.dga-modal-sm {
    max-width: 440px;
}

.dga-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    border-bottom: 1px solid #e5e7eb;
}

.dga-modal-header h3 {
    margin: 0;
    font-size: 1.15rem;
    font-weight: 700;
    color: #111827;
}

.dga-modal-close {
    background: transparent;
    border: none;
    color: #6b7280;
    cursor: pointer;
    padding: 4px;
    border-radius: 4px;
    transition: all 0.2s;
}

.dga-modal-close:hover {
    background: #fee2e2;
    color: #ef4444;
}

.dga-modal-body {
    padding: 20px;
    overflow-y: auto;
    flex: 1;
}

.dga-modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    padding: 16px 20px;
    border-top: 1px solid #e5e7eb;
    background: #f9fafb;
}

/* --------------------------------------------------------------------------
   8b. Form Groups (shared utility)
   -------------------------------------------------------------------------- */
.dga-form-group {
    margin-bottom: 16px;
}

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

.dga-form-group label .required {
    color: #ef4444;
}

.dga-form-group input[type="text"],
.dga-form-group textarea,
.dga-form-group select {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    font-size: 0.95rem;
    transition: border-color 0.2s;
    box-sizing: border-box;
}

.dga-form-group input:focus,
.dga-form-group textarea:focus,
.dga-form-group select:focus {
    outline: none;
    border-color: #2563eb;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.dga-form-group input[readonly] {
    background: #f3f4f6;
    color: #6b7280;
}

.dga-form-group small {
    display: block;
    margin-top: 4px;
    color: #9ca3af;
    font-size: 0.8rem;
}

/* --------------------------------------------------------------------------
   9. Toast Notifications
   -------------------------------------------------------------------------- */
.dga-toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 300;
    display: flex;
    flex-direction: column;
    gap: 10px;
    pointer-events: none;
}

.dga-toast {
    background: #1d2327;
    color: #fff;
    padding: 12px 20px;
    border-radius: 6px;
    font-size: 14px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
    pointer-events: auto;
    display: flex;
    align-items: center;
    gap: 10px;
    animation: dga-toast-in 0.3s ease forwards;
    max-width: 400px;
}

.dga-toast.success {
    border-left: 4px solid #00a32a;
}

.dga-toast.error {
    border-left: 4px solid #d63638;
}

.dga-toast.warning {
    border-left: 4px solid #dba617;
}

.dga-toast.info {
    border-left: 4px solid #0073aa;
}

.dga-toast.fade-out {
    animation: dga-toast-out 0.3s ease forwards;
}

/* Toast aliases (for posts module naming convention) */
.dga-toast.dga-toast-success {
    border-left: 4px solid #00a32a;
}

.dga-toast.dga-toast-error {
    border-left: 4px solid #d63638;
}

.dga-toast.dga-toast-warning {
    border-left: 4px solid #dba617;
}

.dga-toast.dga-toast-info {
    border-left: 4px solid #0073aa;
}

.dga-toast.show {
    opacity: 1;
    transform: translateX(0);
}

@keyframes dga-toast-in {
    from {
        opacity: 0;
        transform: translateX(40px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes dga-toast-out {
    from {
        opacity: 1;
        transform: translateX(0);
    }
    to {
        opacity: 0;
        transform: translateX(40px);
    }
}

/* --------------------------------------------------------------------------
   10. Sign-Out Button (legacy / standalone)
   -------------------------------------------------------------------------- */
.dga-sign-out-btn {
    background: #f14141;
    color: #fff;
    padding: 10px 20px;
    border: none;
    border-radius: 5px;
    font-size: 14px;
    cursor: pointer;
    text-decoration: none;
    display: inline-block;
    transition: background 0.2s ease;
}

.dga-sign-out-btn:hover,
.dga-sign-out-btn:focus {
    background: #c83232;
    color: #fff;
}

/* --------------------------------------------------------------------------
   11. Sidebar Sub-menu Items
   -------------------------------------------------------------------------- */
.dga-dashboard-wrapper .dga-sidebar-item[data-parent] {
    border-bottom: none;
}

.dga-dashboard-wrapper .dga-sidebar-item[data-parent] .dga-sidebar-link {
    padding-left: 48px;
    font-size: 13px;
    color: #bbb !important;
    padding-top: 9px;
    padding-bottom: 9px;
    position: relative;
}

.dga-dashboard-wrapper .dga-sidebar-item[data-parent] .dga-sidebar-link::before {
    content: '';
    position: absolute;
    left: 30px;
    top: 50%;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.25);
    transform: translateY(-50%);
    transition: background 0.2s ease;
}

.dga-dashboard-wrapper .dga-sidebar-item[data-parent] .dga-sidebar-link:hover {
    color: #fff !important;
}

.dga-dashboard-wrapper .dga-sidebar-item[data-parent] .dga-sidebar-link:hover::before {
    background: rgba(255, 255, 255, 0.6);
}

.dga-dashboard-wrapper .dga-sidebar-item[data-parent].active .dga-sidebar-link {
    background: rgba(0, 115, 170, 0.7) !important;
    color: #fff !important;
}

.dga-dashboard-wrapper .dga-sidebar-item[data-parent].active .dga-sidebar-link::before {
    background: #fff;
}

.dga-dashboard-wrapper .dga-sidebar-item[data-parent] .dga-sidebar-link .dashicons {
    font-size: 16px;
    width: 16px;
    height: 16px;
    line-height: 16px;
}

/* Chevron arrow on parent items with children */
.dga-dashboard-wrapper .dga-sidebar-item.has-children .dga-sidebar-link {
    position: relative;
}

.dga-dashboard-wrapper .dga-submenu-arrow {
    margin-left: auto;
    font-size: 14px !important;
    width: 14px !important;
    height: 14px !important;
    line-height: 14px !important;
    transition: transform 0.2s ease;
    opacity: 0.4;
    flex-shrink: 0;
}

.dga-dashboard-wrapper .dga-sidebar-item.has-children.expanded .dga-submenu-arrow {
    transform: rotate(90deg);
    opacity: 0.7;
}

.dga-dashboard-wrapper .dga-sidebar-item.has-children .dga-sidebar-link:hover .dga-submenu-arrow {
    opacity: 0.8;
}

.dga-dashboard-wrapper .dga-sidebar-item.has-children.active .dga-submenu-arrow {
    opacity: 1;
}

/* --------------------------------------------------------------------------
   12. Mobile Responsive (max-width: 782px)
   -------------------------------------------------------------------------- */
@media (max-width: 782px) {
    .dga-dashboard-wrapper .dga-sidebar-toggle {
        display: flex;
    }

    .dga-dashboard-wrapper .dga-sidebar-close {
        display: block;
    }

    .dga-dashboard-wrapper .dga-dashboard-sidebar {
        transform: translateX(-260px);
        position: fixed;
        width: 260px;
    }

    .dga-dashboard-wrapper .dga-dashboard-sidebar.open {
        transform: translateX(0);
    }

    .dga-dashboard-content {
        margin-left: 0;
    }

    .dga-module-panel {
        padding: 20px;
    }

    .dga-dashboard-login-required {
        padding: 40px 20px;
        margin: 20px;
    }

    .dga-tabs {
        overflow-x: auto;
    }

    .dga-modal-dialog {
        width: 95%;
    }

    .dga-toast-container {
        left: 10px;
        right: 10px;
    }

    .dga-toast {
        max-width: 100%;
    }

    /* Profile popover fullscreen on mobile */
    .dga-profile-popover {
        left: 10px;
        right: 10px;
        top: 10px;
        width: auto;
        max-height: calc(100vh - 20px);
    }

    .dga-profile-popover-arrow {
        display: none;
    }

    /* Sub-menu items mobile adjustments */
    .dga-dashboard-wrapper .dga-sidebar-item[data-parent] .dga-sidebar-link {
        padding-left: 42px;
        font-size: 12px;
    }

    .dga-dashboard-wrapper .dga-sidebar-item[data-parent] .dga-sidebar-link::before {
        left: 26px;
        width: 5px;
        height: 5px;
    }
}
