/* SmartPOS AI - Partner Portal Styles */
:root {
    --primary: #6366f1;
    --primary-dark: #4f46e5;
    --primary-light: #818cf8;
    --success: #10b981;
    --success-light: #d1fae5;
    --warning: #f59e0b;
    --warning-light: #fef3c7;
    --danger: #ef4444;
    --danger-light: #fee2e2;
    --info: #3b82f6;
    --info-light: #dbeafe;
    --bg: #f8fafc;
    --bg-card: #ffffff;
    --text: #1e293b;
    --text-secondary: #64748b;
    --text-muted: #94a3b8;
    --border: #e2e8f0;
    --sidebar-bg: #1e293b;
    --sidebar-text: #cbd5e1;
    --sidebar-active: #6366f1;
    --radius: 12px;
    --radius-sm: 8px;
    --shadow: 0 1px 3px rgba(0,0,0,0.1);
    --shadow-lg: 0 4px 12px rgba(0,0,0,0.1);
}

* { margin: 0; padding: 0; box-sizing: border-box; }
body { font-family: 'Inter', -apple-system, sans-serif; background: var(--bg); color: var(--text); line-height: 1.6; }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

/* Auth Screen */
.auth-screen { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: linear-gradient(135deg, #667eea 0%, #764ba2 100%); padding: 20px; }
.auth-container { background: white; border-radius: var(--radius); padding: 40px; width: 100%; max-width: 520px; box-shadow: var(--shadow-lg); }
.auth-header { text-align: center; margin-bottom: 30px; }
.auth-header h1 { font-size: 28px; font-weight: 700; color: var(--primary); }
.auth-header p { color: var(--text-secondary); font-size: 14px; margin-top: 4px; }
.auth-form h2 { font-size: 20px; margin-bottom: 20px; }
.form-desc { color: var(--text-secondary); font-size: 14px; margin-bottom: 16px; }
.form-group { margin-bottom: 16px; }
.form-group label { display: block; font-size: 13px; font-weight: 500; color: var(--text-secondary); margin-bottom: 6px; }
.form-group input, .form-group select, .form-group textarea {
    width: 100%; padding: 10px 14px; border: 1px solid var(--border); border-radius: var(--radius-sm);
    font-size: 14px; font-family: inherit; transition: border-color 0.2s;
}
.form-group input:focus, .form-group select:focus, .form-group textarea:focus {
    outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(99,102,241,0.1);
}
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.btn-primary {
    width: 100%; padding: 12px; background: var(--primary); color: white; border: none;
    border-radius: var(--radius-sm); font-size: 15px; font-weight: 600; cursor: pointer; transition: background 0.2s;
}
.btn-primary:hover { background: var(--primary-dark); }
.btn-primary:disabled { opacity: 0.6; cursor: not-allowed; }
.auth-links { text-align: center; margin-top: 16px; font-size: 13px; }
.auth-links a { margin: 0 8px; }

/* App Layout */
.app { display: flex; min-height: 100vh; }
.sidebar {
    width: 250px; background: var(--sidebar-bg); color: var(--sidebar-text); display: flex;
    flex-direction: column; position: fixed; top: 0; left: 0; bottom: 0; z-index: 100;
    transition: transform 0.3s;
}
.sidebar-header { padding: 24px 20px; border-bottom: 1px solid rgba(255,255,255,0.1); }
.sidebar-header h2 { font-size: 18px; color: white; font-weight: 700; }
.sidebar-badge { display: inline-block; background: var(--primary); color: white; font-size: 11px; padding: 2px 8px; border-radius: 20px; margin-top: 4px; }
.sidebar-nav { flex: 1; padding: 12px 0; overflow-y: auto; }
.nav-item {
    display: flex; align-items: center; gap: 12px; padding: 10px 20px; color: var(--sidebar-text);
    font-size: 14px; transition: all 0.2s; text-decoration: none; border-left: 3px solid transparent;
}
.nav-item:hover { background: rgba(255,255,255,0.05); color: white; text-decoration: none; }
.nav-item.active { background: rgba(99,102,241,0.15); color: white; border-left-color: var(--primary); }
.nav-item svg { width: 20px; height: 20px; flex-shrink: 0; }
.sidebar-footer { padding: 16px 20px; border-top: 1px solid rgba(255,255,255,0.1); }
.btn-logout {
    width: 100%; padding: 10px; background: rgba(255,255,255,0.1); color: var(--sidebar-text);
    border: none; border-radius: var(--radius-sm); font-size: 13px; cursor: pointer; transition: background 0.2s;
}
.btn-logout:hover { background: rgba(255,255,255,0.2); color: white; }

/* Mobile header */
.mobile-header {
    display: none; position: fixed; top: 0; left: 0; right: 0; height: 56px; background: white;
    border-bottom: 1px solid var(--border); z-index: 99; align-items: center; padding: 0 16px;
    justify-content: space-between;
}
.hamburger { background: none; border: none; cursor: pointer; padding: 4px; }
.hamburger span { display: block; width: 22px; height: 2px; background: var(--text); margin: 5px 0; transition: 0.3s; }
.notification-bell { position: relative; cursor: pointer; }
.notification-bell svg { width: 22px; height: 22px; }
.badge { position: absolute; top: -6px; right: -8px; background: var(--danger); color: white; font-size: 10px; padding: 1px 5px; border-radius: 10px; }

/* Main Content */
.main-content { flex: 1; margin-left: 250px; padding: 32px; min-height: 100vh; }

/* Cards */
.page-header { margin-bottom: 24px; }
.page-header h1 { font-size: 24px; font-weight: 700; }
.page-header p { color: var(--text-secondary); font-size: 14px; margin-top: 4px; }

.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 16px; margin-bottom: 24px; }
.stat-card {
    background: var(--bg-card); border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow);
    border: 1px solid var(--border);
}
.stat-card .stat-label { font-size: 12px; font-weight: 500; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.5px; }
.stat-card .stat-value { font-size: 28px; font-weight: 700; margin-top: 4px; }
.stat-card .stat-value.text-primary { color: var(--primary); }
.stat-card .stat-value.text-success { color: var(--success); }
.stat-card .stat-value.text-warning { color: var(--warning); }

