/* ====== RESET & VARIABLES (SAAS PREMIUM) ====== */
:root {
    --bg-main: #F8FAF9;
    --white: #FFFFFF;
    --green-dark: #064E3B;
    --green-main: #16A34A;
    --green-light: #DCFCE7;
    --green-suave: #22C55E;
    
    --text-main: #111827;
    --text-sec: #6B7280;
    --border: #E5E7EB;
    
    --blue: #2563EB;
    --purple: #7C3AED;
    --orange: #F97316;
    --red: #EF4444;
    --cyan: #0891B2;

    --shadow-sm: 0 1px 2px 0 rgba(0,0,0,0.05);
    --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.08), 0 2px 4px -1px rgba(0,0,0,0.04);
    --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.08), 0 4px 6px -2px rgba(0,0,0,0.04);
    
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 16px;
    --transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

[data-theme="dark"] {
    --bg-main: #0B1120;
    --white: #111827;
    --green-dark: #4ADE80;
    --green-main: #22C55E;
    --green-light: rgba(34,197,94,0.15);
    --text-main: #F9FAFB;
    --text-sec: #9CA3AF;
    --border: #1F2937;
    --shadow-sm: 0 1px 2px 0 rgba(0,0,0,0.5);
    --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.5);
    --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.5);
}

* { margin: 0; padding: 0; box-sizing: border-box; font-family: 'Inter', sans-serif; }
body { background-color: var(--bg-main); color: var(--text-main); -webkit-font-smoothing: antialiased; }
input, select, textarea, button { font-family: inherit; }

/* Utilities */
.text-muted { color: var(--text-sec); font-size: 14px; }
.flex-between { display: flex; justify-content: space-between; align-items: center; }
.flex-end { display: flex; justify-content: flex-end; align-items: center; }
.gap-2 { gap: 12px; }

/* ====== BRAND LOGO (EXACT USER REQUEST) ====== */
.main-header .header-container { display: flex; align-items: center; justify-content: space-between; gap: 20px; }
.header-left { display: flex; align-items: center; }
.brand { display: flex; align-items: center; gap: 12px; }
.brand-logo { width: 42px; height: 42px; object-fit: contain; display: block; flex-shrink: 0; }
.brand-text { display: flex; flex-direction: column; justify-content: center; }
.brand-text h1 { margin: 0; font-size: 22px; font-weight: 800; color: var(--text-main); line-height: 1.1; }
.brand-text p { margin: 2px 0 0; font-size: 13px; color: var(--text-sec); line-height: 1.2; }
@media (max-width: 640px) {
  .brand-logo { width: 34px; height: 34px; }
  .brand-text h1 { font-size: 18px; }
  .brand-text p { font-size: 11px; }
}

/* ====== BUTTONS ====== */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 10px 18px; border-radius: var(--radius-sm); font-size: 14px; font-weight: 600; cursor: pointer; transition: var(--transition); border: none; background: transparent; }
.btn-sm { padding: 6px 14px; font-size: 13px; }
.btn-block { width: 100%; }
.btn-primary { background-color: var(--green-main); color: #fff; box-shadow: 0 1px 2px rgba(22,163,74,0.2); }
.btn-primary:hover { background-color: var(--green-dark); transform: translateY(-1px); }
.btn-outline { background-color: var(--white); border: 1px solid var(--border); color: var(--text-main); }
.btn-outline:hover { background-color: var(--bg-main); border-color: var(--text-sec); }
.btn-danger { background-color: var(--red); color: white; }

/* ====== FORMS & INPUTS ====== */
.form-group { margin-bottom: 20px; width: 100%; }
.form-row { display: flex; gap: 20px; width: 100%; }
.form-row .form-group { flex: 1; }
label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 8px; color: var(--text-main); }
input[type="text"], input[type="email"], input[type="password"], input[type="url"], select, textarea { width: 100%; padding: 10px 14px; border: 1px solid var(--border); border-radius: var(--radius-sm); font-size: 14px; background: var(--white); color: var(--text-main); transition: var(--transition); outline: none; box-shadow: 0 1px 2px rgba(0,0,0,0.02) inset; }
input:focus, select:focus, textarea:focus { border-color: var(--green-main); box-shadow: 0 0 0 3px var(--green-light); }
input[type="color"] { width: 100%; height: 42px; padding: 2px; border: 1px solid var(--border); border-radius: var(--radius-sm); cursor: pointer; background: var(--white); }
.image-preview { margin-top: 8px; width: 100%; height: 120px; border-radius: var(--radius-md); border: 1px dashed var(--border); background-size: cover; background-position: center; display: flex; align-items: center; justify-content: center; background-color: var(--bg-main); color: var(--text-sec); font-size: 13px; }

