/* Reset and Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    line-height: 1.6;
    color: #1e293b;
    background-color: #fefcfb;
}

/* CSS Custom Properties - Orange Theme */
:root {
    --primary-color: #ea580c;
    --primary-light: #f97316;
    --primary-lighter: #fb923c;
    --primary-lightest: #fdba74;
    --primary-dark: #c2410c;
    --primary-darker: #9a3412;
    
    --secondary-color: #64748b;
    --background-color: #fefcfb;
    --surface-color: #ffffff;
    --border-color: #fed7aa;
    --text-primary: #1e293b;
    --text-secondary: #64748b;
    --text-muted: #94a3b8;
    
    --success-color: #10b981;
    --danger-color: #ef4444;
    --warning-color: #f59e0b;
    
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --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);
}

/* Dashboard Layout */
.dashboard-container {
    display: grid;
    grid-template-areas: 
        "header header"
        "sidebar main";
    grid-template-columns: 250px 1fr;
    grid-template-rows: 70px 1fr;
    min-height: 100vh;
}

/* Header */
.dashboard-header {
    grid-area: header;
    background: var(--surface-color);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 2rem;
    box-shadow: var(--shadow-sm);
    overflow: hidden;
    height: 70px;
    max-height: 70px;
    min-height: 0;
}

.header-left {
    display: flex;
    align-items: center;
    overflow: hidden;
    max-width: 75%;
    flex-shrink: 1;
}

.header-left .logo {
    display: flex;
    align-items: center;
    gap: 1rem;
    overflow: hidden;
    max-width: 600px;
    flex-shrink: 1;
}

.logo-image {
    width: 120px !important;
    height: 40px !important;
    max-width: 120px;
    max-height: 40px;
    min-width: 0;
    min-height: 0;
    border-radius: 8px;
    object-fit: contain;
    object-position: center;
    transform: scale(1.1);
    transform-origin: center center;
    transition: transform 0.2s ease;
    display: block;
    flex-shrink: 0;
}


.tenant-name {
    font-size: 0.875rem;
    color: var(--text-secondary);
    font-weight: 500;
    padding: 0.25rem 0.75rem;
    background: var(--primary-lightest);
    border-radius: 1rem;
    color: var(--primary-darker);
}

.refresh-btn {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    background: var(--primary-color);
    color: white;
    border: none;
    border-radius: 0.5rem;
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    margin-left: 1rem;
    flex-shrink: 0;
}

.educational-btn {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    background: var(--primary-color);
    color: white;
    border: none;
    border-radius: 0.5rem;
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    margin-left: 0.5rem;
    flex-shrink: 0;
}

.educational-btn:hover {
    background: var(--primary-dark);
    transform: translateY(-1px);
}

.educational-btn.active {
    background: var(--primary-darker);
}

.refresh-btn:hover {
    background: var(--primary-dark);
    transform: translateY(-1px);
}

.refresh-btn:disabled {
    opacity: 0.7;
    cursor: not-allowed;
    transform: none;
}

.refresh-icon {
    font-size: 1rem;
    transition: transform 0.2s ease;
}

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

.user-profile {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.user-avatar {
    width: 2.5rem;
    height: 2.5rem;
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-light) 100%);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: 600;
    font-size: 0.875rem;
}

.user-name {
    font-weight: 500;
    color: var(--text-primary);
}

/* Sidebar */
.sidebar {
    grid-area: sidebar;
    background: var(--surface-color);
    border-right: 1px solid var(--border-color);
    padding: 1.5rem 0;
}

.sidebar-nav ul {
    list-style: none;
}

.nav-item {
    margin-bottom: 0.5rem;
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1.5rem;
    text-decoration: none;
    color: var(--text-secondary);
    transition: all 0.2s ease;
    border-right: 3px solid transparent;
}

.nav-link:hover {
    background: var(--primary-lightest);
    color: var(--primary-darker);
}

.nav-item.active .nav-link {
    background: var(--primary-lightest);
    color: var(--primary-darker);
    border-right-color: var(--primary-color);
    font-weight: 600;
}

.nav-icon {
    font-size: 1.25rem;
}

.nav-text {
    font-size: 0.875rem;
}

/* Main Content */
.main-content {
    grid-area: main;
    padding: 2rem;
    overflow-y: auto;
}

.content-header {
    margin-bottom: 2rem;
}

.content-header h1 {
    font-size: 2rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 0.5rem;
}

.content-header p {
    color: var(--text-secondary);
    font-size: 1rem;
}

