/* ========================================
   Customer Portal - Exmoorweb
   ======================================== */

:root {
    --primary: #4f46e5;
    --primary-hover: #4338ca;
    --primary-light: #eef2ff;
    --success: #10b981;
    --success-light: #ecfdf5;
    --warning: #f59e0b;
    --warning-light: #fffbeb;
    --danger: #ef4444;
    --danger-light: #fef2f2;
    --info: #3b82f6;
    --info-light: #eff6ff;

    --bg: #f1f5f9;
    --surface: #ffffff;
    --text: #1e293b;
    --text-secondary: #64748b;
    --text-muted: #94a3b8;
    --border: #e2e8f0;
    --border-light: #f1f5f9;

    --sidebar-width: 260px;
    --topbar-height: 64px;
    --radius: 10px;
    --radius-sm: 6px;
    --shadow: 0 1px 3px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.06);
    --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.1), 0 2px 4px -2px rgba(0,0,0,0.1);
    --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.1), 0 4px 6px -4px rgba(0,0,0,0.1);

    --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

* { box-sizing: border-box; }

body {
    font-family: var(--font);
    background: var(--bg);
    color: var(--text);
    margin: 0;
    padding: 0;
    min-height: 100vh;
}

/* ---- Sidebar ---- */
.portal-sidebar {
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    width: var(--sidebar-width);
    background: var(--surface);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    z-index: 1040;
    transition: transform 0.3s ease;
}

.sidebar-brand {
    padding: 20px 20px 16px;
    display: flex;
    align-items: center;
    gap: 12px;
    border-bottom: 1px solid var(--border);
}

.brand-icon {
    width: 36px;
    height: 36px;
    background: var(--primary);
    color: white;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    flex-shrink: 0;
}

.brand-text {
    font-weight: 700;
    font-size: 18px;
    color: var(--text);
}

.sidebar-close {
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 18px;
    margin-left: auto;
    cursor: pointer;
    padding: 4px 8px;
}

.sidebar-nav {
    flex: 1;
    overflow-y: auto;
    padding: 12px 0;
}

.nav-section {
    margin-bottom: 8px;
}

.nav-section-title {
    display: block;
    padding: 8px 20px 4px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
}

.sidebar-nav .nav-link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 20px;
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 14px;
    font-weight: 500;
    border-left: 3px solid transparent;
    transition: all 0.15s ease;
}

.sidebar-nav .nav-link:hover {
    background: var(--primary-light);
    color: var(--primary);
}

.sidebar-nav .nav-link.active {
    background: var(--primary-light);
    color: var(--primary);
    border-left-color: var(--primary);
    font-weight: 600;
}

.sidebar-nav .nav-link i {
    width: 20px;
    text-align: center;
    font-size: 15px;
}

.sidebar-footer {
    padding: 16px 20px;
    border-top: 1px solid var(--border);
}

.customer-info {
    display: flex;
    align-items: center;
    gap: 10px;
}

.customer-avatar {
    width: 36px;
    height: 36px;
    background: var(--primary);
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 14px;
    flex-shrink: 0;
}