/* Switches */
.switch-list { display: flex; flex-direction: column; gap: 12px; }
.switch-item { display: flex; align-items: center; gap: 12px; cursor: pointer; font-size: 14px; font-weight: 500; }
.switch-item input { display: none; }
.switch-item .slider { width: 36px; height: 20px; background: var(--border); border-radius: 20px; position: relative; transition: var(--transition); }
.switch-item .slider::before { content: ""; position: absolute; width: 16px; height: 16px; background: white; border-radius: 50%; top: 2px; left: 2px; transition: var(--transition); box-shadow: 0 1px 2px rgba(0,0,0,0.1); }
.switch-item input:checked + .slider { background: var(--green-main); }
.switch-item input:checked + .slider::before { transform: translateX(16px); }

/* ====== SYSTEM HEADER ====== */
.header { background-color: var(--white); border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 100; box-shadow: var(--shadow-sm); }
.header-container { max-width: 1400px; margin: 0 auto; padding: 14px 24px; display: flex; align-items: center; justify-content: space-between; gap: 20px; }
.header-left { display: flex; align-items: center; gap: 12px; }
.header-right { margin-left: auto; display: flex; align-items: center; justify-content: flex-end; gap: 16px; }

.profile-menu-container { position: relative; }
.profile-trigger {
    display: flex; align-items: center; gap: 10px; cursor: pointer; padding: 6px 12px 6px 6px;
    border-radius: 999px; border: 1px solid var(--border); background: var(--white); transition: var(--transition);
}
.profile-trigger:hover { background: var(--bg-main); }
.profile-avatar { width: 32px; height: 32px; border-radius: 50%; background: var(--green-light); border: 1px solid var(--border); cursor: pointer; background-size: cover; background-position: center; flex-shrink: 0; }
.profile-info { display: flex; flex-direction: column; text-align: left; }
.profile-name { font-size: 13px; font-weight: 600; color: var(--text-main); line-height: 1.2; }
.profile-email { font-size: 11px; color: var(--text-sec); line-height: 1.2; }

@media (max-width: 768px) {
    .profile-info { display: none; }
    .profile-trigger { padding: 4px; border: none; background: transparent; }
    .header-right { gap: 8px; }
}

.profile-dropdown { position: absolute; top: calc(100% + 10px); right: 0; background: var(--white); border: 1px solid var(--border); border-radius: 18px; box-shadow: 0 20px 60px rgba(15, 23, 42, 0.16); width: 220px; display: none; flex-direction: column; overflow: hidden; z-index: 999; }
.profile-dropdown.active { display: flex; }
.dropdown-header { padding: 16px; border-bottom: 1px solid var(--border); background: var(--bg-main); }
.dropdown-header h4 { font-size: 14px; margin-bottom: 2px;}
.dropdown-header p { font-size: 12px; color: var(--text-sec);}
.drop-item { display: flex; align-items: center; gap: 10px; padding: 12px 16px; font-size: 13px; font-weight: 500; color: var(--text-main); cursor: pointer; background: transparent; border: none; text-align: left; transition: var(--transition); }
.drop-item:hover { background: var(--bg-main); }
.drop-divider { height: 1px; background: var(--border); }

/* ====== MAIN DASHBOARD GRID ====== */
.main-content { max-width: 1400px; margin: 40px auto; padding: 0 24px; }
.top-section { display: flex; justify-content: space-between; align-items: flex-end; margin-bottom: 32px; flex-wrap: wrap; gap: 20px; }
.top-text h2 { font-size: 28px; font-weight: 800; letter-spacing: -0.5px; margin-bottom: 4px; }
.top-text p { font-size: 15px; color: var(--text-sec); }
.search-filter { display: flex; gap: 12px; }
.search-box { position: relative; }
.search-box i { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--text-sec); width: 16px; }
.search-box input { padding-left: 36px; width: 240px; }

