/* ============================================
   ZUNARIO Customer Portal - Stylesheet
   ============================================ */

/* ============ CSS Variables (matching main site) ============ */
:root {
    --primary: #8b5cf6;
    --primary-light: #a78bfa;
    --primary-dark: #7c3aed;
    --secondary: #06b6d4;
    --accent: #f59e0b;
    --success: #10b981;
    --error: #ef4444;
    --warning: #f59e0b;

    --gradient-primary: linear-gradient(135deg, #8b5cf6 0%, #06b6d4 100%);

    --bg-dark: #0a0a0f;
    --bg-darker: #050508;
    --bg-card: rgba(255, 255, 255, 0.03);
    --bg-card-hover: rgba(255, 255, 255, 0.06);
    --bg-input: rgba(255, 255, 255, 0.05);

    --text-primary: #ffffff;
    --text-secondary: rgba(255, 255, 255, 0.7);
    --text-muted: rgba(255, 255, 255, 0.5);

    --border-color: rgba(255, 255, 255, 0.1);
    --border-glow: rgba(139, 92, 246, 0.5);

    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 20px;

    --transition-fast: 0.15s ease;
    --transition-base: 0.3s ease;

    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 8px 32px rgba(0, 0, 0, 0.4);
    --shadow-glow: 0 0 40px rgba(139, 92, 246, 0.3);
}

/* ============ Reset & Base ============ */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
    font-size: 16px;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg-dark);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
}

/* ============ Background ============ */
.bg-animation {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: -1;
    overflow: hidden;
}

.gradient-orb {
    position: absolute;
    border-radius: 50%;
    filter: blur(100px);
    opacity: 0.3;
}

.orb-1 {
    width: 500px;
    height: 500px;
    background: var(--primary);
    top: -200px;
    right: -200px;
}

.orb-2 {
    width: 400px;
    height: 400px;
    background: var(--secondary);
    bottom: -150px;
    left: -150px;
}

/* ============ Typography ============ */
h1, h2, h3, h4, h5, h6 {
    font-family: 'Space Grotesk', sans-serif;
    font-weight: 700;
    line-height: 1.2;
}

h1 { font-size: 2.5rem; }
h2 { font-size: 1.75rem; }
h3 { font-size: 1.25rem; }

