/* =========================================
   CRM ADMIN DASHBOARD (PREMIUM REDESIGN)
   ========================================= */
.crm-layout {
    display: flex;
    height: 100vh;
    background-color: #f8fafc;
    overflow: hidden;
    color: #1e293b;
}

/* Sidebar (Desktop) */
.crm-sidebar {
    width: 280px;
    min-width: 280px;
    flex-shrink: 0;
    background: white;
    border-right: 1px solid #e2e8f0;
    display: flex;
    flex-direction: column;
    z-index: 50;
    transition: all 0.3s ease;
}

/* Sidebar Collapsed State */
@media (min-width: 901px) {
    .crm-layout.sidebar-collapsed .crm-sidebar {
        width: 80px !important;
        min-width: 80px !important;
        max-width: 80px !important;
        flex-shrink: 0;
    }

    .crm-layout.sidebar-collapsed .crm-brand-custom {
        padding: 24px 0;
        justify-content: center;
    }

    .crm-layout.sidebar-collapsed .crm-brand-custom .brand-divider,
    .crm-layout.sidebar-collapsed .crm-brand-custom .brand-text-stack {
        display: none;
    }

    .crm-layout.sidebar-collapsed .badge-pro {
        display: none;
    }

    .crm-layout.sidebar-collapsed .crm-nav-item {
        padding: 14px 0;
        justify-content: center;
        font-size: 0;
        gap: 0;
    }

    .crm-layout.sidebar-collapsed .crm-nav-item .nav-icon {
        margin: 0;
    }

    .crm-layout.sidebar-collapsed .btn-crm-logout {
        font-size: 0;
        padding: 12px 0;
        display: flex;
        justify-content: center;
    }

    .crm-layout.sidebar-collapsed .btn-crm-logout::before {
        content: "\21A9"; /* Logout icon roughly */
        font-size: 18px;
    }
}

.crm-brand-custom {
    padding: 24px;
    display: flex;
    align-items: center;
    gap: 12px;
    border-bottom: 1px solid #f1f5f9;
}

.brand-logo-icon {
    display: flex;
    align-items: center;
    justify-content: center;
}

.brand-logo-img {
    width: 55px;
    height: 55px;
    object-fit: contain;
    transform: scale(1.8);
}

.brand-divider {
    width: 2px;
    height: 42px;
    background-color: #cbd5e1;
    border-radius: 2px;
    margin: 0 10px;
}

.brand-text-stack {
    display: flex;
    flex-direction: column;
    justify-content: center;
    line-height: 1;
}

.brand-text-img {
    width: 120px;
    height: auto;
    object-fit: contain;
}

.badge-pro {
    background: linear-gradient(135deg, #6366f1, #a855f7);
    color: white;
    font-size: 11px;
    padding: 3px 6px;
    border-radius: 6px;
    font-weight: 800;
}

.crm-nav {
    flex: 1;
    padding: 24px 16px;
    overflow-y: auto;
}

.crm-nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    padding: 14px 16px;
    margin-bottom: 8px;
    border: none;
    border-radius: 12px;
    background: transparent;
    color: #64748b;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    text-align: left;
    white-space: nowrap;
    overflow: hidden;
}

.crm-nav-item:hover {
    background: #f1f5f9;
    color: #1e293b;
}

.crm-nav-item.active {
    background: #e0e7ff;
    color: #4f46e5;
}

