@import url('../css/style.css');

/* Custom properties for admin area - matching main website */
:root {
  --admin-bg: var(--color-bg-warm);
  --admin-card: var(--color-bg-light);
  --admin-text: var(--color-text);
  --admin-border: var(--color-accent);
  --admin-primary: var(--color-primary);
  --admin-primary-hover: var(--color-primary);
  --admin-danger: #ef4444;
  --admin-danger-hover: #dc2626;
  --admin-success: var(--color-primary);
  --admin-accent: var(--color-accent);
}

body {
  background-color: var(--admin-bg);
  min-height: 100vh;
  margin: 0;
  padding: 0;
}

/* =========================================
   LOGIN SECTION
   ========================================= */
.login-screen {
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 100vh;
  width: 100%;
  padding: 20px;
  background-color: var(--color-bg-warm);
}

.login-card {
  background: var(--admin-card);
  border-radius: 16px;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.1), 0 8px 16px rgba(0, 0, 0, 0.06);
  padding: 48px;
  width: 100%;
  max-width: 420px;
  text-align: center;
  border: 1px solid var(--admin-border);
}

.login-header {
  margin-bottom: 32px;
}

.login-logo-img {
  height: 48px;
  width: auto;
  margin: 0 auto 20px;
  display: block;
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.1));
}

.login-header p {
  color: var(--color-text-light);
  font-size: 14px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  font-weight: 600;
  margin: 0;
}

