/* =============================================
   SHARED PANEL STYLES
   Common styles for Admin and Partners panels
   ============================================= */

:root {
    /* Sidebar variables - matching customer dashboard */
    --sidebar-width: 240px;
    --sidebar-collapsed-width: 64px;
    --sidebar-bg: #1e293b;
    --sidebar-hover: #334155;
    --sidebar-active: #3b82f6;
    --sidebar-text: #94a3b8;
    --sidebar-text-hover: #f1f5f9;
    --sidebar-group-text: #94a3b8;
    --sidebar-transition: 0.3s ease;
    
    /* Content area */
    --content-bg: #f9fafb;
    --card-bg: #ffffff;
    --text-primary: #111827;
    --text-secondary: #6b7280;
    --border-color: #e5e7eb;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: var(--content-bg);
    color: var(--text-primary);
    line-height: 1.6;
}

/* Layout */
.panel-layout {
    display: flex;
    min-height: 100vh;
}

/* =============================================
   SIDEBAR STYLES
   ============================================= */

.panel-sidebar {
    width: var(--sidebar-width);
    background: var(--sidebar-bg);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 100;
    overflow: hidden;
    transition: width var(--sidebar-transition);
}

.panel-sidebar.collapsed {
    width: var(--sidebar-collapsed-width);
}

/* Sidebar header */
.sidebar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem 1rem;
    border-bottom: 1px solid #334155;
    min-height: 56px;
    gap: 0.5rem;
    cursor: pointer;
    transition: background 0.2s;
}

.sidebar-header:hover {
    background: var(--sidebar-hover);
}

.sidebar-logo {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    color: white;
    font-weight: 700;
    font-size: 1rem;
    white-space: nowrap;
    overflow: hidden;
    text-decoration: none;
}

.sidebar-logo-icon {
    font-size: 1.25rem;
    flex-shrink: 0;
}

.panel-sidebar.collapsed .sidebar-logo-text {
    display: none;
}

/* Mobile close button */
.sidebar-close-mobile {
    display: none;
    background: none;
    border: none;
    color: var(--sidebar-text);
    cursor: pointer;
    padding: 0.5rem;
    border-radius: 0.375rem;
    transition: all 0.2s;
}

.sidebar-close-mobile:hover {
    color: var(--sidebar-text-hover);
    background: var(--sidebar-hover);
}

/* Sidebar navigation */
.sidebar-nav {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 1rem 0;
}

/* Scrollbar styling */
.sidebar-nav::-webkit-scrollbar {
    width: 6px;
}

.sidebar-nav::-webkit-scrollbar-track {
    background: transparent;
}

.sidebar-nav::-webkit-scrollbar-thumb {
    background: #475569;
    border-radius: 3px;
}

/* Navigation groups */
.nav-group {
    margin-bottom: 1.5rem;
}

.nav-group-label {
    padding: 0.5rem 1rem;
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--sidebar-group-text);
    white-space: nowrap;
    overflow: hidden;
}

.panel-sidebar.collapsed .nav-group-label {
    text-align: center;
    padding: 0.5rem 0;
}

.panel-sidebar.collapsed .nav-group-label-text {
    display: none;
}

.panel-sidebar.collapsed .nav-group-label::after {
    content: '•••';
    font-size: 0.5rem;
    letter-spacing: 0.1em;
}

/* Nav items */
.nav-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.625rem 1rem;
    color: var(--sidebar-text);
    text-decoration: none;
    transition: all 0.2s;
    border: none;
    background: none;
    width: 100%;
    text-align: left;
    cursor: pointer;
    font-size: 0.875rem;
}

.nav-item:hover {
    background: var(--sidebar-hover);
    color: var(--sidebar-text-hover);
}

.nav-item.active {
    background: var(--sidebar-active);
    color: white;
}

.nav-item-icon {
    font-size: 1.125rem;
    flex-shrink: 0;
    width: 24px;
    text-align: center;
}

.nav-item-text {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.panel-sidebar.collapsed .nav-item-text {
    display: none;
}

.panel-sidebar.collapsed .nav-item {
    justify-content: center;
    padding: 0.75rem;
}

/* Sidebar footer */
.sidebar-footer {
    padding: 1rem;
    border-top: 1px solid #334155;
}

.sidebar-user {
    display: flex;
    align-items: center;
    padding: 0.75rem;
    margin-bottom: 0.75rem;
    background: rgba(255,255,255,0.05);
    border-radius: 0.375rem;
}

/* Avatar hidden by default - email gets full width */
.sidebar-user .user-avatar {
    display: none;
}

.sidebar-user .user-info {
    overflow: hidden;
    flex: 1;
    min-width: 0;
}

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

.panel-sidebar.collapsed .sidebar-user {
    display: none;
}

.sidebar-footer .btn-logout {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    width: 100%;
    padding: 0.625rem 1rem;
    background: transparent;
    border: 1px solid #475569;
    border-radius: 0.375rem;
    color: var(--sidebar-text);
    font-size: 0.875rem;
    cursor: pointer;
    transition: all 0.2s;
}

.sidebar-footer .btn-logout:hover {
    background: #ef4444;
    border-color: #ef4444;
    color: white;
}

.panel-sidebar.collapsed .sidebar-footer .btn-logout span {
    display: none;
}

/* =============================================
   MAIN CONTENT AREA
   ============================================= */

.panel-content {
    flex: 1;
    margin-left: var(--sidebar-width);
    min-height: 100vh;
    transition: margin-left var(--sidebar-transition);
    padding: 1.5rem;
}

.panel-sidebar.collapsed + .panel-content,
.panel-sidebar.collapsed ~ .panel-content {
    margin-left: var(--sidebar-collapsed-width);
}

/* Page header */
.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
    gap: 1rem;
}