.crm-nav-item .nav-icon {
    width: 20px;
    height: 20px;
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.crm-sidebar-footer {
    padding: 24px 16px;
    border-top: 1px solid #f1f5f9;
}

.btn-crm-logout {
    width: 100%;
    padding: 12px;
    border-radius: 10px;
    border: 1px solid #fee2e2;
    background: #fff5f5;
    color: #ef4444;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-crm-logout:hover {
    background: #fee2e2;
}

/* Main Content Area */
.crm-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.crm-header-top {
    height: 72px;
    background: white;
    border-bottom: 1px solid #e2e8f0;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    padding: 0 32px;
    z-index: 40;
}

.crm-search-box {
    display: flex;
    align-items: center;
    background: #f1f5f9;
    padding: 8px 16px;
    border-radius: 12px;
    width: 320px;
}

.crm-search-box input {
    border: none;
    background: transparent;
    width: 100%;
    outline: none;
    font-size: 14px;
    color: #334155;
}

.crm-search-box input::placeholder {
    color: #94a3b8;
}

.search-icon {
    width: 18px;
    height: 18px;
    stroke: #94a3b8;
    stroke-width: 2;
    margin-right: 12px;
}

.crm-header-actions {
    display: flex;
    align-items: center;
    gap: 16px;
}

.crm-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: linear-gradient(135deg, #6366f1, #4f46e5);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 14px;
    cursor: pointer;
    box-shadow: 0 4px 10px rgba(99, 102, 241, 0.3);
}

.crm-content-scroll {
    flex: 1;
    overflow-y: auto;
    padding: 32px;
}

.crm-page-title {
    font-size: 28px;
    font-weight: 800;
    color: #0f172a;
    margin: 0 0 24px 0;
}

.crm-section-title {
    font-size: 18px;
    font-weight: 700;
    color: #1e293b;
    margin: 0 0 16px 0;
}

/* KPI Cards */
.kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 24px;
}

.kpi-card {
    padding: 24px;
    border-left: 4px solid #6366f1;
}

.kpi-card:nth-child(2) {
    border-left-color: #10b981;
}

.kpi-card:nth-child(3) {
    border-left-color: #f59e0b;
}

.kpi-label {
    display: block;
    font-size: 13px;
    font-weight: 700;
    color: #64748b;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 8px;
}

.kpi-val-row {
    display: flex;
    align-items: baseline;
    gap: 12px;
}

.kpi-number {
    font-size: 36px;
    font-weight: 800;
    letter-spacing: -1px;
}

.text-indigo {
    color: #4f46e5;
}

.text-green {
    color: #10b981;
}

.text-orange {
    color: #f59e0b;
}

.kpi-trend {
    font-size: 14px;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: 6px;
}

.kpi-trend.positive {
    background: #dcfce7;
    color: #16a34a;
}

.kpi-trend.negative {
    background: #ffedd5;
    color: #ea580c;
}

/* Tables */
.crm-table {
    width: 100%;
    border-collapse: collapse;
}

.crm-table th {
    text-align: left;
    padding: 16px 24px;
    font-size: 12px;
    font-weight: 700;
    color: #64748b;
    text-transform: uppercase;
    border-bottom: 1px solid #e2e8f0;
    background: #f8fafc;
}

.crm-table td {
    padding: 20px 24px;
    border-bottom: 1px solid #f1f5f9;
    vertical-align: middle;
    font-size: 14px;
    color: #334155;
    font-weight: 500;
}

.crm-table tr:hover td {
    background-color: #f8fafc;
}

.user-row-info {
    display: flex;
    align-items: center;
    gap: 12px;
}

.user-avatar-small {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    overflow: hidden;
    background: #e2e8f0;
    display: flex;
    align-items: center;
    justify-content: center;
}

.user-avatar-small img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.user-name-cell {
    display: block;
    font-weight: 700;
    color: #0f172a;
}

.user-email-cell {
    font-size: 12px;
    color: #64748b;
}

.status-badge {
    padding: 4px 10px;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 600;
}

.status-active {
    background: #dcfce7;
    color: #16a34a;
}

.status-expired {
    background: #fef3c7;
    color: #d97706;
}

.status-banned {
    background: #fee2e2;
    color: #ef4444;
}

.plan-badge {
    background: #f1f5f9;
    color: #475569;
    padding: 4px 8px;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 600;
}

.btn-text-action {
    color: #4f46e5;
    font-weight: 600;
    background: transparent;
    border: none;
    cursor: pointer;
    font-size: 13px;
    padding: 6px 10px;
    border-radius: 6px;
}

