/* =====================================================
   BUTTONS
===================================================== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 20px;
    border-radius: var(--radius-md);
    font-weight: var(--weight-semibold);
    font-size: var(--text-sm);
    font-family: var(--font-body);
    transition: var(--transition-fast);
    cursor: pointer;
    border: none;
    position: relative;
    overflow: hidden;
    white-space: nowrap;
}

.btn::after {
    content: '';
    position: absolute;
    inset: 0;
    background: rgba(255,255,255,0);
    transition: background 0.2s;
    border-radius: inherit;
}
.btn:hover::after { background: rgba(255,255,255,0.08); }
.btn:active { transform: scale(0.98); }

.btn-primary {
    background: var(--primary-gradient);
    color: #fff;
    box-shadow: var(--shadow-brand);
}
.btn-primary:hover { box-shadow: 0 10px 28px rgba(241, 90, 36, 0.35); transform: translateY(-1px); }

.btn-secondary {
    background: var(--primary-50);
    color: var(--primary-brand);
    border: 1px solid var(--primary-100);
}
.btn-secondary:hover { background: var(--primary-100); }

.btn-ghost {
    color: var(--text-muted);
    background: transparent;
}
.btn-ghost:hover { background: var(--bg-main); color: var(--text-main); }

.btn-danger { background: var(--error-bg); color: var(--error); border: 1px solid var(--error-border); }
.btn-danger:hover { background: var(--error); color: #fff; }

.btn-success { background: var(--success-bg); color: var(--success); border: 1px solid var(--success-border); }
.btn-success:hover { background: var(--success); color: #fff; }

.btn-sm { padding: 7px 14px; font-size: var(--text-xs); border-radius: var(--radius-sm); }
.btn-lg { padding: 14px 28px; font-size: var(--text-base); border-radius: var(--radius-lg); }
.btn-icon { padding: 10px; border-radius: var(--radius-md); }
.btn-icon-sm { padding: 7px; border-radius: var(--radius-sm); }

.btn-loading { opacity: 0.7; pointer-events: none; }
.btn-loading .btn-spinner {
    width: 14px; height: 14px;
    border: 2px solid rgba(255,255,255,0.3);
    border-top-color: #fff;
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
}

/* =====================================================
   CARDS
===================================================== */
.card {
    background: var(--bg-white);
    border-radius: var(--radius-lg);
    padding: var(--space-6);
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border-light);
    transition: var(--transition-base);
}
.card:hover { box-shadow: var(--shadow-lg); transform: translateY(-2px); }
.card-flat { box-shadow: none; border: 1px solid var(--border-color); }
.card-flat:hover { box-shadow: var(--shadow-md); transform: translateY(-1px); }

.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: var(--space-6);
    padding-bottom: var(--space-4);
    border-bottom: 1px solid var(--border-light);
}
.card-title { font-size: var(--text-base); font-weight: var(--weight-semibold); color: var(--text-main); }
.card-subtitle { font-size: var(--text-sm); color: var(--text-muted); margin-top: 2px; }

/* =====================================================
   STAT CARDS
===================================================== */
.stat-card {
    display: flex;
    flex-direction: column;
    gap: var(--space-3);
    position: relative;
    overflow: hidden;
}
.stat-card::before {
    content: '';
    position: absolute;
    top: -20px; right: -20px;
    width: 80px; height: 80px;
    border-radius: 50%;
    background: var(--primary-gradient);
    opacity: 0.06;
    transition: var(--transition-slow);
}
.stat-card:hover::before { transform: scale(1.6); opacity: 0.1; }

.stat-icon {
    width: 44px; height: 44px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    margin-bottom: var(--space-1);
}
.stat-icon-brand   { background: var(--primary-50); color: var(--primary-brand); }
.stat-icon-green   { background: var(--success-bg); color: var(--success); }
.stat-icon-orange  { background: var(--warning-bg); color: var(--warning); }
.stat-icon-purple  { background: var(--pending-bg); color: var(--pending); }

