/* DrivenFit Portal Styles */

/* ---- Login card ---- */
.df-portal-login {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 60vh;
    padding: 24px;
}
.df-portal-login-card {
    background: #fff;
    border: 1px solid var(--df-border);
    border-radius: 12px;
    padding: 40px 36px;
    max-width: 380px;
    width: 100%;
    text-align: center;
    box-shadow: 0 4px 24px rgba(0,0,0,.08);
}
.df-portal-login-card img {
    width: 160px;
    margin: 0 auto 16px;
    display: block;
    background: #111827;
    border-radius: 8px;
    padding: 12px;
}
.df-portal-login-card h2 {
    margin: 0 0 6px;
    font-size: 22px;
    font-weight: 800;
    color: var(--df-black);
}
.df-portal-login-sub {
    color: var(--df-gray);
    font-size: 13px;
    margin: 0 0 24px;
}
.df-portal-login-card .df-field {
    text-align: left;
}

/* ---- Portal shell ---- */
.df-portal {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    color: var(--df-black);
    width: 100%;
    box-sizing: border-box;
}

/* Override Yootheme container constraints — same fix as calculator page */
.uk-container .df-portal,
.uk-section   .df-portal { max-width: 100%; width: 100%; }

/* ---- Header ---- */
.df-portal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: var(--df-black);
    padding: 14px 24px;
    border-radius: 10px 10px 0 0;
    gap: 16px;
    flex-wrap: wrap;
}
.df-portal-header-left {
    display: flex;
    align-items: center;
    gap: 14px;
}
.df-portal-logo-img {
    width: 110px;
    display: block;
    background: transparent;
}
.df-portal-title {
    display: block;
    font-size: 16px;
    font-weight: 700;
    color: #fff;
    line-height: 1.2;
}
.df-portal-user {
    display: block;
    font-size: 12px;
    color: #F15A29;
    font-weight: 600;
}
.df-portal-header-right {
    display: flex;
    align-items: center;
    gap: 10px;
}
.df-portal-btn-link {
    font-size: 12px;
    color: #9ca3af;
    text-decoration: none;
    padding: 6px 12px;
    border: 1px solid #374151;
    border-radius: 6px;
    transition: color .15s;
}
.df-portal-btn-link:hover { color: #fff; }
.df-btn-sm { padding: 7px 16px; font-size: 13px; }

/* ---- Stats bar ---- */
.df-portal-stats {
    display: flex;
    gap: 1px;
    background: var(--df-border);
    border-left: 1px solid var(--df-border);
    border-right: 1px solid var(--df-border);
}
.df-stat-card {
    flex: 1;
    background: #fff;
    padding: 14px 20px;
    text-align: center;
}
.df-stat-val {
    font-size: 26px;
    font-weight: 800;
    color: #F15A29;
    line-height: 1;
    margin-bottom: 3px;
}
.df-stat-label {
    font-size: 11px;
    color: var(--df-gray);
    text-transform: uppercase;
    letter-spacing: 0.4px;
}

/* ---- Filters ---- */
.df-portal-filters {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    align-items: flex-end;
    padding: 16px 20px;
    background: #f9fafb;
    border: 1px solid var(--df-border);
    border-top: none;
}
.df-filter-group {
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-width: 120px;
}
.df-filter-group label {
    font-size: 11px;
    font-weight: 600;
    color: var(--df-gray);
    text-transform: uppercase;
    letter-spacing: 0.4px;
}
.df-filter-group select,
.df-filter-group input[type="date"] {
    padding: 7px 10px;
    border: 1.5px solid var(--df-border);
    border-radius: 6px;
    font-size: 13px;
    background: #fff;
    color: var(--df-black);
}
.df-filter-actions {
    flex-direction: row;
    align-items: flex-end;
    min-width: auto;
    gap: 8px;
}

/* ---- Table wrap ---- */
.df-portal-table-wrap {
    background: #fff;
    border: 1px solid var(--df-border);
    border-top: none;
    border-radius: 0 0 10px 10px;
    overflow-x: auto;
    min-height: 200px;
}
.df-portal-loading {
    text-align: center;
    padding: 48px 24px;
    color: var(--df-gray);
    font-size: 14px;
}
.df-portal-empty {
    text-align: center;
    padding: 48px 24px;
    color: var(--df-gray);
    font-size: 14px;
}

/* ---- Assessments table ---- */
.df-portal-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}
.df-portal-table thead tr {
    background: #f9fafb;
    border-bottom: 2px solid var(--df-border);
}
.df-portal-table th {
    padding: 10px 14px;
    text-align: left;
    font-size: 11px;
    font-weight: 700;
    color: var(--df-gray);
    text-transform: uppercase;
    letter-spacing: 0.4px;
    white-space: nowrap;
}
.df-portal-table td {
    padding: 10px 14px;
    border-bottom: 1px solid #f3f4f6;
    vertical-align: middle;
}
.df-portal-table tbody tr:hover {
    background: #f9fafb;
    cursor: pointer;
}
.df-portal-table tbody tr:last-child td {
    border-bottom: none;
}