.btn-text-action:hover {
    background: #e0e7ff;
}

.action-btn-group {
    display: flex;
    gap: 8px;
}

.btn-icon-sm {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    background: #f1f5f9;
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: #64748b;
    transition: all 0.2s;
}

.btn-icon-sm:hover {
    background: #e2e8f0;
    color: #0f172a;
}

.btn-icon-sm svg {
    width: 16px;
    height: 16px;
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

/* Radzen Settings Overrides */
.crm-settings-view .rz-tabview {
    border-radius: 16px;
    overflow: hidden;
    background: transparent;
    border: none;
}

.crm-settings-view .rz-tabview-nav {
    background: white;
    border-right: 1px solid #e2e8f0;
    padding: 16px 0;
}

.crm-settings-view .rz-tabview-nav li {
    margin-bottom: 8px;
}

.crm-settings-view .rz-tabview-nav li .rz-tabview-title {
    color: #64748b;
    font-weight: 600;
    padding: 12px 24px;
    border-radius: 0 12px 12px 0;
    transition: all 0.2s ease;
    border: none;
    background: transparent;
}

.crm-settings-view .rz-tabview-nav li.rz-tabview-selected {
    border: none;
}

.crm-settings-view .rz-tabview-nav li.rz-tabview-selected .rz-tabview-title {
    color: #4f46e5;
    background: rgba(99, 102, 241, 0.1);
    border-left: 3px solid #4f46e5;
}

.crm-settings-view .rz-tabview-panels {
    background: transparent;
    border: none;
    padding: 16px;
}

/* Mobile Bottom Nav (CRM) */
.crm-mobile-nav {
    display: none;
}

/* Mobile responsive */
@media (max-width: 900px) {
    .crm-sidebar {
        display: none;
    }

    .crm-sidebar.mobile-open {
        display: flex;
        position: fixed;
        top: 0;
        left: 0;
        bottom: 0;
        z-index: 1000;
        width: 280px !important;
        max-width: 280px !important;
        box-shadow: 10px 0 25px rgba(0,0,0,0.1);
        background: white;
    }

    .crm-sidebar.mobile-open ~ .crm-mobile-nav {
        display: none !important;
    }

    .crm-header-top {
        padding: 0 16px;
    }

    .crm-search-box {
        width: 200px;
    }

    .crm-content-scroll {
        padding: 20px;
    }

    .table-responsive {
        overflow-x: auto;
    }

    .crm-table th,
    .crm-table td {
        padding: 16px;
    }

    .crm-mobile-nav {
        display: flex;
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        height: 70px;
        background: rgba(255, 255, 255, 0.9);
        backdrop-filter: blur(10px);
        border-top: 1px solid #e2e8f0;
        z-index: 100;
        justify-content: space-around;
        padding: 8px;
    }

    .crm-mobile-item {
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        gap: 4px;
        flex: 1;
        background: transparent;
        border: none;
        color: #94a3b8;
        font-size: 11px;
        font-weight: 600;
    }

    .crm-mobile-item.active {
        color: #6366f1;
    }

    .crm-mobile-item .nav-icon {
        width: 24px;
        height: 24px;
        stroke: currentColor;
        stroke-width: 2;
        stroke-linecap: round;
        stroke-linejoin: round;
    }
}

/* =========================================
   USER DETAIL VIEW (PREMIUM)
   ========================================= */
.premium-detail-container {
    padding: 10px;
    color: #1e293b;
}

.avatar-wrapper-detail {
    width: 120px;
    height: 120px;
    border-radius: 24px;
    overflow: hidden;
    background: #f1f5f9;
    border: 3px solid white;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.05);
    position: relative;
    margin: 0 auto;
}

.avatar-placeholder-detail {
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, #f8fafc, #e2e8f0);
    display: flex;
    align-items: center;
    justify-content: center;
}