.page-header h1 {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-primary);
}

/* Content header - for pages with mobile menu and actions */
.content-header {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
}

.content-header h1 {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-primary);
    flex: 1;
}

.content-header .btn {
    flex-shrink: 0;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

/* Cards */
.card {
    background: var(--card-bg);
    border-radius: 0.5rem;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    padding: 1.5rem;
    margin-bottom: 1.5rem;
}

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

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

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

.stat-card {
    background: var(--card-bg);
    border-radius: 0.5rem;
    padding: 1.25rem;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.stat-card .stat-icon {
    font-size: 1.5rem;
    margin-bottom: 0.5rem;
}

.stat-card .stat-label {
    font-size: 0.75rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 0.25rem;
}

.stat-card .stat-value {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-primary);
}

.stat-card .stat-change {
    font-size: 0.75rem;
    margin-top: 0.25rem;
}

.stat-card .stat-change.positive {
    color: #10b981;
}

.stat-card .stat-change.negative {
    color: #ef4444;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    border-radius: 0.375rem;
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    border: none;
    text-decoration: none;
}

.btn-primary {
    background: #3b82f6;
    color: white;
}

.btn-primary:hover {
    background: #2563eb;
}

.btn-secondary {
    background: #e5e7eb;
    color: #374151;
}

.btn-secondary:hover {
    background: #d1d5db;
}

.btn-danger {
    background: #ef4444;
    color: white;
}

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

.btn-sm {
    padding: 0.375rem 0.75rem;
    font-size: 0.75rem;
}

.btn-success {
    background: #22c55e;
    color: white;
}

.btn-success:hover {
    background: #16a34a;
}

.btn-warning {
    background: #f59e0b;
    color: white;
}

.btn-warning:hover {
    background: #d97706;
}

.btn-outline {
    background: transparent;
    border: 1px solid var(--border-color, #e5e7eb);
    color: var(--text-primary, #374151);
}

.btn-outline:hover {
    background: #f3f4f6;
}

.btn-icon {
    padding: 0.375rem;
    min-width: auto;
    background: transparent;
    border: 1px solid var(--border-color, #e5e7eb);
    border-radius: 0.375rem;
    cursor: pointer;
}

.btn-icon:hover {
    background: #f3f4f6;
}

/* Form elements */
.form-group {
    margin-bottom: 1rem;
}

.form-label {
    display: block;
    font-size: 0.875rem;
    font-weight: 500;
    margin-bottom: 0.375rem;
    color: var(--text-primary);
}

.form-input,
.form-select,
.form-textarea {
    width: 100%;
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--border-color);
    border-radius: 0.375rem;
    font-size: 0.875rem;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
    outline: none;
    border-color: #3b82f6;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

/* Tables */
.table-container {
    overflow-x: auto;
    background: var(--card-bg);
    border-radius: 0.5rem;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

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

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

.data-table th {
    background: #f9fafb;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-secondary);
}

.data-table tbody tr:hover {
    background: #f9fafb;
}

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

/* Loading state */
.loading-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 3rem;
    color: var(--text-secondary);
}

.spinner {
    width: 2.5rem;
    height: 2.5rem;
    border: 3px solid var(--border-color);
    border-top-color: #3b82f6;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 1rem;
}

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

/* =============================================
   MOBILE RESPONSIVE
   ============================================= */

/* Mobile menu toggle button */
.mobile-menu-toggle {
    display: none;
    position: fixed;
    top: 1rem;
    left: 1rem;
    z-index: 110;
    background: var(--sidebar-bg);
    border: none;
    border-radius: 0.375rem;
    padding: 0.5rem;
    color: white;
    cursor: pointer;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

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

@media (max-width: 768px) {
    .mobile-menu-toggle {
        display: flex;
        align-items: center;
        justify-content: center;
    }
    
    .sidebar-close-mobile {
        display: block;
    }
    
    .panel-sidebar {
        transform: translateX(-100%);
        width: var(--sidebar-width);
    }
    
    .panel-sidebar.mobile-open {
        transform: translateX(0);
    }
    
    .sidebar-overlay.active {
        display: block;
    }
    
    .panel-content {
        margin-left: 0;
        padding-top: 4rem;
    }
    
    .panel-sidebar.collapsed + .panel-content,
    .panel-sidebar.collapsed ~ .panel-content {
        margin-left: 0;
    }
    
    .page-header {
        flex-direction: column;
        align-items: flex-start;
    }
    
    .stats-grid {
        grid-template-columns: 1fr;
    }
}

/* =============================================
   UTILITY CLASSES
   ============================================= */

.text-center { text-align: center; }
.text-right { text-align: right; }
.text-muted { color: var(--text-secondary); }
.text-success { color: #10b981; }
.text-danger { color: #ef4444; }
.text-warning { color: #f59e0b; }

.mt-1 { margin-top: 0.25rem; }
.mt-2 { margin-top: 0.5rem; }
.mt-3 { margin-top: 0.75rem; }
.mt-4 { margin-top: 1rem; }
.mb-1 { margin-bottom: 0.25rem; }
.mb-2 { margin-bottom: 0.5rem; }
.mb-3 { margin-bottom: 0.75rem; }
.mb-4 { margin-bottom: 1rem; }

.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-2 { gap: 0.5rem; }
.gap-4 { gap: 1rem; }

.hidden { display: none; }
.block { display: block; }

.w-full { width: 100%; }
.max-w-md { max-width: 28rem; }
.max-w-lg { max-width: 32rem; }
.max-w-xl { max-width: 36rem; }