/* Level badge */
.df-level-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    background: #fff0eb;
    color: #F15A29;
    font-weight: 700;
    padding: 3px 10px;
    border-radius: 12px;
    font-size: 12px;
    white-space: nowrap;
}
.df-type-badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 600;
}
.df-type-badge.trainer  { background: #fff0eb; color: #7c2d12; }
.df-type-badge.prospect { background: #f3f4f6; color: #374151; }

.df-sync-dot { font-size: 12px; }
.df-sync-dot.ok  { color: #16a34a; }
.df-sync-dot.fail{ color: #dc2626; }

.df-booked-yes { color: #16a34a; font-weight: 700; }
.df-booked-no  { color: #9ca3af; }

/* ---- Pagination ---- */
.df-portal-pagination {
    display: flex;
    gap: 6px;
    padding: 14px 20px;
    justify-content: center;
    border-top: 1px solid var(--df-border);
}
.df-page-btn {
    padding: 5px 12px;
    border: 1px solid var(--df-border);
    border-radius: 6px;
    background: #fff;
    font-size: 13px;
    cursor: pointer;
    transition: background .15s;
}
.df-page-btn:hover    { background: #f9fafb; }
.df-page-btn.active   { background: #F15A29; color: #fff; border-color: #F15A29; }
.df-page-btn:disabled { opacity: .4; cursor: default; }

/* ---- Detail drawer ---- */
.df-portal-drawer {
    position: fixed;
    inset: 0;
    z-index: 9999;
    display: flex;
    justify-content: flex-end;
}
.df-drawer-overlay {
    position: absolute;
    inset: 0;
    background: rgba(0,0,0,.45);
}
.df-drawer-panel {
    position: relative;
    z-index: 1;
    width: 520px;
    max-width: 100vw;
    height: 100%;
    background: #fff;
    display: flex;
    flex-direction: column;
    box-shadow: -4px 0 32px rgba(0,0,0,.15);
    animation: df-slide-in .2s ease;
}
@keyframes df-slide-in {
    from { transform: translateX(100%); }
    to   { transform: translateX(0); }
}
.df-drawer-header {
    background: var(--df-black);
    padding: 14px 20px;
    display: flex;
    align-items: center;
    gap: 14px;
    flex-shrink: 0;
}
.df-drawer-close {
    background: none;
    border: none;
    color: #9ca3af;
    font-size: 13px;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 4px;
    transition: color .15s;
    white-space: nowrap;
}
.df-drawer-close:hover { color: #fff; }
.df-drawer-title {
    font-size: 15px;
    font-weight: 700;
    color: #fff;
    flex: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.df-drawer-body {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
}

/* ---- Drawer content ---- */
.df-drawer-score-card {
    background: #111827;
    border-radius: 10px;
    padding: 16px 20px;
    display: flex;
    align-items: center;
    gap: 16px;
    margin-bottom: 16px;
}
.df-drawer-gauge {
    text-align: center;
    flex-shrink: 0;
}
.df-drawer-gauge .df-gauge-pct {
    font-size: 28px;
    font-weight: 900;
    color: #fff;
    display: block;
    line-height: 1;
}
.df-drawer-gauge .df-gauge-label {
    font-size: 9px;
    color: #9ca3af;
    letter-spacing: 1px;
    text-transform: uppercase;
}
.df-drawer-level-info {}
.df-drawer-level-info .df-drawer-your-results {
    font-size: 10px;
    font-weight: 700;
    color: #F15A29;
    letter-spacing: 1px;
    text-transform: uppercase;
    margin: 0 0 2px;
}
.df-drawer-level-info .df-drawer-level-num {
    font-size: 32px;
    font-weight: 900;
    color: #fff;
    line-height: 1;
    margin: 0 0 2px;
}
.df-drawer-level-info .df-drawer-level-label {
    font-size: 13px;
    font-weight: 700;
    color: #F15A29;
    text-transform: uppercase;
    margin: 0 0 6px;
}
.df-drawer-level-info .df-drawer-level-desc {
    font-size: 12px;
    color: #d1d5db;
    line-height: 1.5;
    margin: 0;
}

.df-drawer-cats {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr 1fr;
    gap: 8px;
    margin-bottom: 16px;
}
.df-drawer-cat {
    border: 1px solid var(--df-border);
    border-radius: 8px;
    padding: 10px 6px;
    text-align: center;
}
.df-drawer-cat-label { font-size: 9px; font-weight: 700; color: var(--df-gray); letter-spacing: 0.5px; margin-bottom: 4px; }
.df-drawer-cat-val   { font-size: 22px; font-weight: 900; color: var(--df-black); line-height: 1; margin-bottom: 2px; }
.df-drawer-cat-lvl   { font-size: 10px; font-weight: 700; margin-bottom: 6px; }
.df-drawer-dots      { display: flex; gap: 2px; justify-content: center; flex-wrap: wrap; }
.df-drawer-dot       { width: 8px; height: 8px; border-radius: 50%; }

.df-drawer-section { margin-bottom: 16px; }
.df-drawer-section-title {
    font-size: 11px;
    font-weight: 700;
    color: var(--df-gray);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin: 0 0 8px;
    padding-bottom: 6px;
    border-bottom: 1px solid var(--df-border);
}
.df-drawer-table {
    width: 100%;
    font-size: 12px;
    border-collapse: collapse;
}
.df-drawer-table td, .df-drawer-table th {
    padding: 6px 10px;
    border: 1px solid var(--df-border);
}
.df-drawer-table th { background: #f9fafb; font-weight: 600; text-align: left; }
.df-drawer-table tr:nth-child(even) td { background: #fafafa; }

.df-drawer-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin-bottom: 12px;
}
.df-drawer-actions .df-btn { flex: 1; min-width: 120px; text-align: center; }

.df-drawer-note textarea {
    width: 100%;
    padding: 8px 12px;
    border: 1.5px solid var(--df-border);
    border-radius: 6px;
    font-size: 13px;
    font-family: inherit;
    resize: vertical;
    box-sizing: border-box;
}

.df-log-row-sent   { color: #16a34a; font-weight: 600; }
.df-log-row-failed { color: #dc2626; font-weight: 600; }
.df-log-row-skipped{ color: #92400e; font-weight: 600; }

/* ---- Step test block ---- */
.df-step-test-block {
    background: #f0fdf4;
    border-radius: 8px;
    padding: 12px 14px;
    margin-bottom: 12px;
}
.df-step-test-block .df-step-label { font-size: 11px; font-weight: 700; color: #166534; margin-bottom: 4px; }
.df-step-test-block .df-step-text  { font-size: 12px; color: #374151; line-height: 1.5; }

/* ---- Responsive ---- */
@media (max-width: 640px) {
    .df-portal-stats { flex-wrap: wrap; }
    .df-stat-card    { min-width: 45%; }
    .df-drawer-cats  { grid-template-columns: 1fr 1fr; }
    .df-drawer-panel { width: 100vw; }
    .df-portal-table { font-size: 12px; }
    .df-portal-table th, .df-portal-table td { padding: 7px 8px; }
}

/* ================================================================
   PORTAL ADMIN TABS
   ================================================================ */
.df-portal-tabnav {
    display: flex;
    gap: 0;
    border-bottom: 2px solid var(--df-border, #d9d9d9);
    margin: 0;
    padding: 0 24px;
    background: #fff;
    overflow-x: auto;
}
.df-portal-tab {
    padding: 12px 20px;
    font-size: 13px;
    font-weight: 600;
    color: #6b7280;
    background: none;
    border: none;
    border-bottom: 3px solid transparent;
    margin-bottom: -2px;
    cursor: pointer;
    white-space: nowrap;
    transition: color 0.15s, border-color 0.15s;
}
.df-portal-tab:hover       { color: #111827; }
.df-portal-tab-active      { color: #f15a29; border-bottom-color: #f15a29; }

.df-portal-tabpanel { padding: 0; }

/* ================================================================
   ADMIN SECTION LAYOUT
   ================================================================ */
.df-admin-section {
    background: #fff;
    border-radius: 8px;
    padding: 24px;
    margin: 16px;
    box-shadow: 0 1px 3px rgba(0,0,0,.06);
}
.df-admin-section-title {
    margin: 0 0 4px;
    font-size: 16px;
    font-weight: 700;
    color: #111827;
}
.df-admin-section-desc {
    margin: 0 0 16px;
    font-size: 13px;
    color: #6b7280;
    line-height: 1.5;
}
.df-admin-section-desc code {
    background: #f3f4f6;
    border-radius: 3px;
    padding: 1px 5px;
    font-size: 12px;
    color: #374151;
}
.df-admin-subsection {
    border-top: 1px solid #e5e7eb;
    padding-top: 16px;
    margin-top: 16px;
}
.df-admin-subsection-title {
    margin: 0 0 12px;
    font-size: 14px;
    font-weight: 600;
    color: #374151;
}

/* ================================================================
   FIELD GRID
   ================================================================ */
.df-field-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin-bottom: 12px;
}
.df-field-grid-4 { grid-template-columns: repeat(4, 1fr); }
@media (max-width: 640px) {
    .df-field-grid   { grid-template-columns: 1fr; }
    .df-field-grid-4 { grid-template-columns: 1fr 1fr; }
}
.df-field { margin-bottom: 12px; }
.df-field label {
    display: block;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: #374151;
    margin-bottom: 4px;
}
.df-field input[type="text"],
.df-field input[type="password"],
.df-field input[type="number"],
.df-field textarea {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid #d1d5db;
    border-radius: 4px;
    font-size: 13px;
    color: #111827;
    background: #fff;
    box-sizing: border-box;
}
.df-field input:focus,
.df-field textarea:focus {
    outline: none;
    border-color: #f15a29;
    box-shadow: 0 0 0 2px rgba(241,90,41,.12);
}
.df-field textarea { resize: vertical; }

/* ================================================================
   BUCKET TABS (inside Templates)
   ================================================================ */
.df-bucket-tabs {
    display: flex;
    gap: 8px;
    margin-bottom: 16px;
}
.df-bucket-tab {
    padding: 6px 16px;
    border-radius: 20px;
    border: 1px solid #d1d5db;
    background: #f9fafb;
    font-size: 12px;
    font-weight: 600;
    color: #374151;
    cursor: pointer;
    transition: all 0.15s;
}
.df-bucket-tab:hover        { border-color: #f15a29; color: #f15a29; }
.df-bucket-tab-active       { background: #f15a29; border-color: #f15a29; color: #fff; }
.df-bucket-panel.df-hidden  { display: none; }

/* ================================================================
   NOTICE / FEEDBACK
   ================================================================ */
.df-notice {
    padding: 10px 16px;
    border-radius: 6px;
    font-size: 13px;
    margin-bottom: 12px;
}
.df-notice-success { background: #dcfce7; color: #166534; }
.df-notice-error   { background: #fef2f2; color: #dc2626; }
.df-hidden         { display: none !important; }

/* ================================================================
   USER (TRAINER / ADMIN) CARDS
   ================================================================ */
.df-user-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 16px;
}
.df-user-card {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: #f9fafb;
    border: 1px solid #e5e7eb;
    border-radius: 6px;
    padding: 10px 16px;
}
.df-user-info    { display: flex; flex-direction: column; gap: 2px; }
.df-user-name    { font-size: 14px; font-weight: 600; color: #111827; }
.df-user-pin     { font-size: 11px; color: #9ca3af; }
.df-user-actions { display: flex; gap: 8px; }
.df-btn-danger {
    background: #fef2f2;
    color: #dc2626;
    border: 1px solid #fca5a5;
}
.df-btn-danger:hover { background: #fee2e2; }

/* ================================================================
   RESPONSIVE — TABLET & MOBILE ONLY (≤768px and ≤640px)
   Desktop layout is completely unchanged above these breakpoints.
   ================================================================ */

/* ---- Filter toggle button (hidden on desktop) ---- */
.df-filter-toggle-btn {
    display: none;
}

/* ---- Card list (hidden on desktop, shown on tablet/mobile via JS) ---- */
.df-card-list     { display: none; }

/* ================================================================
   TABLET (≤768px)
   ================================================================ */
@media (max-width: 768px) {

    /* Stats bar — 2×2 grid */
    .df-portal-stats {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 1px;
    }
    .df-stat-card { min-width: 0; }

    /* Header — hide WP Dashboard link, tighten spacing */
    .df-portal-btn-link { display: none; }
    .df-portal-header   { padding: 10px 16px; }
    .df-portal-title    { font-size: 15px; }

    /* Tab nav — scrollable pill row */
    .df-portal-tabnav {
        padding: 10px 12px;
        gap: 8px;
        border-bottom: 1px solid var(--df-border, #d9d9d9);
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
        /* Fade gradient on right to signal more tabs */
        -webkit-mask-image: linear-gradient(to right, black 80%, transparent 100%);
        mask-image:         linear-gradient(to right, black 80%, transparent 100%);
    }
    .df-portal-tabnav::-webkit-scrollbar { display: none; }

    .df-portal-tab {
        /* Pill style */
        padding: 7px 14px;
        border-radius: 20px;
        border: 1.5px solid #d1d5db;
        background: #f9fafb;
        font-size: 12px;
        font-weight: 600;
        color: #374151;
        white-space: nowrap;
        border-bottom: 1.5px solid #d1d5db;
        margin-bottom: 0;
    }
    .df-portal-tab:hover {
        border-color: #f15a29;
        color: #f15a29;
        background: #fff;
    }
    .df-portal-tab-active {
        background: #f15a29;
        border-color: #f15a29;
        color: #fff;
    }

    /* Filter toggle button — visible on tablet */
    .df-filter-toggle-btn {
        display: block;
        width: 100%;
        padding: 10px 16px;
        background: #f9fafb;
        border: none;
        border-bottom: 1px solid var(--df-border, #d9d9d9);
        text-align: left;
        font-size: 13px;
        font-weight: 600;
        color: #374151;
        cursor: pointer;
    }

    /* Filter body — hidden by default on tablet/mobile */
    #df-filters-body {
        display: none;
    }

    .df-portal-filters {
        flex-direction: column;
        padding: 12px 16px;
        gap: 10px;
    }
    .df-filter-group  { min-width: 0; width: 100%; }
    .df-filter-actions {
        flex-direction: row;
        gap: 8px;
    }
    .df-filter-actions .df-btn {
        flex: 1;
    }

    /* Card list — show on tablet/mobile, hide table */
    .df-portal-table-wrap .df-portal-table { display: none; }
    .df-card-list { display: flex; flex-direction: column; gap: 0; }

    /* Card layout */
    .df-card {
        position: relative;
        padding: 14px 16px;
        border-bottom: 1px solid #f3f4f6;
        background: #fff;
        cursor: pointer;
        display: flex;
        flex-direction: column;
        gap: 6px;
        transition: background 0.1s;
    }
    .df-card:active { background: #fef9f7; }

    .df-card-top {
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: 8px;
    }
    .df-card-name {
        font-size: 15px;
        font-weight: 700;
        color: #111827;
        flex: 1;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }
    .df-card-sub {
        font-size: 12px;
        color: #9ca3af;
    }
    .df-card-meta {
        display: flex;
        flex-wrap: wrap;
        gap: 6px;
        align-items: center;
    }
    .df-card-meta-item {
        font-size: 12px;
        color: #6b7280;
        background: #f3f4f6;
        padding: 2px 8px;
        border-radius: 4px;
    }
    .df-card-booked.booked {
        font-size: 12px;
        background: #dcfce7;
        color: #166534;
        padding: 2px 8px;
        border-radius: 4px;
        font-weight: 600;
    }
    .df-card-arrow {
        position: absolute;
        right: 16px;
        top: 50%;
        transform: translateY(-50%);
        font-size: 20px;
        color: #d1d5db;
    }

    /* Pagination — larger touch targets */
    .df-page-btn {
        min-width: 40px;
        min-height: 40px;
        font-size: 14px;
    }

    /* Admin sections — tighter padding */
    .df-admin-section { padding: 16px; margin: 12px; }

    /* Drawer — full width */
    .df-drawer-panel { width: 100vw; }
}

/* ================================================================
   MOBILE (≤640px) — additional refinements on top of tablet styles
   ================================================================ */
@media (max-width: 640px) {

    /* Stats — tighter */
    .df-stat-val   { font-size: 22px; }
    .df-stat-card  { padding: 12px; }

    /* Admin field grids — single column */
    .df-field-grid   { grid-template-columns: 1fr; }
    .df-field-grid-4 { grid-template-columns: 1fr 1fr; }

    /* User cards — stack actions below name */
    .df-user-card {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }
    .df-user-actions {
        width: 100%;
        justify-content: flex-start;
    }

    /* Bucket tabs — scrollable row */
    .df-bucket-tabs {
        overflow-x: auto;
        flex-wrap: nowrap;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
        padding-bottom: 4px;
    }
    .df-bucket-tabs::-webkit-scrollbar { display: none; }

    /* Portal header tighten */
    .df-portal-header { gap: 8px; }
    .df-portal-logo-img { width: 28px; }
}

/* ================================================================
   BULK ACTION BAR
   ================================================================ */
.df-bulk-bar {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 16px;
    background: #fff8f0;
    border: 1px solid #fed7aa;
    border-bottom: none;
    font-size: 13px;
    font-weight: 600;
    color: #374151;
}
#df-bulk-count { flex: 1; color: #f15a29; }