.gradient-text {
    background: var(--gradient-primary);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

/* ============ Layout ============ */
.portal-container {
    display: flex;
    min-height: 100vh;
}

.portal-sidebar {
    width: 260px;
    background: rgba(10, 10, 15, 0.8);
    backdrop-filter: blur(20px);
    border-right: 1px solid var(--border-color);
    padding: 24px;
    display: flex;
    flex-direction: column;
    position: fixed;
    height: 100vh;
    overflow-y: auto;
}

.portal-main {
    flex: 1;
    margin-left: 260px;
    padding: 32px;
    min-height: 100vh;
}

/* ============ Sidebar ============ */
.sidebar-logo {
    display: flex;
    align-items: center;
    gap: 12px;
    padding-bottom: 24px;
    border-bottom: 1px solid var(--border-color);
    margin-bottom: 24px;
}

.sidebar-logo img {
    height: 40px;
    width: auto;
    object-fit: contain;
}

.sidebar-logo span {
    font-family: 'Space Grotesk', sans-serif;
    font-size: 1.5rem;
    font-weight: 700;
    background: var(--gradient-primary);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.sidebar-nav {
    flex: 1;
}

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

.nav-section-title {
    font-size: 0.75rem;
    text-transform: uppercase;
    color: var(--text-muted);
    letter-spacing: 1px;
    margin-bottom: 12px;
    padding-left: 12px;
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    transition: var(--transition-fast);
    margin-bottom: 4px;
}

.nav-link:hover {
    background: var(--bg-card-hover);
    color: var(--text-primary);
}

.nav-link.active {
    background: var(--gradient-primary);
    color: white;
}

.nav-link svg {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
}

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

.user-info {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    background: var(--bg-card);
    border-radius: var(--radius-sm);
    margin-bottom: 12px;
}

.user-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--gradient-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 1rem;
}

.user-details {
    flex: 1;
    overflow: hidden;
}

.user-name {
    font-weight: 600;
    font-size: 0.9rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.user-email {
    font-size: 0.75rem;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ============ Auth Pages ============ */
.auth-container {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
}

.auth-card {
    width: 100%;
    max-width: 420px;
    background: var(--bg-card);
    backdrop-filter: blur(20px);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 40px;
}

.auth-logo {
    text-align: center;
    margin-bottom: 32px;
}

.auth-logo img {
    width: 60px;
    height: 60px;
    margin-bottom: 16px;
}

.auth-logo h1 {
    font-size: 1.5rem;
    margin-bottom: 8px;
}

.auth-logo p {
    color: var(--text-secondary);
    font-size: 0.9rem;
}

/* ============ Forms ============ */
.form-group {
    margin-bottom: 20px;
}

.form-label {
    display: block;
    margin-bottom: 8px;
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--text-secondary);
}

.form-input {
    width: 100%;
    padding: 14px 16px;
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 1rem;
    transition: var(--transition-fast);
}

.form-input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(139, 92, 246, 0.2);
}

.form-input::placeholder {
    color: var(--text-muted);
}

.form-error {
    color: var(--error);
    font-size: 0.85rem;
    margin-top: 6px;
    display: none;
}

.form-group.error .form-input {
    border-color: var(--error);
}

.form-group.error .form-error {
    display: block;
}

.form-hint {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-top: 6px;
}

/* ============ Buttons ============ */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 14px 24px;
    border-radius: var(--radius-sm);
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition-fast);
    border: none;
    text-decoration: none;
}

.btn-primary {
    background: var(--gradient-primary);
    color: white;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-glow);
}

.btn-primary:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

.btn-secondary {
    background: var(--bg-card);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
}

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

.btn-danger {
    background: var(--error);
    color: white;
}

.btn-danger:hover {
    background: #dc2626;
}

.btn-ghost {
    background: transparent;
    color: var(--text-secondary);
    padding: 8px 12px;
}

.btn-ghost:hover {
    color: var(--text-primary);
    background: var(--bg-card);
}

.btn-full {
    width: 100%;
}

.btn-sm {
    padding: 8px 16px;
    font-size: 0.875rem;
}

/* ============ Cards ============ */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 24px;
}

.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
}

.card-title {
    font-size: 1.1rem;
    font-weight: 600;
}

.card-body {
    color: var(--text-secondary);
}

/* ============ Stats Grid ============ */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
    margin-bottom: 32px;
}

.stat-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 24px;
    display: flex;
    align-items: flex-start;
    gap: 16px;
}

.stat-icon {
    width: 48px;
    height: 48px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.stat-icon.primary { background: rgba(139, 92, 246, 0.2); color: var(--primary); }
.stat-icon.success { background: rgba(16, 185, 129, 0.2); color: var(--success); }
.stat-icon.warning { background: rgba(245, 158, 11, 0.2); color: var(--warning); }
.stat-icon.secondary { background: rgba(6, 182, 212, 0.2); color: var(--secondary); }

.stat-icon svg {
    width: 24px;
    height: 24px;
}

.stat-content h3 {
    font-size: 2rem;
    font-weight: 700;
    margin-bottom: 4px;
}

.stat-content p {
    font-size: 0.9rem;
    color: var(--text-muted);
}

/* ============ Tables ============ */
.table-container {
    overflow-x: auto;
}

.table {
    width: 100%;
    border-collapse: collapse;
}

.table th,
.table td {
    padding: 14px 16px;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
}

.table th {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.table td {
    font-size: 0.95rem;
    color: var(--text-secondary);
}

.table tbody tr:hover {
    background: var(--bg-card-hover);
}

/* ============ Badges ============ */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 4px 10px;
    border-radius: 100px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
}

.badge-success {
    background: rgba(16, 185, 129, 0.2);
    color: var(--success);
}

.badge-warning {
    background: rgba(245, 158, 11, 0.2);
    color: var(--warning);
}

.badge-error {
    background: rgba(239, 68, 68, 0.2);
    color: var(--error);
}

.badge-info {
    background: rgba(6, 182, 212, 0.2);
    color: var(--secondary);
}

.badge-muted {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-muted);
}