.stat-label { font-size: var(--text-xs); color: var(--text-muted); font-weight: var(--weight-medium); text-transform: uppercase; letter-spacing: 0.06em; }
.stat-value { font-family: var(--font-heading); font-size: var(--text-2xl); font-weight: var(--weight-bold); color: var(--text-main); line-height: 1.2; }
.stat-trend { font-size: var(--text-xs); display: inline-flex; align-items: center; gap: 4px; font-weight: var(--weight-medium); padding: 3px 8px; border-radius: var(--radius-full); width: fit-content; }
.trend-up   { color: var(--success); background: var(--success-bg); }
.trend-down { color: var(--error);   background: var(--error-bg); }
.trend-flat { color: var(--text-muted); background: var(--bg-main); }

/* =====================================================
   WALLET CARD
===================================================== */
.wallet-card {
    background: var(--wallet-gradient);
    color: #fff;
    padding: var(--space-8);
    border-radius: var(--radius-xl);
    position: relative;
    overflow: hidden;
    box-shadow: var(--shadow-brand);
}
.wallet-card::before,
.wallet-card::after {
    content: '';
    position: absolute;
    border-radius: 50%;
    background: rgba(255,255,255,0.08);
}
.wallet-card::before { width: 180px; height: 180px; top: -60px; right: -40px; }
.wallet-card::after  { width: 120px; height: 120px; bottom: -40px; left: 60px; }
.wallet-chip {
    width: 40px; height: 30px;
    background: linear-gradient(135deg, #fbbf24, #f59e0b);
    border-radius: 6px;
    margin-bottom: var(--space-6);
    position: relative;
    z-index: 1;
}
.wallet-balance-label { font-size: var(--text-xs); opacity: 0.75; letter-spacing: 0.05em; text-transform: uppercase; }
.wallet-balance       { font-family: var(--font-heading); font-size: 2.2rem; font-weight: var(--weight-extrabold); letter-spacing: -0.5px; margin: 4px 0 var(--space-6); position: relative; z-index: 1; }
.wallet-info-row      { display: flex; justify-content: space-between; position: relative; z-index: 1; }
.wallet-info-item span:first-child { font-size: var(--text-2xs); opacity: 0.7; text-transform: uppercase; display: block; }
.wallet-info-item span:last-child  { font-size: var(--text-sm); font-weight: var(--weight-semibold); }

/* =====================================================
   BADGES & STATUS
===================================================== */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 4px 10px;
    border-radius: var(--radius-full);
    font-size: var(--text-xs);
    font-weight: var(--weight-semibold);
    line-height: 1;
}
.badge::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge-success  { background: var(--success-bg);  color: var(--success);  border: 1px solid var(--success-border); }
.badge-warning  { background: var(--warning-bg);  color: var(--warning);  border: 1px solid var(--warning-border); }
.badge-error    { background: var(--error-bg);    color: var(--error);    border: 1px solid var(--error-border); }
.badge-info     { background: var(--info-bg);     color: var(--info);     border: 1px solid var(--info-border); }
.badge-pending  { background: var(--pending-bg);  color: var(--pending);  border: 1px solid var(--pending-border); }
.badge-primary  { background: var(--primary-100); color: var(--primary-brand); border: 1px solid var(--primary-200); }
.badge-gray     { background: var(--bg-main);     color: var(--text-muted);   border: 1px solid var(--border-color); }

/* =====================================================
   AVATAR
===================================================== */
.avatar {
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: var(--weight-semibold);
    font-family: var(--font-heading);
    flex-shrink: 0;
    background: var(--primary-gradient);
    color: #fff;
    box-shadow: var(--shadow-sm);
}
.avatar-sm  { width: 30px; height: 30px; font-size: var(--text-xs); }
.avatar-md  { width: 38px; height: 38px; font-size: var(--text-sm); }
.avatar-lg  { width: 48px; height: 48px; font-size: var(--text-base); }
.avatar-xl  { width: 64px; height: 64px; font-size: var(--text-xl); }
.avatar-img { object-fit: cover; }

/* =====================================================
   FORMS
===================================================== */
.form-group { display: flex; flex-direction: column; gap: 6px; }
.form-row   { display: grid; grid-template-columns: 1fr 1fr; gap: var(--space-4); }

.label {
    font-size: var(--text-sm);
    font-weight: var(--weight-medium);
    color: var(--text-main);
}
.label-required::after { content: ' *'; color: var(--error); }