.avatar-image-detail {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.premium-text-gradient {
    background: linear-gradient(135deg, #1e293b, #475569);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    font-size: 24px;
    font-weight: 800;
}

.info-group-detail {
    background: white;
    padding: 16px;
    border-radius: 16px;
    border: 1px solid #f1f5f9;
    transition: all 0.2s ease;
}

.info-group-detail:hover {
    border-color: #e2e8f0;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.03);
}

.info-value-detail {
    font-weight: 700;
    color: #0f172a;
    font-size: 16px;
    margin-top: 4px;
}

.quick-updates-detail {
    background: #f8fafc;
    padding: 24px;
    border-radius: 20px;
    border: 1px solid #e2e8f0;
}

.avatar-actions-detail {
    display: flex;
    gap: 8px;
    margin-top: 12px;
    justify-content: center;
}

/* =========================================
   PHASE 4: PROFILE & UI POLISH
   ========================================= */

/* Tabs Styling */
.crm-tabs {
    display: flex;
    gap: 8px;
    border-bottom: 2px solid #f1f5f9;
    margin-bottom: 24px;
    padding: 0 4px;
}

.crm-tab-item {
    padding: 12px 20px;
    font-size: 14px;
    font-weight: 700;
    color: #64748b;
    cursor: pointer;
    transition: all 0.2s;
    position: relative;
    border: none;
    background: transparent;
}

.crm-tab-item:hover {
    color: #1e293b;
}

.crm-tab-item.active {
    color: #4f46e5;
    background: rgba(99, 102, 241, 0.05);
    border-radius: 12px 12px 0 0;
}

.crm-tab-item.active::after {
    content: '';
    position: absolute;
    bottom: -2px;
    left: 0;
    right: 0;
    height: 3px;
    background: #4f46e5;
    border-radius: 3px;
}

/* Sectioned Detail View */
.detail-section-card {
    background: white;
    border-radius: 20px;
    border: 1px solid #f1f5f9;
    padding: 24px;
    height: 100%;
    transition: all 0.2s;
}

.detail-section-card:hover {
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.03);
    border-color: #e2e8f0;
}

.section-header-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.section-title-crm {
    font-size: 16px;
    font-weight: 800;
    color: #0f172a;
    display: flex;
    align-items: center;
    gap: 10px;
}

/* Profile Header */
.profile-header-premium {
    display: flex;
    align-items: center;
    gap: 32px;
    padding: 32px;
    background: white;
    border-radius: 24px;
    border: 1px solid #f1f5f9;
    margin-bottom: 24px;
}

.profile-meta-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 24px;
    padding-left: 32px;
    border-left: 1px solid #f1f5f9;
}

