/* 
 * SHANFIX CLIENT PORTAL - BRAND-ALIGNED PREMIUM DESIGN
 * Perfectly synced with Shanfix Technology core branding.
 */

:root {
    /* Main Site Brand Colors */
    --color-primary: #22c55e;
    --color-primary-dark: #16a34a;
    --color-secondary: #ef4444;      /* Red accent from site */
    --color-accent: #59e00a;         /* High-viz green from site */
    
    /* Portal Specific Extensions */
    --p: #083F0C;                   /* The deep green used in site navbar */
    --p-dark: #052607;
    --s: var(--color-primary);
    --s-dark: var(--color-primary-dark);
    --red: var(--color-secondary);
    
    /* Surface & Text */
    --bg: #f8fafc;
    --surface: #ffffff;
    --text-high: #0f172a;
    --text-mid: #475569;
    --text-low: #94a3b8;
    --border: rgba(15, 23, 42, 0.08);
    
    /* Gradients */
    --grad-p: linear-gradient(135deg, var(--p), var(--p-dark));
    --grad-s: linear-gradient(135deg, var(--s), var(--s-dark));
    --grad-accent: linear-gradient(135deg, var(--color-accent), #4ade80);
    --grad-red: linear-gradient(135deg, var(--red), #dc2626);
    
    /* Shadows & Effects */
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.1);
    --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.1), 0 2px 4px -1px rgba(0,0,0,0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.1), 0 4px 6px -2px rgba(0,0,0,0.05);
    --shadow-xl: 0 20px 25px -5px rgba(0,0,0,0.1), 0 10px 10px -5px rgba(0,0,0,0.04);
    --glass: blur(16px) saturate(180%);
}

/* --- Global Styles --- */
body.client-portal-body {
    background: var(--bg);
    background-image: 
        radial-gradient(at 100% 0%, rgba(34, 197, 94, 0.05) 0px, transparent 50%),
        radial-gradient(at 0% 100%, rgba(239, 68, 68, 0.03) 0px, transparent 50%);
    margin: 0;
    font-family: 'Inter', sans-serif;
    color: var(--text-high);
    min-height: 100vh;
}

h1, h2, h3, h4, .outfit { font-family: 'Outfit', sans-serif; font-weight: 700; }

/* --- Brand Accent Line (Sync with Top Header) --- */
body.client-portal-body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: var(--grad-accent);
    z-index: 2000;
}

/* --- Sidebar Refinement --- */
.portal-sidebar {
    width: 280px;
    background: var(--p); /* Matches site navbar */
    color: white;
    position: fixed;
    height: 100vh;
    left: 0;
    top: 0;
    z-index: 1000;
    box-shadow: 10px 0 30px rgba(0,0,0,0.1);
    display: flex;
    flex-direction: column;
}

.sidebar-logo {
    padding: 3rem 2rem;
    font-size: 1.8rem;
    font-weight: 800;
    border-bottom: 1px solid rgba(255,255,255,0.05);
}

.sidebar-logo span:last-child { color: var(--color-accent); }

.nav-item {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1.1rem 2rem;
    color: rgba(255,255,255,0.7);
    text-decoration: none;
    font-weight: 600;
    transition: all 0.3s;
    border-left: 4px solid transparent;
}

.nav-item:hover {
    color: white;
    background: rgba(255,255,255,0.05);
}

.nav-item.active {
    color: white;
    background: rgba(255,255,255,0.1);
    border-left-color: var(--color-accent);
}

.nav-item i { font-size: 1.2rem; width: 24px; text-align: center; }

/* --- Main Content Area --- */
.portal-main {
    margin-left: 280px;
    padding: 2.5rem 4rem;
}

.glass-header {
    background: rgba(255, 255, 255, 0.7);
    -webkit-backdrop-filter: var(--glass);
    backdrop-filter: var(--glass);
    border: 1px solid rgba(255, 255, 255, 0.5);
    border-radius: 24px;
    padding: 1.5rem 2.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2.5rem;
    box-shadow: var(--shadow-md);
}

.user-profile {
    display: flex;
    align-items: center;
    gap: 1.2rem;
    padding: 0.5rem 1.2rem;
    background: white;
    border-radius: 100px;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border);
}

.avatar {
    width: 44px;
    height: 44px;
    background: var(--grad-s);
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
    box-shadow: 0 4px 10px rgba(34, 197, 94, 0.3);
}

/* --- Layout Utilities --- */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 2rem;
    margin-bottom: 3rem;
}

.portal-tab-content {
    display: none;
    opacity: 0;
}

.portal-tab-content.active {
    display: block;
    opacity: 1;
}

/* --- Dashboard Components --- */
.stat-card {
    background: white;
    padding: 2.5rem;
    border-radius: 32px;
    border: 1px solid var(--border);
    box-shadow: var(--shadow-md);
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    overflow: hidden;
}

.stat-card:hover {
    transform: translateY(-8px);
    box-shadow: var(--shadow-xl);
    border-color: var(--s);
}

.stat-card::after {
    content: '';
    position: absolute;
    bottom: -20px;
    right: -20px;
    width: 100px;
    height: 100px;
    background: var(--s);
    opacity: 0.03;
    border-radius: 50%;
}

.stat-icon {
    width: 64px;
    height: 64px;
    background: rgba(34, 197, 94, 0.1);
    color: var(--s);
    border-radius: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.8rem;
    margin-bottom: 2rem;
}