.input, .select-input, .textarea {
    width: 100%;
    padding: 11px 14px;
    border-radius: var(--radius-md);
    border: 1.5px solid var(--border-color);
    background: var(--bg-white);
    color: var(--text-main);
    font-size: var(--text-sm);
    transition: var(--transition-fast);
}
.input:focus, .select-input:focus, .textarea:focus {
    border-color: var(--primary-brand);
    box-shadow: 0 0 0 4px rgba(37,99,235,0.1);
}
.input::placeholder { color: var(--text-light); }
.input-error   { border-color: var(--error) !important; }
.input-success { border-color: var(--success) !important; }

.input-with-icon { position: relative; }
.input-with-icon .input { padding-left: 42px; }
.input-with-icon .input-icon { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); color: var(--text-light); font-size: 1rem; pointer-events: none; }
.input-with-icon:focus-within .input-icon { color: var(--primary-brand); }

.textarea { min-height: 100px; resize: vertical; line-height: var(--leading-relaxed); }
.select-input { cursor: pointer; appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 14px center; padding-right: 38px; }

.form-hint { font-size: var(--text-xs); color: var(--text-muted); }
.form-error-msg { font-size: var(--text-xs); color: var(--error); }

/* =====================================================
   TABLES
===================================================== */
.table-container { width: 100%; overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: var(--text-sm); }

.table th {
    padding: 12px 16px;
    background: var(--bg-main);
    color: var(--text-muted);
    font-size: var(--text-2xs);
    text-transform: uppercase;
    letter-spacing: 0.07em;
    font-weight: var(--weight-semibold);
    white-space: nowrap;
    text-align: left;
}
.table th:first-child { border-radius: var(--radius-sm) 0 0 var(--radius-sm); }
.table th:last-child  { border-radius: 0 var(--radius-sm) var(--radius-sm) 0; }

.table td {
    padding: 14px 16px;
    border-bottom: 1px solid var(--border-light);
    color: var(--text-main);
    vertical-align: middle;
}
.table tr:last-child td { border-bottom: none; }
.table tr:hover td { background: var(--primary-50); transition: background 0.15s; }

.table-actions { display: flex; gap: var(--space-2); align-items: center; }

/* =====================================================
   NOTIFICATIONS & TOASTS
===================================================== */
.toast-container { position: fixed; bottom: 24px; right: 24px; z-index: var(--z-toast); display: flex; flex-direction: column; gap: var(--space-3); pointer-events: none; }
.toast {
    pointer-events: all;
    background: var(--bg-white);
    padding: 14px 18px;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-xl);
    border: 1px solid var(--border-light);
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 300px;
    max-width: 400px;
    animation: slideInRight 0.3s ease;
    transition: opacity 0.3s, transform 0.3s;
}
.toast-icon { width: 34px; height: 34px; border-radius: var(--radius-sm); display: flex; align-items: center; justify-content: center; flex-shrink: 0; font-size: 1rem; }
.toast-body { flex: 1; }
.toast-title { font-weight: var(--weight-semibold); font-size: var(--text-sm); }
.toast-message { font-size: var(--text-xs); color: var(--text-muted); margin-top: 2px; }
.toast-close { color: var(--text-light); cursor: pointer; font-size: 1.1rem; flex-shrink: 0; transition: color 0.2s; }
.toast-close:hover { color: var(--text-main); }

.toast-success .toast-icon { background: var(--success-bg); color: var(--success); }
.toast-warning .toast-icon { background: var(--warning-bg); color: var(--warning); }
.toast-error   .toast-icon { background: var(--error-bg);   color: var(--error); }
.toast-info    .toast-icon { background: var(--info-bg);    color: var(--info); }

.toast-success { border-left: 3px solid var(--success); }
.toast-warning { border-left: 3px solid var(--warning); }
.toast-error   { border-left: 3px solid var(--error); }
.toast-info    { border-left: 3px solid var(--primary-brand); }

/* =====================================================
   NOTIFICATION DROPDOWN
===================================================== */
.notif-item {
    display: flex;
    align-items: flex-start;
    gap: var(--space-3);
    padding: var(--space-4) var(--space-6);
    border-bottom: 1px solid var(--border-light);
    transition: background 0.15s;
    cursor: pointer;
}
.notif-item:hover { background: var(--bg-main); }
.notif-item.unread { background: var(--primary-50); }
.notif-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--primary-brand); margin-top: 5px; flex-shrink: 0; }
.notif-title { font-size: var(--text-sm); font-weight: var(--weight-medium); }
.notif-time  { font-size: var(--text-xs); color: var(--text-light); margin-top: 2px; }