.meta-item-crm {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.meta-label-crm {
    font-size: 11px;
    font-weight: 700;
    color: #94a3b8;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.meta-value-crm {
    font-weight: 700;
    color: #1e293b;
    font-size: 14px;
}

/* Grid Avatar Enhancement */
.grid-avatar-cell {
    display: flex;
    align-items: center;
    gap: 12px;
}

.grid-avatar-circle {
    width: 32px;
    height: 32px;
    border-radius: 10px;
    background: #f1f5f9;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #94a3b8;
    font-size: 13px;
    font-weight: 800;
}

.grid-avatar-circle img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* Status Pills Enhancement */
.pill-badge {
    padding: 6px 14px;
    border-radius: 99px;
    font-size: 12px;
    font-weight: 800;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.pill-active {
    background: #dcfce7;
    color: #15803d;
    border: 1px solid #bbf7d0;
}

.pill-prospect {
    background: #fef9c3;
    color: #a16207;
    border: 1px solid #fef08a;
}

.pill-inactive {
    background: #f1f5f9;
    color: #64748b;
    border: 1px solid #e2e8f0;
}

.pill-expired {
    background: #fee2e2;
    color: #b91c1c;
    border: 1px solid #fecaca;
}

/* =========================================
   SHARED SEARCH INPUT (POS STYLE)
   ========================================= */
.pos-search-container {
    position: relative;
    display: flex;
    flex-direction: column;
}

.pos-search-input-wrapper {
    position: relative;
    width: 100%;
}

.pos-search-icon {
    position: absolute;
    left: 1.25rem;
    top: 50%;
    transform: translateY(-50%);
    font-size: 16px;
    color: #94a3b8;
    pointer-events: none;
}

.pos-search-input-wrapper .fitlog-input {
    padding-left: 3.5rem; /* Increased for emoji space */
    padding-right: 2.75rem;
}

.pos-search-clear {
    position: absolute;
    right: 0.75rem;
    top: 50%;
    transform: translateY(-50%);
    background: #f1f5f9;
    border: none;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    color: #64748b;
    font-size: 10px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    z-index: 5;
}

.pos-search-clear:hover {
    background: #e2e8f0;
    color: #1e293b;
}

.pos-search-results {
    position: absolute;
    top: calc(100% + 0.5rem);
    left: 0;
    right: 0;
    background: #ffffff;
    border-radius: 1.25rem;
    border: 1px solid #e2e8f0;
    box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.1), 0 8px 10px -6px rgba(0, 0, 0, 0.1);
    z-index: 1000;
    max-height: 150px; /* Further reduced for ~2 items plus padding */
    overflow-y: auto;
    padding: 0.5rem;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.pos-search-results::-webkit-scrollbar {
    width: 6px;
}

.pos-search-results::-webkit-scrollbar-thumb {
    background: #e2e8f0;
    border-radius: 10px;
}

.pos-search-item {
    padding: 0.875rem 1rem;
    border-radius: 0.875rem;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    text-align: left;
}

.pos-search-item:hover {
    background: #f8fafc;
}

.pos-search-item.selected {
    background: #eef2ff;
    border: 1px solid #c7d2fe;
}

.pos-item-main {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
}

.pos-item-name {
    font-size: 0.875rem;
    font-weight: 800;
    color: #1e293b;
}

.pos-item-price {
    font-size: 0.875rem;
    font-weight: 900;
    color: #4f46e5;
}

.pos-item-meta {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.pos-stock-badge {
    font-size: 9px;
    font-weight: 900;
    padding: 0.25rem 0.5rem;
    background: #f1f5f9;
    color: #64748b;
    border-radius: 2rem;
    text-transform: uppercase;
}

.pos-item-cat {
    font-size: 10px;
    font-weight: 700;
    color: #94a3b8;
}

.pos-search-no-results {
    padding: 2rem;
    text-align: center;
    color: #94a3b8;
    font-size: 0.875rem;
    font-weight: 700;
}

@keyframes popIn {
    from { opacity: 0; transform: translateY(10px) scale(0.98); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

.animate-pop-in {
    animation: popIn 0.2s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

/* Modales Egresos Redondeados */
.fitlog-dialog.rz-dialog,
.fitlog-dialog.rz-dialog .rz-dialog-content,
.rz-dialog:has(.fitlog-custom-modal),
.rz-dialog-content:has(.fitlog-custom-modal) {
    background: transparent !important;
    background-color: transparent !important;
    box-shadow: none !important;
    border: none !important;
    border-radius: 2rem !important;
    padding: 0 !important;
}

.rz-dialog-wrapper {
    border-radius: 2rem !important;
}

/* Clases globales para inputs (basadas en TrainerFormView) */
.fitlog-input {
    width: 100%;
    padding: 1rem;
    background-color: #f8fafc;
    border-radius: 1rem;
    border: none;
    box-shadow: inset 0 0 0 1px #f1f5f9;
    font-weight: 700;
    outline: none;
    font-size: 0.875rem;
    color: #0f172a;
    transition: all 0.2s;
}

.fitlog-input:focus {
    box-shadow: inset 0 0 0 2px #4f46e5;
}

.fitlog-label {
    font-size: 10px;
    font-weight: 900;
    color: #94a3b8;
    text-transform: uppercase;
    letter-spacing: 0.15em;
    margin-bottom: 0.375rem;
    display: block;
    margin-left: 0.5rem;
}