.apps-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 24px; }
.app-card { background: var(--white); border-radius: var(--radius-lg); box-shadow: var(--shadow-sm); border: 1px solid var(--border); display: flex; flex-direction: column; overflow: hidden; transition: var(--transition); cursor: pointer; }
.app-card:hover { transform: translateY(-4px); box-shadow: var(--shadow-md); border-color: var(--green-main); }
.card-header { padding: 24px; display: flex; gap: 16px; align-items: center; border-bottom: 1px solid var(--border); position: relative; }
.card-logo { width: 64px; height: 64px; border-radius: var(--radius-md); object-fit: cover; border: 1px solid var(--border); background: var(--bg-main); }
.card-logo-placeholder { width: 64px; height: 64px; border-radius: var(--radius-md); background: var(--green-light); color: var(--green-dark); display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 24px; }
.card-info { flex: 1; }
.card-title { font-size: 18px; font-weight: 700; margin-bottom: 4px; color: var(--text-main); }
.card-desc { font-size: 13px; color: var(--text-sec); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.badge { font-size: 11px; padding: 4px 10px; border-radius: 20px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.5px;}
.badge-active { background: var(--green-light); color: var(--green-dark); }
.badge-draft { background: rgba(245,158,11,0.15); color: #B45309; }
.card-actions { padding: 16px 24px; background: var(--bg-main); display: flex; justify-content: space-between; align-items: center; font-size: 13px; font-weight: 500; color: var(--text-sec); }
.card-actions i { width: 16px; margin-right: 4px; }

/* ====== APP INTERNAL DASHBOARD (SAAS) ====== */
.dashboard-overlay { position: fixed; inset: 0; background: var(--bg-main); z-index: 500; display: none; height: 100vh; overflow: hidden; }
.dashboard-overlay.active { display: flex; }

/* Sidebar */
.dashboard-sidebar { width: 260px; background: var(--white); border-right: 1px solid var(--border); display: flex; flex-direction: column; z-index: 10; }
.dash-logo-area { padding: 24px 20px; display: flex; align-items: center; gap: 14px; border-bottom: 1px solid var(--border); }
.dash-logo-area img { width: 44px; height: 44px; border-radius: var(--radius-sm); object-fit: cover; border: 1px solid var(--border); }
.dash-logo-text h3 { font-size: 15px; font-weight: 700; width: 140px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-bottom: 4px;}
.dash-nav { flex: 1; overflow-y: auto; padding: 16px 0; }
.dash-nav::-webkit-scrollbar { width: 4px; }
.dash-nav::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }
.dash-nav-divider { font-size: 11px; font-weight: 700; color: var(--text-sec); padding: 24px 24px 8px; letter-spacing: 0.5px; text-transform: uppercase; }
.dash-nav-item { display: flex; align-items: center; gap: 12px; width: 100%; padding: 10px 24px; font-size: 14px; font-weight: 500; color: var(--text-sec); border: none; background: transparent; cursor: pointer; transition: var(--transition); border-right: 3px solid transparent; }
.dash-nav-item i { width: 18px; height: 18px; }
.dash-nav-item:hover { color: var(--text-main); background: var(--bg-main); }
.dash-nav-item.active { color: var(--green-dark); background: var(--green-light); border-right-color: var(--green-main); font-weight: 600; }

/* Main Area Layout */
.dashboard-main-area { flex: 1; display: flex; flex-direction: column; overflow: hidden; background: var(--bg-main); }
.dashboard-topbar { height: 72px; background: var(--white); border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; padding: 0 32px; flex-shrink: 0; box-shadow: var(--shadow-sm); z-index: 5; }
.topbar-left { display: flex; align-items: center; gap: 24px; }
.breadcrumb { font-size: 13px; color: var(--text-sec); display: flex; align-items: center; gap: 8px; }
.breadcrumb i { width: 14px; height: 14px; }
.breadcrumb strong { color: var(--text-main); font-weight: 600; }
.topbar-right { display: flex; gap: 12px; }

/* Content Wrapper & Middle Editor */
.dashboard-content-wrapper { flex: 1; display: flex; overflow: hidden; padding: 32px; gap: 32px; }
.dashboard-middle { flex: 1; overflow-y: auto; background: var(--bg-main); display: flex; flex-direction: column; }
.dashboard-middle::-webkit-scrollbar { width: 6px; }
.dashboard-middle::-webkit-scrollbar-thumb { background: #CBD5E1; border-radius: 4px; }

.dash-tab-content { display: none; max-width: 800px; margin: 0 auto; width: 100%; padding-bottom: 60px; animation: fadeIn 0.3s ease; }
.dash-tab-content.active { display: block; }
.dash-tab-content h2 { font-size: 28px; font-weight: 800; letter-spacing: -0.5px; margin-bottom: 8px; }

.saas-panel { background: var(--white); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 32px; box-shadow: var(--shadow-sm); margin-bottom: 24px; }
.saas-panel h4 { font-size: 16px; font-weight: 700; margin-bottom: 8px; }

/* Right Live Preview */
.dashboard-right-preview { width: 375px; flex-shrink: 0; background: #F9FAFB; border-radius: 40px; border: 12px solid #111827; box-shadow: var(--shadow-lg); display: flex; flex-direction: column; overflow: hidden; position: relative; height: calc(100vh - 136px); margin-top: 0; }
.live-preview-header { padding: 12px 20px; background: #111827; color: white; display: flex; justify-content: space-between; align-items: center; font-size: 11px; font-weight: 600; }
.live-preview-content { flex: 1; overflow-y: auto; background: var(--bg-main); position: relative; }
.live-preview-content::-webkit-scrollbar { display: none; }

/* Lists and Data */
.data-list { display: flex; flex-direction: column; gap: 12px; }
.data-item { background: var(--white); border: 1px solid var(--border); padding: 16px 20px; border-radius: var(--radius-md); display: flex; justify-content: space-between; align-items: center; transition: var(--transition); }
.data-item:hover { border-color: var(--green-main); box-shadow: var(--shadow-sm); }
.data-info h5 { font-size: 15px; font-weight: 600; margin-bottom: 4px; display:flex; align-items:center; gap:8px;}
.data-info p { font-size: 13px; color: var(--text-sec); }
.data-actions { display: flex; gap: 8px; }

.stats-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 20px; }
.stat-card { background: var(--white); border: 1px solid var(--border); border-radius: var(--radius-md); padding: 20px; display: flex; align-items: center; gap: 16px; box-shadow: var(--shadow-sm); }
.stat-icon { width: 48px; height: 48px; background: var(--bg-main); color: var(--text-sec); border-radius: var(--radius-md); border: 1px solid var(--border); display: flex; align-items: center; justify-content: center; }
.stat-info h4 { font-size: 13px; color: var(--text-sec); font-weight: 500; margin-bottom: 2px;}
.stat-info h2 { font-size: 24px; font-weight: 700; color: var(--text-main); }

.code-box { background: #111827; color: #10B981; padding: 16px; font-family: monospace; font-size: 13px; border-radius: var(--radius-md); margin-top: 12px; }
.tags-container { display: flex; flex-wrap: wrap; gap: 8px; }
.tag-chip { background: rgba(37,99,235,0.1); color: var(--blue); border: 1px solid rgba(37,99,235,0.2); padding: 6px 12px; border-radius: 20px; font-size: 12px; font-weight: 500; display: flex; align-items: center; gap: 6px; }

/* ====== MODALS & OVERLAYS ====== */
.modal-overlay { position: fixed; inset: 0; background: rgba(17,24,39,0.7); backdrop-filter: blur(4px); z-index: 5000; display: none; align-items: center; justify-content: center; opacity: 0; transition: opacity 0.3s; padding: 24px; }
.modal-overlay.active { display: flex; opacity: 1; }
.modal { background: var(--white); border-radius: var(--radius-lg); width: 100%; max-width: 600px; max-height: 90vh; overflow-y: auto; box-shadow: var(--shadow-lg); transform: scale(0.95); transition: transform 0.3s; border: 1px solid var(--border); }
.modal-overlay.active .modal { transform: scale(1); }
.modal-small { max-width: 480px; }
.modal-header { padding: 24px; border-bottom: 1px solid var(--border); display: flex; justify-content: space-between; align-items: center; }
.modal-header h3 { font-size: 18px; font-weight: 700; }
.modal-body { padding: 24px; }

/* ====== LOGIN SCREENS (ADMIN & STUDENT) ====== */
.login-screen,
.student-login-screen {
  min-height: 100vh;
  width: 100%;
  display: grid;
  place-items: center;
  padding: 24px;
  background: var(--bg-main);
}

.login-card,
.student-login-card {
  width: 100%;
  max-width: 460px;
  margin: 0 auto;
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: 24px;
  padding: 40px;
  box-shadow: 0 24px 70px rgba(15, 23, 42, 0.10);
  text-align: center;
}

.login-card img,
.student-login-card img {
  display: block;
  margin: 0 auto 16px auto;
  max-width: 80px;
  height: auto;
  object-fit: contain;
}

@media (max-width: 640px) {
  .login-screen,
  .student-login-screen {
    padding: 16px;
  }
  .login-card,
  .student-login-card {
    padding: 32px 24px;
    border-radius: 20px;
  }
}

/* ====== PUBLIC PREVIEW ====== */
.preview-overlay {
    position: fixed; inset: 0; background: rgba(17,24,39,0.95); z-index: 6000; display: none; overflow-y: auto;
}
.preview-overlay.active { display: grid; place-items: center; padding: 40px; }

.preview-container {
    width: 100%;
    max-width: 414px;
    height: 850px;
    max-height: 90vh;
    position: relative;
    background: var(--bg-main);
    border-radius: 40px;
    border: 12px solid #111827;
    overflow: hidden;
    box-shadow: 0 25px 50px -12px rgba(0,0,0,0.5);
    display: flex;
    flex-direction: column;
}

.btn-close-preview { position: fixed; top: 20px; right: 20px; background: rgba(255,255,255,0.1); color: white; padding: 10px 20px; border-radius: 30px; display: flex; align-items: center; gap: 8px; font-weight: 600; z-index: 7000; backdrop-filter: blur(8px); box-shadow: 0 4px 12px rgba(0,0,0,0.3); cursor: pointer; border: 1px solid rgba(255,255,255,0.2); transition: var(--transition); }
.btn-close-preview:hover { background: rgba(255,255,255,0.2); transform: scale(1.02); }

@media (max-width: 640px) {
    .preview-overlay.active { display: block; padding: 0; }
    .preview-container { max-width: 100%; height: 100vh; max-height: 100vh; border-radius: 0; border: none; }
}

/* Layout classes injected by JS for preview */
.preview-header { padding: 16px 20px; display: flex; justify-content: space-between; align-items: center; max-width: 600px; margin: 0 auto; position: sticky; top: 0; z-index: 100; }
.preview-bottom-nav { position: fixed; bottom: 0; left: 50%; transform: translateX(-50%); width: 100%; max-width: 600px; display: flex; justify-content: space-around; padding: 12px 0 24px; z-index: 100; box-shadow: 0 -4px 6px -1px rgba(0,0,0,0.05); }
.bot-nav-item { display: flex; flex-direction: column; align-items: center; gap: 4px; font-size: 11px; font-weight: 500; cursor: pointer; opacity: 0.6; }
.bot-nav-item.active { opacity: 1; }

.app-home-banner { padding: 48px 20px; text-align: center; border-radius: 0 0 32px 32px; background-size: cover; background-position: center; margin-bottom: 24px; }
.cards-scroll { display: flex; gap: 16px; overflow-x: auto; padding: 0 20px 16px; scroll-snap-type: x mandatory; }
.fast-card { min-width: 140px; padding: 16px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px; text-align: center; font-size: 13px; font-weight: 600; scroll-snap-align: start; }
.item-card { padding: 16px; display: flex; flex-direction: column; }
.item-card img { width: 100%; height: 160px; object-fit: cover; margin-bottom: 12px; }
.deliverable-item { display: flex; align-items: center; gap: 16px; padding: 12px; }

/* Toast */
.toast-container { position: fixed; top: 20px; right: 20px; z-index: 9999; display: flex; flex-direction: column; gap: 10px; }
.toast { background: var(--white); border-left: 4px solid var(--green-main); box-shadow: var(--shadow-lg); padding: 16px 20px; border-radius: var(--radius-md); display: flex; align-items: center; gap: 12px; font-size: 14px; font-weight: 600; animation: slideIn 0.3s ease, fadeOut 0.3s ease 2.7s forwards; }
@keyframes slideIn { from { transform: translateX(100%); } to { transform: translateX(0); } }
@keyframes fadeOut { to { opacity: 0; } }
