/* ============================================================
   Nik Teacher - Core Styles (Refactored & Responsive)
   ============================================================ */

:root {
    --primary-color: #667eea;
    --primary-dark: #5a67d8;
    --secondary-color: #718096;
    --dark-color: #1A237E;
    --bg-light: #f7fafc;
    --bg-white: #ffffff;
    --border-color: #e2e8f0;
    --text-color: #2d3748;
    --text-muted: #f1f1f1;
    --success-color: #48bb78;
    --danger-color: #f56565;
    --warning-color: #ed8936;
    --border-radius: 8px;
    --transition: all 0.3s ease;
    
    /* Safe area insets for mobile */
    --safe-area-inset-top: 0px;
    --safe-area-inset-right: 0px;
    --safe-area-inset-bottom: 0px;
    --safe-area-inset-left: 0px;
}

@supports (padding: env(safe-area-inset-top)) {
    :root {
        --safe-area-inset-top: env(safe-area-inset-top);
        --safe-area-inset-right: env(safe-area-inset-right);
        --safe-area-inset-bottom: env(safe-area-inset-bottom);
        --safe-area-inset-left: env(safe-area-inset-left);
    }
}

/* ============================================================
   Base Reset & Layout
   ============================================================ */

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

html {
    scroll-behavior: smooth;
    height: 100%;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background-color: var(--bg-light);
    color: var(--text-color);
    font-size: 16px;
    line-height: 1.5;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    overflow-x: hidden;
    width: 100%;
}

main {
    flex: 1 0 auto;
    width: 100%;
    padding-bottom: 2rem;
}

/* ============================================================
   Typography (Mobile-First)
   ============================================================ */

h1, h2, h3, h4, h5, h6 {
    color: var(--dark-color);
    font-weight: 700;
    margin-bottom: 1rem;
    line-height: 1.2;
}

h1 { font-size: 1.75rem; }
h2 { font-size: 1.5rem; }
h3 { font-size: 1.25rem; }
h4 { font-size: 1.125rem; }
h5 { font-size: 1rem; }
h6 { font-size: 0.875rem; }

p {
    margin-bottom: 1rem;
}

a {
    color: var(--primary-color);
    text-decoration: none;
    transition: var(--transition);
}

a:hover {
    color: var(--primary-dark);
}

@media (min-width: 768px) {
    h1 { font-size: 2.5rem; }
    h2 { font-size: 2rem; }
    h3 { font-size: 1.75rem; }
    h4 { font-size: 1.5rem; }
}

/* ============================================================
   Navigation
   ============================================================ */

.saas-navbar {
    background: var(--bg-white) !important;
    border-bottom: 1px solid var(--border-color);
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
    padding: 0.5rem 0;
}

.navbar-brand {
    font-weight: 800;
    font-size: 1.25rem;
    color: var(--dark-color) !important;
}

.nav-link {
    font-weight: 500;
    color: var(--text-color) !important;
    padding: 0.5rem 1rem !important;
    border-radius: var(--border-radius);
    transition: var(--transition);
}

.nav-link:hover {
    background-color: rgba(102, 126, 234, 0.1);
    color: var(--primary-color) !important;
}

.nav-link.active {
    color: var(--primary-color) !important;
    background-color: rgba(102, 126, 234, 0.05);
}

/* ============================================================
   Components
   ============================================================ */

/* Cards */
.card {
    background: var(--bg-white);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    margin-bottom: 1.5rem;
    overflow: hidden;
    transition: var(--transition);
}

.card:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
}

.card-header {
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-dark) 100%);
    color: white;
    padding: 1rem 1.25rem;
    border-bottom: none;
    font-weight: 600;
}

.card-body {
    padding: 1.25rem;
}

/* Buttons */
.btn {
    font-weight: 600;
    padding: 0.625rem 1.25rem;
    border-radius: var(--border-radius);
    transition: var(--transition);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    border: none;
}

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

.btn-primary:hover {
    background-color: var(--primary-dark);
    transform: translateY(-1px);
    box-shadow: 0 4px 6px rgba(102, 126, 234, 0.25);
}

/* Forms */
.form-control, .form-select {
    border-radius: var(--border-radius);
    border: 1px solid var(--border-color);
    padding: 0.625rem 0.875rem;
    font-size: 1rem;
    transition: var(--transition);
}

.form-control:focus, .form-select:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.2);
    outline: none;
}