.login-form {
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.form-group {
  text-align: left;
}

.form-group label {
  display: block;
  font-size: 14px;
  font-weight: 500;
  color: #4b5563;
  margin-bottom: 8px;
}

.form-group input {
  width: 100%;
  padding: 12px 16px;
  border: 1px solid var(--admin-border);
  border-radius: 8px;
  font-size: 16px;
  font-family: var(--font-body);
  transition: all 0.2s;
  background-color: #f8fafc;
  box-sizing: border-box;
}

.form-group input:focus {
  outline: none;
  border-color: var(--admin-primary);
  box-shadow: 0 0 0 3px rgba(91, 140, 123, 0.1);
  background-color: #fff;
}

.btn-login {
  background: linear-gradient(135deg, var(--admin-primary), var(--color-primary-dark));
  color: white;
  border: none;
  border-radius: 12px;
  padding: 16px 24px;
  font-size: 16px;
  font-weight: 600;
  font-family: var(--font-body);
  cursor: pointer;
  transition: all 0.3s ease;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 8px;
  width: 100%;
  margin-top: 12px;
  box-shadow: 0 4px 12px rgba(91, 140, 123, 0.3);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.btn-login:hover {
  background: linear-gradient(135deg, var(--color-primary-dark), var(--admin-primary));
  transform: translateY(-2px);
  box-shadow: 0 8px 20px rgba(91, 140, 123, 0.4);
}

.btn-login:active {
  transform: translateY(0);
  box-shadow: 0 2px 8px rgba(91, 140, 123, 0.3);
}

.btn-login:disabled {
  opacity: 0.7;
  cursor: not-allowed;
  transform: none;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.btn-login i {
  width: 18px;
  height: 18px;
}

.error-message {
  color: var(--admin-danger);
  font-size: 14px;
  margin-top: 12px;
  min-height: 20px;
  padding: 8px 12px;
  background: rgba(239, 68, 68, 0.1);
  border-radius: 8px;
  border: 1px solid rgba(239, 68, 68, 0.2);
  text-align: center;
}

/* =========================================
   DASHBOARD SECTION
   ========================================= */
.dashboard {
  display: flex;
  min-height: 100vh;
  background: var(--admin-bg);
  width: 100%;
}

.sidebar {
  width: 320px;
  background: var(--admin-card);
  border-right: 1px solid var(--admin-border);
  display: flex;
  flex-direction: column;
  box-shadow: 4px 0 16px rgba(0, 0, 0, 0.08);
  position: relative;
  z-index: 10;
}

.sidebar-header {
  padding: 40px 32px 32px;
  border-bottom: 1px solid var(--admin-border);
  text-align: center;
  background: linear-gradient(135deg, var(--admin-primary), var(--color-primary-dark));
  color: white;
}

.sidebar-header h2 {
  font-family: var(--font-heading);
  font-size: 28px;
  color: white;
  margin: 0 0 8px 0;
  font-weight: 600;
}

.sidebar-badge {
  display: inline-block;
  background: rgba(255, 255, 255, 0.2);
  color: white;
  padding: 6px 16px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  backdrop-filter: blur(10px);
}

.sidebar-nav {
  flex: 1;
  padding: 32px 0;
}

.sidebar-link {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 16px 32px;
  border: none;
  background: none;
  color: var(--admin-text);
  font-size: 15px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.3s ease;
  text-align: left;
  position: relative;
}

.sidebar-link::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 4px;
  background: var(--admin-primary);
  transform: scaleY(0);
  transition: transform 0.3s ease;
}

.sidebar-link:hover {
  background: rgba(91, 140, 123, 0.08);
  color: var(--admin-primary);
  padding-left: 40px;
}

.sidebar-link:hover::before {
  transform: scaleY(1);
}

.sidebar-link.active {
  background: linear-gradient(90deg, rgba(91, 140, 123, 0.1), transparent);
  color: var(--admin-primary);
  font-weight: 600;
}

.sidebar-link.active::before {
  transform: scaleY(1);
}

.sidebar-link i {
  width: 20px;
  height: 20px;
  transition: transform 0.3s ease;
}

.sidebar-link:hover i {
  transform: scale(1.1);
}

.sidebar-footer {
  padding: 32px;
  border-top: 1px solid var(--admin-border);
  background: var(--color-bg-light);
}

.btn-logout {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 16px;
  border: 2px solid var(--admin-danger);
  background: var(--admin-card);
  color: var(--admin-danger);
  border-radius: 12px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s ease;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.btn-logout:hover {
  background: var(--admin-danger);
  color: white;
  transform: translateY(-2px);
  box-shadow: 0 8px 20px rgba(239, 68, 68, 0.3);
}

.dashboard-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  background: var(--admin-bg);
}

.dashboard-topbar {
  background: var(--admin-card);
  border-bottom: 1px solid var(--admin-border);
  padding: 24px 40px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

.date-filter select {
  padding: 12px 20px;
  border: 2px solid var(--admin-border);
  border-radius: 12px;
  background: var(--admin-card);
  color: var(--admin-text);
  font-size: 15px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.3s ease;
  font-family: var(--font-body);
}

.date-filter select:hover {
  border-color: var(--admin-primary);
}

.date-filter select:focus {
  outline: none;
  border-color: var(--admin-primary);
  box-shadow: 0 0 0 3px rgba(91, 140, 123, 0.1);
}

.dashboard-content {
  flex: 1;
  padding: 40px;
  overflow-y: auto;
}

.page-title {
  font-family: var(--font-heading);
  font-size: 36px;
  color: var(--admin-text);
  margin: 0 0 40px 0;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 16px;
}

.page-title::before {
  content: '';
  width: 6px;
  height: 36px;
  background: linear-gradient(135deg, var(--admin-primary), var(--color-primary-dark));
  border-radius: 3px;
}

.tab-pane {
  display: none;
  animation: fadeIn 0.5s ease;
}

.tab-pane.active {
  display: block;
}

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 32px;
  margin-bottom: 48px;
}

.kpi-card {
  background: var(--admin-card);
  border: 1px solid var(--admin-border);
  border-radius: 20px;
  padding: 32px;
  transition: all 0.4s ease;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.08);
  position: relative;
  overflow: hidden;
}

.kpi-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 4px;
  background: linear-gradient(90deg, var(--admin-primary), var(--admin-accent));
}