/* =====================================================
   LOADING SKELETON
===================================================== */
.skeleton {
    border-radius: var(--radius-sm);
    background: linear-gradient(90deg, var(--border-light) 25%, var(--bg-main) 50%, var(--border-light) 75%);
    background-size: 200% 100%;
    animation: shimmer 1.4s ease infinite;
}
.skeleton-text  { height: 14px; border-radius: var(--radius-full); }
.skeleton-title { height: 22px; border-radius: var(--radius-full); }
.skeleton-avatar{ border-radius: 50%; }
.skeleton-card  { height: 120px; border-radius: var(--radius-lg); }

/* =====================================================
   EMPTY STATE
===================================================== */
.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: var(--space-12) var(--space-6);
    text-align: center;
}
.empty-icon { font-size: 3rem; color: var(--text-light); margin-bottom: var(--space-4); opacity: 0.6; }
.empty-title { font-size: var(--text-lg); font-weight: var(--weight-semibold); margin-bottom: var(--space-2); }
.empty-desc  { font-size: var(--text-sm); color: var(--text-muted); max-width: 320px; }

/* =====================================================
   PROGRESS BAR
===================================================== */
.progress-bar { height: 6px; background: var(--border-light); border-radius: var(--radius-full); overflow: hidden; }
.progress-fill { height: 100%; border-radius: var(--radius-full); background: var(--primary-gradient); transition: width 0.6s ease; }
.progress-fill-success { background: var(--success-gradient); }
.progress-fill-warning { background: linear-gradient(135deg, #f59e0b, #fbbf24); }

/* =====================================================
   TABS
===================================================== */
.tabs { display: flex; gap: 2px; background: var(--bg-main); padding: 4px; border-radius: var(--radius-md); }
.tab-btn {
    flex: 1; padding: 8px 16px; border-radius: var(--radius-sm); font-size: var(--text-sm);
    font-weight: var(--weight-medium); color: var(--text-muted); cursor: pointer;
    transition: var(--transition-fast); background: transparent; text-align: center;
}
.tab-btn.active { background: var(--bg-white); color: var(--primary-brand); box-shadow: var(--shadow-sm); }
.tab-btn:hover:not(.active) { color: var(--text-main); }

/* =====================================================
   DROPDOWN
===================================================== */
.dropdown { position: relative; }
.dropdown-menu {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    background: var(--bg-white);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-xl);
    border: 1px solid var(--border-light);
    min-width: 180px;
    z-index: var(--z-dropdown);
    overflow: hidden;
    animation: fadeDown 0.2s ease;
}
.dropdown-menu.hidden { display: none; }
.dropdown-item {
    display: flex; align-items: center; gap: var(--space-3);
    padding: 10px var(--space-4); font-size: var(--text-sm);
    color: var(--text-main); cursor: pointer; transition: background 0.15s;
}
.dropdown-item:hover { background: var(--bg-main); }
.dropdown-item.danger { color: var(--error); }
.dropdown-item.danger:hover { background: var(--error-bg); }
.dropdown-divider { height: 1px; background: var(--border-light); margin: 4px 0; }

/* =====================================================
   MODAL
===================================================== */
.modal-backdrop {
    position: fixed; inset: 0;
    background: var(--bg-overlay);
    z-index: var(--z-modal);
    display: flex; align-items: center; justify-content: center;
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    animation: fadeIn 0.2s ease;
}
.modal-backdrop.hidden { display: none; }
.modal {
    background: var(--bg-white);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-2xl);
    max-width: 520px;
    width: 100%;
    animation: scaleIn 0.25s var(--ease-bounce);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    max-height: 90vh;
}
.modal-card { @extend .modal; } /* Backward compatibility */