.form-label {
    font-weight: 600;
    margin-bottom: 0.5rem;
    color: var(--dark-color);
}

/* ============================================================
   Footer
   ============================================================ */

.saas-footer {
    background-color: #0f172a;
    color: #f2f2f3;
    padding: 4rem 0 2rem;
    margin-top: auto;
    flex-shrink: 0;
    border-top: 1px solid #1e293b;
}

.saas-footer .footer-brand {
    font-size: 1.5rem;
    font-weight: 800;
    color: #e5e5e6;
    margin-bottom: 1rem;
    display: block;
}

.saas-footer .footer-slogan {
    font-size: 0.875rem;
    color: #94a3b8;
    margin-bottom: 1.5rem;
    font-style: italic;
}

.saas-footer h6 {
    color: #f8fafc;
    font-size: 1rem;
    font-weight: 700;
    margin-bottom: 1.5rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.saas-footer ul {
    list-style: none;
    padding: 0;
    margin: 0;
}

.saas-footer ul li {
    margin-bottom: 0.75rem;
}

.saas-footer ul li a {
    color: #94a3b8;
    transition: var(--transition);
    font-size: 0.9375rem;
}

.saas-footer ul li a:hover {
    color: var(--primary-color);
    padding-left: 4px;
}

.saas-footer hr {
    border-color: #1e293b;
    opacity: 1;
}

.footer-bottom {
    padding-top: 2rem;
    font-size: 0.875rem;
    color: #64748b;
}

.made-with-love {
    color: #f43f5e;
}


/* ============================================================
   Responsive Utilities
   ============================================================ */

@media (max-width: 767px) {
    .container {
        padding-left: 1rem;
        padding-right: 1rem;
    }
    
    .btn {
        width: 100%;
        margin-bottom: 0.5rem;
    }
    
    .btn-inline {
        width: auto;
        margin-bottom: 0;
    }
}

/* ============================================================
   Specific Module Styles
   ============================================================ */

/* Stat Boxes */
.stat-box {
    padding: 1.5rem;
    border-radius: var(--border-radius);
    background: white;
    border: 1px solid var(--border-color);
    text-align: center;
    height: 100%;
}

.stat-number {
    font-size: 2rem;
    font-weight: 800;
    color: var(--primary-color);
    display: block;
    margin-bottom: 0.25rem;
}

.stat-label {
    color: var(--text-muted);
    font-weight: 600;
    text-transform: uppercase;
    font-size: 0.75rem;
    letter-spacing: 0.05em;
}

/* AI Tutor Chat Button */
.floating-chat-btn {
    position: fixed;
    bottom: max(20px, calc(20px + var(--safe-area-inset-bottom)));
    right: max(20px, calc(20px + var(--safe-area-inset-right)));
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-dark) 100%);
    color: white;
    border: none;
    font-size: 24px;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(0,123,255,0.4);
    transition: all 0.3s ease;
    z-index: 999;
    display: flex;
    align-items: center;
    justify-content: center;
}

.chat-modal {
    position: fixed;
    bottom: max(100px, calc(100px + var(--safe-area-inset-bottom)));
    right: max(20px, calc(20px + var(--safe-area-inset-right)));
    width: 380px;
    max-height: 60vh;
    background: white;
    box-shadow: 0 10px 25px rgba(0,0,0,0.15);
    display: none;
    flex-direction: column;
    z-index: 1000;
    border: 1px solid var(--border-color);
    overflow: hidden;
}

@media (max-width: 480px) {
    .chat-modal {
        width: calc(100% - 40px);
        right: 20px;
        bottom: 90px;
    }
}

.chat-header {
    background: var(--primary-color);
    color: white;
    padding: 0.75rem 1rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 1rem;
    background: #f8f9fa;
}

.message {
    margin-bottom: 1rem;
    max-width: 85%;
}

.message-content {
    padding: 0.75rem;
    border-radius: var(--border-radius);
    font-size: 0.9rem;
}

.ai-message .message-content {
    background: white;
    border: 1px solid var(--border-color);
}

.user-message {
    margin-left: auto;
}

.user-message .message-content {
    background: var(--primary-color);
    color: white;
}

.chat-footer {
    padding: 0.75rem;
    border-top: 1px solid var(--border-color);
    background: white;
}

.chat-footer-links {
    padding: 0.5rem;
    text-align: center;
    border-top: 1px solid var(--border-color);
    background: #f8f9fa;
    font-size: 0.75rem;
}