/* ============ License Key Display ============ */
.license-key {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    background: rgba(16, 185, 129, 0.1);
    border: 1px solid rgba(16, 185, 129, 0.3);
    border-radius: var(--radius-sm);
    font-family: 'Fira Code', monospace;
    font-size: 0.9rem;
    color: var(--success);
    letter-spacing: 1px;
}

.license-key button {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 4px;
}

.license-key button:hover {
    color: var(--text-primary);
}

/* ============ Alerts ============ */
.alert {
    padding: 16px 20px;
    border-radius: var(--radius-sm);
    margin-bottom: 20px;
    display: flex;
    align-items: flex-start;
    gap: 12px;
}

.alert-success {
    background: rgba(16, 185, 129, 0.1);
    border: 1px solid rgba(16, 185, 129, 0.3);
    color: var(--success);
}

.alert-error {
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid rgba(239, 68, 68, 0.3);
    color: var(--error);
}

.alert-warning {
    background: rgba(245, 158, 11, 0.1);
    border: 1px solid rgba(245, 158, 11, 0.3);
    color: var(--warning);
}

.alert-info {
    background: rgba(6, 182, 212, 0.1);
    border: 1px solid rgba(6, 182, 212, 0.3);
    color: var(--secondary);
}

/* ============ Modal ============ */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transition: var(--transition-base);
}

.modal-overlay.active {
    opacity: 1;
    visibility: visible;
}

.modal {
    width: 100%;
    max-width: 500px;
    background: var(--bg-dark);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 32px;
    transform: scale(0.95);
    transition: var(--transition-base);
}

.modal-overlay.active .modal {
    transform: scale(1);
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 24px;
}

.modal-title {
    font-size: 1.25rem;
}

.modal-close {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 8px;
}

.modal-close:hover {
    color: var(--text-primary);
}

/* ============ Tickets ============ */
.ticket-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.ticket-item {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 16px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: var(--transition-fast);
}

.ticket-item:hover {
    background: var(--bg-card-hover);
    border-color: var(--primary);
}

.ticket-status {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
}

.ticket-status.open { background: var(--success); }
.ticket-status.in_progress { background: var(--warning); }
.ticket-status.resolved { background: var(--secondary); }
.ticket-status.closed { background: var(--text-muted); }

.ticket-info {
    flex: 1;
}

.ticket-subject {
    font-weight: 600;
    margin-bottom: 4px;
}

.ticket-meta {
    font-size: 0.85rem;
    color: var(--text-muted);
}

/* ============ Chat / Messages ============ */
.message-list {
    display: flex;
    flex-direction: column;
    gap: 16px;
    margin-bottom: 24px;
    max-height: 400px;
    overflow-y: auto;
    padding-right: 8px;
}

.message {
    padding: 16px;
    border-radius: var(--radius-sm);
    max-width: 80%;
}

.message.customer {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    margin-left: auto;
}

.message.support {
    background: rgba(139, 92, 246, 0.1);
    border: 1px solid rgba(139, 92, 246, 0.3);
}

.message-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 8px;
}

.message-sender {
    font-weight: 600;
    font-size: 0.9rem;
}

.message-time {
    font-size: 0.8rem;
    color: var(--text-muted);
}

.message-content {
    color: var(--text-secondary);
    line-height: 1.5;
}

/* ============ Empty State ============ */
.empty-state {
    text-align: center;
    padding: 60px 24px;
    color: var(--text-muted);
}