.modal-header {
    display: flex; align-items: center; justify-content: space-between;
    padding: var(--space-5) var(--space-6); 
    border-bottom: 1px solid var(--border-light);
    background: var(--bg-white);
    position: sticky; top: 0; z-index: 10;
}
.modal-title { font-size: 1.1rem; font-weight: 700; color: var(--text-main); }
.modal-close { color: var(--text-light); font-size: 1.25rem; cursor: pointer; transition: color 0.15s; background: none; border: none; }
.modal-close:hover { color: var(--error); }

.modal-body { 
    padding: var(--space-6); 
    overflow-y: auto; 
    background: var(--bg-white);
}

.modal-footer { 
    padding: var(--space-4) var(--space-6); 
    border-top: 1px solid var(--border-light); 
    display: flex; gap: var(--space-3); 
    justify-content: flex-end; 
    background: var(--bg-main);
}

/* =====================================================
   AGENT / USER CARD
===================================================== */
.agent-card {
    display: flex;
    align-items: center;
    gap: var(--space-4);
    padding: var(--space-4);
    background: var(--bg-white);
    border-radius: var(--radius-md);
    border: 1px solid var(--border-light);
    transition: var(--transition-fast);
}
.agent-card:hover { border-color: var(--primary-200); box-shadow: var(--shadow-md); }
.agent-info { flex: 1; min-width: 0; }
.agent-name { font-size: var(--text-sm); font-weight: var(--weight-semibold); }
.agent-role { font-size: var(--text-xs); color: var(--text-muted); }

/* =====================================================
   NOTIFICATION BADGE (HEADER)
===================================================== */
.notif-btn-wrapper { position: relative; }
.notif-count {
    position: absolute; top: -4px; right: -4px;
    width: 18px; height: 18px;
    background: var(--error);
    color: #fff;
    border-radius: 50%;
    font-size: 10px;
    font-weight: var(--weight-bold);
    display: flex; align-items: center; justify-content: center;
    border: 2px solid var(--bg-white);
    animation: scaleIn 0.3s var(--ease-bounce);
}

/* =====================================================
   TOOLTIP
===================================================== */
[data-tooltip] { position: relative; cursor: default; }
[data-tooltip]::after {
    content: attr(data-tooltip);
    position: absolute;
    bottom: calc(100% + 8px);
    left: 50%; transform: translateX(-50%);
    background: var(--text-main);
    color: #fff;
    padding: 5px 10px;
    border-radius: var(--radius-sm);
    font-size: var(--text-xs);
    font-weight: var(--weight-medium);
    white-space: nowrap;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.2s;
    z-index: var(--z-tooltip);
}
[data-tooltip]:hover::after { opacity: 1; }

/* =====================================================
   DASHBOARD SPECIFIC COMPONENTS
   (Quick Actions, Renewal Alerts, etc.)
===================================================== */

/* Quick Actions Grid */
.quick-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
    gap: var(--space-4);
    padding: var(--space-2) 0;
}

.quick-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: var(--space-3);
    padding: var(--space-5) var(--space-2);
    background: var(--bg-main);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-lg);
    cursor: pointer;
    transition: var(--transition-base);
    text-align: center;
}

.quick-btn i {
    font-size: 1.5rem;
    color: var(--primary-brand);
    background: var(--bg-white);
    width: 48px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
    transition: var(--transition-fast);
}

.quick-btn span {
    font-size: var(--text-xs);
    font-weight: var(--weight-semibold);
    color: var(--text-main);
}

.quick-btn:hover {
    background: var(--bg-white);
    border-color: var(--primary-200);
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
}

.quick-btn:hover i {
    background: var(--primary-brand);
    color: #fff;
    transform: scale(1.1);
}

/* Renewal Items */
.renewal-item {
    display: flex;
    align-items: center;
    gap: var(--space-4);
    padding: var(--space-3) 0;
    border-bottom: 1px solid var(--border-light);
}
.renewal-item:last-child { border-bottom: none; }

.renewal-days {
    width: 38px;
    height: 38px;
    background: var(--error-bg);
    color: var(--error);
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: var(--text-xs);
    font-weight: var(--weight-bold);
    flex-shrink: 0;
}
.renewal-days.soon { background: var(--warning-bg); color: var(--warning); }

/* Commission / Volume Rows */
.comm-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: var(--space-3) 0;
    font-size: var(--text-sm);
}
.comm-row:not(:last-child) { border-bottom: 1px dashed var(--border-color); }