.kpi-card:hover {
  transform: translateY(-8px);
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.12);
  border-color: var(--admin-primary);
}

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

.kpi-header h3 {
  font-family: var(--font-body);
  font-size: 14px;
  font-weight: 600;
  color: var(--admin-text);
  margin: 0;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  opacity: 0.8;
}

.kpi-header i {
  width: 28px;
  height: 28px;
  color: var(--admin-accent);
  background: rgba(196, 149, 106, 0.1);
  padding: 8px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.kpi-value {
  font-family: var(--font-heading);
  font-size: 42px;
  font-weight: 700;
  color: var(--admin-primary);
  margin: 0;
  line-height: 1;
  margin-bottom: 8px;
}

.kpi-card:hover .kpi-value {
  transform: scale(1.05);
  transition: transform 0.3s ease;
}

.table-container {
  background: var(--admin-card);
  border: 1px solid var(--admin-border);
  border-radius: 16px;
  overflow: hidden;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

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

.data-table th {
  background: var(--admin-bg);
  padding: 16px 24px;
  text-align: left;
  font-family: var(--font-body);
  font-size: 12px;
  font-weight: 600;
  color: var(--admin-text);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  border-bottom: 1px solid var(--admin-border);
}

.data-table td {
  padding: 16px 24px;
  font-family: var(--font-body);
  font-size: 14px;
  color: var(--admin-text);
  border-bottom: 1px solid rgba(196, 149, 106, 0.2);
}

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

.data-table tr:hover td {
  background: rgba(91, 140, 123, 0.05);
}

.scroll-stats {
  background: var(--admin-card);
  border: 1px solid var(--admin-border);
  border-radius: 16px;
  padding: 32px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

.scroll-bar-container {
  margin-bottom: 24px;
}

.scroll-bar-container:last-child {
  margin-bottom: 0;
}

.scroll-bar-label {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
  font-family: var(--font-body);
  font-size: 14px;
  font-weight: 500;
  color: var(--admin-text);
}

.scroll-bar {
  height: 8px;
  background: rgba(196, 149, 106, 0.2);
  border-radius: 4px;
  overflow: hidden;
}

.scroll-fill {
  height: 100%;
  background: var(--admin-primary);
  border-radius: 4px;
  transition: width 1s ease-out;
}

.dashboard-content {
  flex: 1;
  padding: 32px;
  max-width: 1200px;
  margin: 0 auto;
  width: 100%;
}

.dashboard-title {
  font-size: 24px;
  font-family: var(--font-heading);
  color: var(--admin-text);
  margin-bottom: 32px;
  display: flex;
  align-items: center;
  gap: 12px;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 24px;
  margin-bottom: 32px;
}

.stat-card {
  background: var(--admin-card);
  border: 1px solid var(--admin-border);
  border-radius: 12px;
  padding: 24px;
  display: flex;
  align-items: flex-start;
  gap: 16px;
  transition: transform 0.2s, box-shadow 0.2s;
}

.stat-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05), 0 2px 4px -1px rgba(0, 0, 0, 0.03);
}

.stat-icon {
  background: #f1f5f9;
  color: var(--admin-primary);
  width: 48px;
  height: 48px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.stat-info {
  flex: 1;
}

.stat-label {
  font-size: 14px;
  color: #64748b;
  margin-bottom: 4px;
  font-weight: 500;
}

.stat-value {
  font-size: 28px;
  font-weight: 600;
  color: var(--admin-text);
  line-height: 1.2;
}

/* =========================================
   VIDEO STATS SECTION
   ========================================= */
.video-stats-section {
  background: var(--admin-card);
  border: 1px solid var(--admin-border);
  border-radius: 12px;
  padding: 24px;
  margin-bottom: 32px;
}

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

.section-title {
  font-size: 18px;
  font-weight: 600;
  color: var(--admin-text);
  display: flex;
  align-items: center;
  gap: 8px;
}

.video-funnel {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.funnel-step {
  display: flex;
  align-items: center;
  gap: 16px;
}

.funnel-label {
  width: 80px;
  font-size: 14px;
  font-weight: 500;
  color: #4b5563;
}

.funnel-bar-container {
  flex: 1;
  height: 24px;
  background: #f1f5f9;
  border-radius: 4px;
  overflow: hidden;
  position: relative;
}

.funnel-bar {
  height: 100%;
  background: var(--admin-primary);
  border-radius: 4px;
  transition: width 1s ease-out;
}

.funnel-value {
  position: absolute;
  top: 50%;
  left: 12px;
  transform: translateY(-50%);
  color: white;
  font-size: 12px;
  font-weight: 600;
  text-shadow: 0 1px 2px rgba(0,0,0,0.2);
}

.funnel-value.dark-text {
  color: var(--admin-text);
  text-shadow: none;
}

.funnel-percentage {
  width: 60px;
  text-align: right;
  font-size: 14px;
  font-weight: 600;
  color: #64748b;
}

/* =========================================
   TABLE SECTION
   ========================================= */
.table-container {
  background: var(--admin-card);
  border: 1px solid var(--admin-border);
  border-radius: 12px;
  overflow: hidden;
}

.table-header {
  padding: 20px 24px;
  border-bottom: 1px solid var(--admin-border);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.table-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--admin-text);
}

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

th {
  text-align: left;
  padding: 16px 24px;
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  color: #64748b;
  border-bottom: 1px solid var(--admin-border);
  background: #f8fafc;
}

td {
  padding: 16px 24px;
  font-size: 14px;
  color: var(--admin-text);
  border-bottom: 1px solid var(--admin-border);
}

tr:last-child td {
  border-bottom: none;
}

tr:hover td {
  background-color: #f8fafc;
}

.badge {
  display: inline-flex;
  align-items: center;
  padding: 4px 8px;
  border-radius: 9999px;
  font-size: 12px;
  font-weight: 500;
}

.badge-pageview {
  background-color: #e0f2fe;
  color: #0369a1;
}

.badge-click {
  background-color: #fef3c7;
  color: #b45309;
}

.badge-video {
  background-color: #ede9fe;
  color: #5b21b6;
}

/* =========================================
   MODAL SECTION
   ========================================= */
.modal-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: rgba(0, 0, 0, 0.5);
  z-index: 100;
  justify-content: center;
  align-items: center;
  backdrop-filter: blur(4px);
}

.modal-content {
  background: var(--admin-card);
  border-radius: 12px;
  width: 100%;
  max-width: 400px;
  padding: 32px;
  box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
}

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

.modal-title {
  font-size: 18px;
  font-weight: 600;
  margin: 0;
}

.btn-close {
  background: none;
  border: none;
  color: #94a3b8;
  cursor: pointer;
  padding: 4px;
  transition: color 0.2s;
}

.btn-close:hover {
  color: var(--admin-text);
}

.modal-footer {
  margin-top: 24px;
  display: flex;
  justify-content: flex-end;
  gap: 12px;
}

.btn-text {
  background: none;
  border: none;
  color: #64748b;
  font-weight: 500;
  cursor: pointer;
  padding: 8px 16px;
  border-radius: 6px;
  transition: all 0.2s;
}

.btn-text:hover {
  background-color: #f1f5f9;
  color: var(--admin-text);
}

.spinner {
  animation: spin 1s linear infinite;
}

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

@media (max-width: 768px) {
  .dashboard {
    flex-direction: column;
  }
  
  .sidebar {
    width: 100%;
    order: 2;
  }
  
  .dashboard-main {
    order: 1;
  }
  
  .dashboard-content {
    padding: 16px;
  }
  
  .kpi-grid {
    grid-template-columns: 1fr;
    gap: 16px;
  }
  
  .table-container {
    overflow-x: auto;
  }
  
  .scroll-stats {
    padding: 16px;
  }
}