.empty-state svg {
    width: 64px;
    height: 64px;
    margin-bottom: 16px;
    opacity: 0.5;
}

.empty-state h3 {
    font-size: 1.25rem;
    color: var(--text-secondary);
    margin-bottom: 8px;
}

.empty-state p {
    margin-bottom: 24px;
}

/* ============ Loading ============ */
.loading {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 40px;
}

.spinner {
    width: 40px;
    height: 40px;
    border: 3px solid var(--border-color);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* ============ Page Header ============ */
.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 32px;
}

.page-title {
    font-size: 1.75rem;
}

.page-subtitle {
    color: var(--text-muted);
    font-size: 0.95rem;
    margin-top: 4px;
}

/* ============ Responsive ============ */
@media (max-width: 1024px) {
    .portal-sidebar {
        width: 80px;
        padding: 16px;
    }

    .portal-main {
        margin-left: 80px;
    }

    .sidebar-logo span,
    .nav-section-title,
    .nav-link span,
    .user-details {
        display: none;
    }

    .nav-link {
        justify-content: center;
    }

    .user-info {
        justify-content: center;
    }
}

@media (max-width: 768px) {
    .portal-sidebar {
        position: fixed;
        left: -260px;
        width: 260px;
        transition: var(--transition-base);
        z-index: 1001;
    }

    .portal-sidebar.active {
        left: 0;
    }

    .portal-main {
        margin-left: 0;
        padding: 16px;
    }

    .sidebar-logo span,
    .nav-section-title,
    .nav-link span,
    .user-details {
        display: block;
    }

    .nav-link {
        justify-content: flex-start;
    }

    .stats-grid {
        grid-template-columns: 1fr;
    }

    .page-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 16px;
    }

    .auth-card {
        padding: 24px;
    }
}

/* ============ Auth Links ============ */
.auth-links {
    text-align: center;
    margin-top: 24px;
    padding-top: 24px;
    border-top: 1px solid var(--border-color);
}

.auth-links p {
    color: var(--text-muted);
    font-size: 0.9rem;
}

.auth-links a {
    color: var(--primary);
    font-weight: 500;
}

.auth-links a:hover {
    text-decoration: underline;
}

.forgot-link {
    display: block;
    text-align: right;
    margin-top: 8px;
    font-size: 0.85rem;
    color: var(--text-muted);
}

.forgot-link:hover {
    color: var(--primary);
}

/* ============ Divider ============ */
.divider {
    display: flex;
    align-items: center;
    gap: 16px;
    margin: 24px 0;
    color: var(--text-muted);
    font-size: 0.85rem;
}

.divider::before,
.divider::after {
    content: '';
    flex: 1;
    height: 1px;
    background: var(--border-color);
}

/* ============ Tabs ============ */
.tabs {
    display: flex;
    gap: 8px;
    margin-bottom: 24px;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 16px;
}

.tab {
    padding: 10px 20px;
    border-radius: var(--radius-sm);
    color: var(--text-muted);
    cursor: pointer;
    transition: var(--transition-fast);
    font-weight: 500;
}

.tab:hover {
    color: var(--text-primary);
    background: var(--bg-card);
}

.tab.active {
    color: var(--text-primary);
    background: var(--gradient-primary);
}

/* ============ Language Switcher ============ */
.lang-switcher {
    position: relative;
    margin-left: auto;
}

.lang-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 12px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition-fast);
}

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

.lang-dropdown {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    min-width: 140px;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-10px);
    transition: var(--transition-fast);
    z-index: 1000;
}

.lang-dropdown.show {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.lang-option {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 10px 14px;
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 0.9rem;
    cursor: pointer;
    transition: var(--transition-fast);
}

.lang-option:hover {
    background: var(--bg-card-hover);
    color: var(--text-primary);
}

.lang-option.active {
    color: var(--primary);
    background: rgba(139, 92, 246, 0.1);
}

.lang-flag {
    font-size: 1.1rem;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 16px;
}