.stat-value { font-size: 2.2rem; font-weight: 800; color: var(--text-high); }
.stat-label { color: var(--text-low); font-weight: 600; font-size: 0.9rem; text-transform: uppercase; letter-spacing: 1px; }

/* --- Buttons & UI Elements --- */
.portal-btn-primary {
    background: var(--grad-s);
    color: white;
    border: none;
    padding: 1.2rem 2rem;
    border-radius: 18px;
    font-weight: 700;
    cursor: pointer;
    box-shadow: 0 8px 20px -5px rgba(34, 197, 94, 0.4);
    transition: all 0.3s;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.8rem;
}

.portal-btn-primary:hover {
    transform: translateY(-3px);
    box-shadow: 0 12px 25px -5px rgba(34, 197, 94, 0.5);
    filter: brightness(1.05);
}

.portal-btn-danger {
    background: var(--grad-red);
    box-shadow: 0 8px 20px -5px rgba(239, 68, 68, 0.3);
}

.portal-btn-danger:hover {
    box-shadow: 0 12px 25px -5px rgba(239, 68, 68, 0.4);
}

/* --- Tables --- */
.data-card {
    background: white;
    border-radius: 32px;
    padding: 3rem;
    box-shadow: var(--shadow-lg);
    border: 1px solid var(--border);
    margin-bottom: 2rem;
}

.premium-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0 12px;
}

.premium-table th {
    padding: 1rem 1.5rem;
    color: var(--text-low);
    font-weight: 700;
    text-transform: uppercase;
    font-size: 0.8rem;
}

.premium-table td {
    padding: 1.5rem;
    background: #f8fafc;
    border-top: 1px solid transparent;
    border-bottom: 1px solid transparent;
    transition: all 0.2s;
}

.premium-table tr td:first-child { border-radius: 20px 0 0 20px; border-left: 1px solid transparent; }
.premium-table tr td:last-child { border-radius: 0 20px 20px 0; border-right: 1px solid transparent; }

.premium-table tr:hover td {
    background: white;
    border-color: var(--s);
    box-shadow: var(--shadow-md);
}

/* --- Badges --- */
.badge {
    padding: 8px 16px;
    border-radius: 12px;
    font-weight: 800;
    font-size: 0.75rem;
    letter-spacing: 0.5px;
}

.badge-paid { background: rgba(34, 197, 94, 0.1); color: var(--s); border: 1px solid rgba(34, 197, 94, 0.1); }
.badge-pending { background: rgba(239, 68, 68, 0.1); color: var(--red); border: 1px solid rgba(239, 68, 68, 0.1); }

/* --- Forms --- */
.form-group-premium {
    position: relative;
    margin-bottom: 2rem;
}

.form-group-premium .form-control {
    width: 100%;
    border-radius: 20px;
    padding: 1.4rem 1.5rem;
    border: 2px solid #f1f5f9;
    background: #f8fafc;
    transition: all 0.3s;
    font-size: 1rem;
    outline: none;
    box-sizing: border-box;
}

.form-group-premium label {
    position: absolute;
    left: 1.5rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-low);
    pointer-events: none;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    font-weight: 500;
}

.form-group-premium .form-control:focus + label,
.form-group-premium .form-control:not(:placeholder-shown) + label {
    transform: translateY(-2.8rem) scale(0.85);
    color: var(--s);
    font-weight: 700;
}

.form-group-premium .form-control:focus {
    border-color: var(--s);
    background: white;
    box-shadow: 0 0 0 4px rgba(34, 197, 94, 0.1);
}

/* --- Animations --- */
@keyframes slideIn {
    from { opacity: 0; transform: translateX(20px); }
    to { opacity: 1; transform: translateX(0); }
}

.portal-tab-content.active {
    animation: slideIn 0.4s ease forwards;
}

/* --- Responsive Layout --- */
@media (max-width: 1200px) {
    .portal-main { padding: 2rem; }
}

@media (max-width: 992px) {
    .portal-sidebar { transform: translateX(-100%); }
    .portal-main { margin-left: 0; }
}

/* Modal & Ticket Thread */
.portal-modal {
    display: none;
    position: fixed;
    z-index: 3000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background: rgba(8, 63, 12, 0.4);
    backdrop-filter: blur(8px);
}

.portal-modal-content {
    background: white;
    margin: 5% auto;
    border-radius: 32px;
    box-shadow: var(--shadow-xl);
    width: 90%;
    position: relative;
    overflow: hidden;
}

.portal-modal-header {
    padding: 2rem;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.portal-modal-body {
    padding: 2rem;
}

.close-modal {
    font-size: 2rem;
    border: none;
    background: none;
    cursor: pointer;
    color: var(--text-low);
}

.ticket-thread-container {
    max-height: 400px;
    overflow-y: auto;
    padding: 1.5rem;
    background: #f1f5f9;
    border-radius: 20px;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.ticket-bubble {
    max-width: 80%;
    padding: 1.2rem;
    border-radius: 20px;
    font-size: 0.95rem;
    line-height: 1.6;
}

.bubble-client {
    align-self: flex-end;
    background: var(--p);
    color: white;
    border-bottom-right-radius: 4px;
}

.bubble-admin {
    align-self: flex-start;
    background: white;
    border: 1px solid var(--border);
    border-bottom-left-radius: 4px;
    color: var(--text-high);
}

.bubble-meta {
    display: block;
    font-size: 0.75rem;
    margin-bottom: 0.6rem;
    font-weight: 600;
    opacity: 0.8;
}

.mt-20 { margin-top: 2rem; }
.mt-15 { margin-top: 1.5rem; }