.card {
    background: var(--bg-card); border-radius: var(--radius); box-shadow: var(--shadow);
    border: 1px solid var(--border); margin-bottom: 24px;
}
.card-header { padding: 16px 20px; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; }
.card-header h3 { font-size: 16px; font-weight: 600; }
.card-body { padding: 20px; }

/* Referral Link Box */
.referral-box {
    background: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%); border-radius: var(--radius);
    padding: 24px; color: white; margin-bottom: 24px;
}
.referral-box h3 { font-size: 16px; margin-bottom: 12px; }
.referral-link-container {
    display: flex; gap: 8px; background: rgba(255,255,255,0.2); border-radius: var(--radius-sm); padding: 4px;
}
.referral-link-container input {
    flex: 1; background: transparent; border: none; color: white; font-size: 14px; padding: 8px 12px;
}
.referral-link-container input::placeholder { color: rgba(255,255,255,0.6); }
.btn-copy {
    background: white; color: var(--primary); border: none; padding: 8px 16px; border-radius: 6px;
    font-weight: 600; font-size: 13px; cursor: pointer; white-space: nowrap;
}
.btn-copy:hover { background: #f0f0ff; }

/* Tables */
.table-container { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th { text-align: left; padding: 10px 16px; font-weight: 600; color: var(--text-secondary); font-size: 12px; text-transform: uppercase; letter-spacing: 0.5px; border-bottom: 2px solid var(--border); }
td { padding: 12px 16px; border-bottom: 1px solid var(--border); }
tr:last-child td { border-bottom: none; }
tr:hover { background: var(--bg); }

/* Status Badges */
.badge-status {
    display: inline-block; padding: 3px 10px; border-radius: 20px; font-size: 12px; font-weight: 500;
}
.badge-pending { background: var(--warning-light); color: #92400e; }
.badge-approved, .badge-active, .badge-converted { background: var(--success-light); color: #065f46; }
.badge-paid, .badge-completed { background: var(--info-light); color: #1e40af; }
.badge-reversed, .badge-rejected, .badge-churned, .badge-failed { background: var(--danger-light); color: #991b1b; }
.badge-clicked, .badge-signed_up, .badge-trial, .badge-processing { background: #f3e8ff; color: #6b21a8; }

/* Buttons */
.btn { padding: 8px 16px; border-radius: var(--radius-sm); font-size: 13px; font-weight: 500; cursor: pointer; border: 1px solid var(--border); background: white; transition: all 0.2s; }
.btn:hover { background: var(--bg); }
.btn-sm { padding: 6px 12px; font-size: 12px; }
.btn-success { background: var(--success); color: white; border-color: var(--success); }
.btn-success:hover { background: #059669; }

/* Filters */
.filters { display: flex; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; align-items: center; }
.filters select, .filters input { padding: 8px 12px; border: 1px solid var(--border); border-radius: var(--radius-sm); font-size: 13px; }

/* Pagination */
.pagination { display: flex; gap: 8px; justify-content: center; align-items: center; margin-top: 16px; }
.pagination button { padding: 6px 12px; border: 1px solid var(--border); border-radius: 6px; background: white; cursor: pointer; font-size: 13px; }
.pagination button:hover { background: var(--bg); }
.pagination button.active { background: var(--primary); color: white; border-color: var(--primary); }
.pagination button:disabled { opacity: 0.4; cursor: not-allowed; }
.pagination-info { font-size: 13px; color: var(--text-secondary); }

/* Profile Form */
.profile-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.profile-section { margin-bottom: 24px; }
.profile-section h3 { font-size: 16px; font-weight: 600; margin-bottom: 12px; padding-bottom: 8px; border-bottom: 1px solid var(--border); }

/* Payout Details */
.payout-balance {
    background: linear-gradient(135deg, #10b981 0%, #059669 100%); border-radius: var(--radius);
    padding: 24px; color: white; margin-bottom: 24px; text-align: center;
}
.payout-balance .balance-label { font-size: 13px; opacity: 0.8; }
.payout-balance .balance-value { font-size: 36px; font-weight: 700; margin: 8px 0; }
.payout-balance .balance-note { font-size: 12px; opacity: 0.7; }

/* Toast */
.toast-container { position: fixed; top: 20px; right: 20px; z-index: 9999; }
.toast {
    background: var(--text); color: white; padding: 12px 20px; border-radius: var(--radius-sm);
    margin-bottom: 8px; font-size: 14px; box-shadow: var(--shadow-lg); animation: slideIn 0.3s;
    max-width: 400px;
}
.toast.success { background: var(--success); }
.toast.error { background: var(--danger); }
.toast.warning { background: var(--warning); color: var(--text); }
@keyframes slideIn { from { transform: translateX(100%); opacity: 0; } to { transform: translateX(0); opacity: 1; } }

/* Empty State */
.empty-state { text-align: center; padding: 48px 20px; color: var(--text-secondary); }
.empty-state svg { width: 48px; height: 48px; margin-bottom: 12px; opacity: 0.4; }
.empty-state p { font-size: 14px; }

/* Loading */
.spinner { display: inline-block; width: 16px; height: 16px; border: 2px solid rgba(255,255,255,0.3); border-radius: 50%; border-top-color: white; animation: spin 0.6s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.loading-placeholder { text-align: center; padding: 48px; color: var(--text-muted); }

/* Materials Grid */
.materials-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 16px; }
.material-card { background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; transition: border-color 0.2s; }
.material-card:hover { border-color: var(--primary); }
.material-card .material-type { font-size: 11px; text-transform: uppercase; letter-spacing: 0.5px; color: var(--primary); font-weight: 600; margin-bottom: 8px; }
.material-card h4 { font-size: 15px; margin-bottom: 8px; }
.material-card p { font-size: 13px; color: var(--text-secondary); margin-bottom: 12px; }
.material-card .material-meta { font-size: 12px; color: var(--text-muted); display: flex; justify-content: space-between; }

/* Responsive */
@media (max-width: 768px) {
    .sidebar { transform: translateX(-100%); }
    .sidebar.open { transform: translateX(0); }
    .mobile-header { display: flex; }
    .main-content { margin-left: 0; padding: 72px 16px 16px; }
    .stats-grid { grid-template-columns: 1fr 1fr; }
    .form-row { grid-template-columns: 1fr; }
    .profile-grid { grid-template-columns: 1fr; }
    .filters { flex-direction: column; }
    .referral-link-container { flex-direction: column; }
    .auth-container { padding: 24px; }
}

@media (max-width: 480px) {
    .stats-grid { grid-template-columns: 1fr; }
}

/* Overlay for mobile sidebar */
.sidebar-overlay { display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.5); z-index: 99; }
.sidebar-overlay.active { display: block; }