.customer-details {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.customer-name {
    font-weight: 600;
    font-size: 13px;
    color: var(--text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.customer-email {
    font-size: 11px;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ---- Main Content ---- */
.portal-main {
    margin-left: var(--sidebar-width);
    min-height: 100vh;
}

.portal-topbar {
    height: var(--topbar-height);
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    padding: 0 24px;
    gap: 16px;
    position: sticky;
    top: 0;
    z-index: 1020;
}

.portal-topbar h1 {
    font-size: 18px;
    font-weight: 600;
    margin: 0;
    color: var(--text);
}

.topbar-actions {
    margin-left: auto;
    display: flex;
    align-items: center;
}

.sidebar-toggle {
    background: none;
    border: none;
    font-size: 20px;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 4px;
}

.portal-content {
    padding: 24px;
    max-width: 1400px;
}

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

/* ---- Stats Cards ---- */
.stat-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
    box-shadow: var(--shadow);
    transition: box-shadow 0.2s ease, transform 0.2s ease;
}

.stat-card:hover {
    box-shadow: var(--shadow-md);
    transform: translateY(-1px);
}

.stat-card .stat-icon {
    width: 44px;
    height: 44px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    margin-bottom: 12px;
}

.stat-card .stat-icon.primary { background: var(--primary-light); color: var(--primary); }
.stat-card .stat-icon.success { background: var(--success-light); color: var(--success); }
.stat-card .stat-icon.warning { background: var(--warning-light); color: var(--warning); }
.stat-card .stat-icon.info { background: var(--info-light); color: var(--info); }
.stat-card .stat-icon.danger { background: var(--danger-light); color: var(--danger); }

.stat-card .stat-value {
    font-size: 28px;
    font-weight: 700;
    color: var(--text);
    line-height: 1.2;
}

.stat-card .stat-label {
    font-size: 13px;
    color: var(--text-secondary);
    margin-top: 2px;
}

/* ---- Cards ---- */
.portal-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    overflow: hidden;
}

.portal-card .card-header {
    padding: 16px 20px;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.portal-card .card-header h3 {
    font-size: 15px;
    font-weight: 600;
    margin: 0;
    color: var(--text);
}

.portal-card .card-body {
    padding: 20px;
}

/* ---- Tables ---- */
.portal-table {
    width: 100%;
    border-collapse: collapse;
}

.portal-table th {
    background: var(--border-light);
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-secondary);
    padding: 10px 16px;
    text-align: left;
    border-bottom: 1px solid var(--border);
}

.portal-table td {
    padding: 12px 16px;
    font-size: 14px;
    border-bottom: 1px solid var(--border-light);
    vertical-align: middle;
}

.portal-table tr:last-child td {
    border-bottom: none;
}

.portal-table tr:hover td {
    background: #fafbfc;
}

/* ---- Badges ---- */
.badge {
    font-weight: 500;
    font-size: 12px;
    padding: 4px 10px;
    border-radius: 20px;
}

/* ---- Buttons ---- */
.btn-primary {
    background: var(--primary);
    border-color: var(--primary);
}

.btn-primary:hover {
    background: var(--primary-hover);
    border-color: var(--primary-hover);
}

.btn-outline-primary {
    color: var(--primary);
    border-color: var(--primary);
}

.btn-outline-primary:hover {
    background: var(--primary);
    border-color: var(--primary);
}

/* ---- Plan Cards ---- */
.plan-card {
    background: var(--surface);
    border: 2px solid var(--border);
    border-radius: var(--radius);
    padding: 24px;
    text-align: center;
    transition: all 0.2s ease;
    cursor: pointer;
    position: relative;
}

.plan-card:hover {
    border-color: var(--primary);
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
}

.plan-card.selected {
    border-color: var(--primary);
    background: var(--primary-light);
}

.plan-card.recommended {
    border-color: var(--primary);
}

.plan-card .plan-badge {
    position: absolute;
    top: -12px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--primary);
    color: white;
    font-size: 11px;
    font-weight: 600;
    padding: 3px 12px;
    border-radius: 20px;
    white-space: nowrap;
}

.plan-card .plan-name {
    font-size: 18px;
    font-weight: 700;
    margin-bottom: 4px;
}

.plan-card .plan-price {
    font-size: 32px;
    font-weight: 700;
    color: var(--primary);
}

.plan-card .plan-price span {
    font-size: 14px;
    font-weight: 400;
    color: var(--text-secondary);
}

.plan-card .plan-hours {
    font-size: 14px;
    color: var(--text-secondary);
    margin-bottom: 16px;
}

.plan-card .plan-features {
    list-style: none;
    padding: 0;
    margin: 0;
    text-align: left;
}

.plan-card .plan-features li {
    padding: 6px 0;
    font-size: 13px;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    gap: 8px;
}

.plan-card .plan-features li i {
    color: var(--success);
    font-size: 12px;
    width: 16px;
    text-align: center;
}

/* ---- Hours Progress ---- */
.hours-progress {
    height: 8px;
    background: var(--border-light);
    border-radius: 4px;
    overflow: hidden;
    margin-top: 8px;
}

.hours-progress .bar {
    height: 100%;
    border-radius: 4px;
    transition: width 0.3s ease;
}

/* ---- Activity Timeline ---- */
.activity-item {
    display: flex;
    gap: 12px;
    padding: 12px 0;
    border-bottom: 1px solid var(--border-light);
}

.activity-item:last-child {
    border-bottom: none;
}

.activity-icon {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    flex-shrink: 0;
}

.activity-content {
    flex: 1;
    min-width: 0;
}

.activity-content p {
    margin: 0;
    font-size: 13px;
    color: var(--text);
}

.activity-content .activity-date {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 2px;
}

/* ---- Empty State ---- */
.empty-state {
    text-align: center;
    padding: 40px 20px;
    color: var(--text-secondary);
}

.empty-state i {
    font-size: 48px;
    margin-bottom: 16px;
    opacity: 0.3;
}

.empty-state h4 {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 8px;
    color: var(--text);
}

.empty-state p {
    font-size: 14px;
    max-width: 400px;
    margin: 0 auto;
}

/* ---- Forms ---- */
.form-label {
    font-weight: 500;
    font-size: 13px;
    color: var(--text);
    margin-bottom: 4px;
}

.form-control, .form-select {
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 14px;
    padding: 8px 12px;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.form-control:focus, .form-select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
}

/* ---- Subscription Detail ---- */
.sub-detail-header {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-bottom: 24px;
}

.sub-detail-header .website-favicon {
    width: 48px;
    height: 48px;
    background: var(--primary-light);
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    color: var(--primary);
}

.sub-detail-header .website-info h2 {
    font-size: 20px;
    font-weight: 600;
    margin: 0 0 4px;
}

.sub-detail-header .website-info p {
    font-size: 14px;
    color: var(--text-secondary);
    margin: 0;
}

/* ---- Responsive ---- */
@media (max-width: 991.98px) {
    .portal-sidebar {
        transform: translateX(-100%);
    }

    .portal-sidebar.open {
        transform: translateX(0);
    }

    .sidebar-overlay.show {
        display: block;
    }

    .portal-main {
        margin-left: 0;
    }

    .portal-content {
        padding: 16px;
    }
}

@media (max-width: 767.98px) {
    .stat-card .stat-value {
        font-size: 22px;
    }

    .portal-topbar h1 {
        font-size: 16px;
    }
}

/* ---- Billing / Payment Methods ---- */
.payment-method-card {
    padding: 16px 20px;
    border-bottom: 1px solid var(--border-light);
    transition: background 0.15s ease;
}

.payment-method-card:last-child {
    border-bottom: none;
}

.payment-method-card:hover {
    background: #fafbfc;
}

.payment-method-card.is-default {
    background: var(--primary-light);
    border-left: 3px solid var(--primary);
}

.pm-brand-icon {
    font-size: 32px;
    width: 48px;
    text-align: center;
    flex-shrink: 0;
}

.pm-actions {
    display: flex;
    gap: 6px;
    opacity: 0;
    transition: opacity 0.15s ease;
}

.payment-method-card:hover .pm-actions {
    opacity: 1;
}

/* Stripe Elements Mock */
.stripe-element-mock {
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 10px 12px;
    display: flex;
    align-items: center;
    gap: 10px;
    background: var(--surface);
    position: relative;
}

.stripe-element-mock:focus-within {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
}

.stripe-element-placeholder {
    color: var(--text-muted);
    font-size: 14px;
    flex: 1;
    letter-spacing: 1px;
}

.stripe-badge {
    color: var(--text-muted);
    font-size: 12px;
}

/* GoCardless Elements Mock */
.gc-element-mock {
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 10px 12px;
    display: flex;
    align-items: center;
    gap: 10px;
    background: var(--surface);
    border-left: 3px solid #00b4d8;
}

.gc-element-placeholder {
    color: var(--text-muted);
    font-size: 14px;
    letter-spacing: 1px;
}

/* Direct Debit Mandate Card */
.dd-mandate-card {
    background: var(--border-light);
    border-radius: var(--radius);
    padding: 20px;
    border: 1px solid var(--border);
}

.dd-bank-icon {
    width: 48px;
    height: 48px;
    background: linear-gradient(135deg, #e0f2fe, #bae6fd);
    color: #0284c7;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    flex-shrink: 0;
}

.dd-field {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.dd-label {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
}

.dd-value {
    font-size: 14px;
    font-weight: 500;
    color: var(--text);
}

.dd-guarantee {
    background: var(--success-light);
    border: 1px solid #bbf7d0;
    border-radius: var(--radius-sm);
    padding: 12px 16px;
}

/* GoCardless Guarantee Panel */
.gc-guarantee-panel {
    background: var(--border-light);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
}

.gc-guarantee-logo {
    display: flex;
    align-items: center;
    gap: 10px;
}

.gc-guarantee-list {
    list-style: none;
    padding: 0;
    margin: 0 0 12px;
}

.gc-guarantee-list li {
    padding: 6px 0;
    font-size: 13px;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    gap: 8px;
}

.gc-guarantee-list li i {
    color: var(--success);
    font-size: 11px;
    width: 16px;
    text-align: center;
}

/* Billing Summary */
.billing-summary-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 0;
    border-bottom: 1px solid var(--border-light);
    font-size: 13px;
    color: var(--text-secondary);
}

.billing-summary-row:last-child {
    border-bottom: none;
}

/* Help Items */
.help-item {
    display: flex;
    gap: 12px;
    padding: 10px 0;
    border-bottom: 1px solid var(--border-light);
}

.help-item:last-child {
    border-bottom: none;
}

.help-item i {
    font-size: 16px;
    width: 20px;
    text-align: center;
    margin-top: 2px;
    flex-shrink: 0;
}

.help-item strong {
    font-size: 13px;
    display: block;
    margin-bottom: 2px;
}

.help-item p {
    font-size: 12px;
    color: var(--text-muted);
    margin: 0;
    line-height: 1.5;
}

/* ═══════ Services: Domains & Hosting ═══════ */
.service-icon {
    width: 44px;
    height: 44px;
    border-radius: var(--radius);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    flex-shrink: 0;
}
.domain-icon {
    background: linear-gradient(135deg, #eef2ff, #c7d2fe);
    color: var(--primary);
}
.hosting-icon {
    background: linear-gradient(135deg, #ecfdf5, #a7f3d0);
    color: var(--success);
}
.email-icon {
    background: linear-gradient(135deg, #fef3c7, #fcd34d);
    color: #b45309;
}

/* Email config block */
.email-config-block {
    padding: 12px;
    background: var(--border-light);
    border-radius: var(--radius-sm);
}

/* DNS record type badges */
.dns-type { font-size: 11px; font-weight: 600; letter-spacing: 0.3px; }

/* Hosting quick-action buttons */
.hosting-action-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    padding: 16px 8px;
    border: 1px solid var(--border-light);
    border-radius: var(--radius);
    background: var(--surface);
    color: var(--text-primary);
    cursor: pointer;
    transition: all 0.2s;
    font-size: 12px;
    font-weight: 500;
}
.hosting-action-btn i { font-size: 20px; color: var(--primary); }
.hosting-action-btn:hover {
    background: var(--border-light);
    border-color: var(--primary);
    transform: translateY(-1px);
}

/* Domain detail fields */
.dd-field { margin-bottom: 12px; }
.dd-label { display: block; font-size: 11px; color: var(--text-muted); margin-bottom: 2px; text-transform: uppercase; letter-spacing: 0.4px; }
.dd-value { font-size: 14px; color: var(--text-primary); }