/* Metrics Grid */
.metrics-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.metric-card {
    background: var(--surface-color);
    border-radius: 0.75rem;
    padding: 1.5rem;
    box-shadow: var(--shadow-md);
    border: 1px solid var(--border-color);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.metric-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

.metric-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.metric-header h3 {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.metric-icon {
    font-size: 1.5rem;
    opacity: 0.7;
}

.metric-value {
    font-size: 2.25rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 0.5rem;
}

.metric-change {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.875rem;
}

.metric-change.positive {
    color: var(--success-color);
}

.metric-change.negative {
    color: var(--danger-color);
}

.change-indicator {
    font-weight: 600;
}

.change-text {
    font-weight: 500;
}

/* Charts Section */
.charts-section {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.chart-container {
    background: var(--surface-color);
    border-radius: 0.75rem;
    padding: 1.5rem;
    box-shadow: var(--shadow-md);
    border: 1px solid var(--border-color);
}

.chart-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
}

.chart-header h3 {
    font-size: 1.125rem;
    font-weight: 600;
    color: var(--text-primary);
}

.chart-controls {
    display: flex;
    gap: 0.5rem;
}

.chart-btn {
    padding: 0.375rem 0.75rem;
    border: 1px solid var(--border-color);
    background: var(--surface-color);
    color: var(--text-secondary);
    border-radius: 0.375rem;
    font-size: 0.75rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

.chart-btn:hover {
    background: var(--primary-lightest);
    color: var(--primary-darker);
    border-color: var(--primary-lighter);
}

.chart-btn.active {
    background: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
}

.view-all-link {
    color: var(--primary-color);
    text-decoration: none;
    font-size: 0.875rem;
    font-weight: 500;
    transition: color 0.2s ease;
}

.view-all-link:hover {
    color: var(--primary-dark);
}

/* Chart Placeholder */
.chart-placeholder {
    height: 200px;
    position: relative;
}

.chart-bars {
    display: flex;
    align-items: end;
    justify-content: space-between;
    height: 160px;
    padding: 0 1rem;
    gap: 0.5rem;
}

.chart-bar {
    flex: 1;
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-light) 100%);
    border-radius: 0.25rem 0.25rem 0 0;
    min-height: 20px;
    transition: all 0.3s ease;
}

.chart-bar:hover {
    background: linear-gradient(135deg, var(--primary-light) 0%, var(--primary-lighter) 100%);
    transform: scaleY(1.05);
}

.chart-labels {
    display: flex;
    justify-content: space-between;
    padding: 0.75rem 1rem 0;
    font-size: 0.75rem;
    color: var(--text-muted);
}

/* Top Pages List */
.top-pages-list {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.page-item {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.page-info {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.page-url {
    font-weight: 500;
    color: var(--text-primary);
    font-family: 'SF Mono', Monaco, 'Cascadia Code', 'Roboto Mono', Consolas, 'Courier New', monospace;
    font-size: 0.875rem;
}

.page-views {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.page-bar {
    height: 0.5rem;
    background: var(--border-color);
    border-radius: 0.25rem;
    overflow: hidden;
}

.page-bar-fill {
    height: 100%;
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-light) 100%);
    border-radius: 0.25rem;
    transition: width 0.3s ease;
}

/* Back to Main */
.back-to-main {
    margin-top: 2rem;
    padding-top: 2rem;
    border-top: 1px solid var(--border-color);
}

.back-link {
    color: var(--primary-color);
    text-decoration: none;
    font-weight: 500;
    transition: color 0.2s ease;
}

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

/* Educational Overlay */
.educational-overlay {
    position: fixed;
    top: 70px;
    left: 0;
    width: 250px;
    height: calc(100vh - 70px);
    background: rgba(0, 0, 0, 0.8);
    z-index: 1000;
    transform: translateX(-100%);
    transition: transform 0.3s ease;
}

.educational-overlay.active {
    transform: translateX(0);
}

.educational-panel {
    width: 100%;
    height: 100%;
    background: var(--surface-color);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
}

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

.educational-header h3 {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0;
}

.educational-close {
    background: none;
    border: none;
    font-size: 1.25rem;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 0.25rem;
    border-radius: 0.25rem;
    transition: all 0.2s ease;
}

.educational-close:hover {
    background: var(--border-color);
    color: var(--text-primary);
}

.educational-content {
    flex: 1;
    padding: 1.5rem;
    overflow-y: auto;
}

.resource-item {
    margin-bottom: 1.5rem;
}

.resource-label {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 0.5rem;
}

.resource-url {
    font-family: 'SF Mono', Monaco, 'Cascadia Code', 'Roboto Mono', Consolas, 'Courier New', monospace;
    font-size: 0.75rem;
    color: var(--primary-color);
    background: var(--primary-lightest);
    padding: 0.75rem;
    border-radius: 0.5rem;
    border: 1px solid var(--primary-lighter);
    word-break: break-all;
    cursor: pointer;
    transition: all 0.2s ease;
}

.resource-url:hover {
    background: var(--primary-lighter);
    border-color: var(--primary-color);
}

.resource-url.loading {
    color: var(--text-muted);
    background: var(--border-color);
    border-color: var(--border-color);
    cursor: default;
}

/* Responsive Design */
@media (max-width: 1024px) {
    .charts-section {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 768px) {
    .dashboard-container {
        grid-template-areas: 
            "header"
            "main";
        grid-template-columns: 1fr;
        grid-template-rows: 70px 1fr;
    }
    
    .sidebar {
        display: none;
    }
    
    .main-content {
        padding: 1rem;
    }
    
    .metrics-grid {
        grid-template-columns: 1fr;
        gap: 1rem;
    }
    
    .content-header h1 {
        font-size: 1.5rem;
    }
    
    .metric-value {
        font-size: 1.75rem;
    }
    
    .chart-container {
        padding: 1rem;
    }
}

@media (max-width: 480px) {
    .dashboard-header {
        padding: 0 1rem;
    }
    
    .header-left .logo {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.25rem;
    }
    
    .logo-image {
        width: 80px !important;
        height: 24px !important;
        max-width: 80px;
        max-height: 24px;
        transform: scale(1.1);
        transform-origin: center center;
    }
    
    .tenant-name {
        font-size: 0.75rem;
    }
    
    .user-profile {
        gap: 0.5rem;
    }
    
    .user-avatar {
        width: 2rem;
        height: 2rem;
        font-size: 0.75rem;
    }
    
    .user-name {
        display: none;
    }
}
