/* ==========================================
   ROOT VARIABLES
   ========================================== */
:root {
  --primary: #1a73e8;
  --primary-dark: #1557b0;
  --primary-light: #e8f0fe;
  --secondary: #34a853;
  --danger: #ea4335;
  --warning: #fbbc04;
  --dark: #202124;
  --gray: #5f6368;
  --light-gray: #f1f3f4;
  --white: #ffffff;
  --shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
  --shadow-hover: 0 4px 20px rgba(0, 0, 0, 0.15);
  --radius: 12px;
  --transition: all 0.3s ease;
  --font-family:
    -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue",
    Arial, sans-serif;
}

/* ==========================================
   RESET & BASE
   ========================================== */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: var(--font-family);
  background: var(--light-gray);
  color: var(--dark);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ==========================================
   NAVBAR
   ========================================== */
.navbar {
  background: var(--white);
  box-shadow: var(--shadow);
  position: sticky;
  top: 0;
  z-index: 1000;
  padding: 0 1rem;
}

.nav-container {
  max-width: 1400px;
  margin: 0 auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
  min-height: 60px;
  height: auto;
  flex-wrap: wrap;
}

.nav-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  font-weight: 700;
  font-size: 1.1rem;
  color: var(--dark);
  padding: 10px 0;
}

.brand-icon {
  height: 36px;
  width: auto;
}

.brand-text {
  color: var(--primary);
}

.nav-toggle {
  display: none;
  background: none;
  border: none;
  font-size: 1.5rem;
  color: var(--dark);
  cursor: pointer;
  padding: 10px;
}

.nav-menu {
  display: flex;
  list-style: none;
  gap: 4px;
  align-items: center;
  flex-wrap: wrap;
}

.nav-item {
  margin: 0;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  border-radius: 8px;
  text-decoration: none;
  color: var(--gray);
  font-weight: 500;
  transition: var(--transition);
  font-size: 0.9rem;
  white-space: nowrap;
}

.nav-link:hover {
  background: var(--primary-light);
  color: var(--primary);
}

.nav-link.active {
  background: var(--primary);
  color: var(--white);
}

.nav-link i {
  font-size: 1rem;
  width: 18px;
}

.logout-link {
  color: var(--danger);
}

.logout-link:hover {
  background: #fce8e6;
  color: var(--danger);
}

/* ==========================================
   MAIN CONTENT
   ========================================== */
.main-content {
  flex: 1;
  max-width: 1400px;
  margin: 0 auto;
  padding: 1rem;
  width: 100%;
}

/* ==========================================
   CARDS & COMPONENTS
   ========================================== */
.card {
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.25rem;
  transition: var(--transition);
}

.card:hover {
  box-shadow: var(--shadow-hover);
}

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
  padding-bottom: 0.75rem;
  border-bottom: 2px solid var(--light-gray);
  flex-wrap: wrap;
  gap: 0.5rem;
}

.card-title {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--dark);
  margin: 0;
}

/* ==========================================
   GRID SYSTEM
   ========================================== */
.grid-2 {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1rem;
}

.grid-3 {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1rem;
}

.grid-4 {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1rem;
}

/* ==========================================
   STATS CARDS
   ========================================== */
.stat-card {
  background: var(--white);
  border-radius: var(--radius);
  padding: 1.25rem;
  box-shadow: var(--shadow);
  display: flex;
  align-items: center;
  gap: 0.75rem;
  transition: var(--transition);
}

.stat-card:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-hover);
}

.stat-icon {
  width: 48px;
  height: 48px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.25rem;
  flex-shrink: 0;
}

.stat-icon.primary {
  background: var(--primary-light);
  color: var(--primary);
}
.stat-icon.success {
  background: #e6f4ea;
  color: var(--secondary);
}
.stat-icon.warning {
  background: #fef7e0;
  color: var(--warning);
}
.stat-icon.danger {
  background: #fce8e6;
  color: var(--danger);
}

.stat-content {
  flex: 1;
  min-width: 0;
}

.stat-value {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--dark);
  line-height: 1.2;
}

.stat-label {
  font-size: 0.8rem;
  color: var(--gray);
  margin-top: 2px;
}

/* ==========================================
   TABLES - Mobile Friendly
   ========================================== */
.table-container {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  margin: 0 -0.5rem;
  padding: 0 0.5rem;
}

.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
  min-width: 600px;
}

.table th {
  text-align: left;
  padding: 10px 12px;
  background: var(--light-gray);
  font-weight: 600;
  color: var(--gray);
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  position: sticky;
  top: 0;
}

.table td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--light-gray);
  vertical-align: middle;
  word-break: break-word;
}

.table tr:hover td {
  background: #fafafa;
}

.table code {
  background: var(--light-gray);
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 0.8rem;
  word-break: break-all;
}

/* ==========================================
   FORMS - Mobile Friendly
   ========================================== */
.form-group {
  margin-bottom: 1rem;
}

.form-label {
  display: block;
  font-weight: 500;
  margin-bottom: 4px;
  color: var(--dark);
  font-size: 0.9rem;
}

.form-control {
  width: 100%;
  padding: 10px 14px;
  border: 2px solid #e0e0e0;
  border-radius: 8px;
  font-size: 1rem;
  transition: var(--transition);
  background: var(--white);
  -webkit-appearance: none;
  appearance: none;
}

.form-control:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(26, 115, 232, 0.15);
}

.form-control.error {
  border-color: var(--danger);
}

.form-control.success {
  border-color: var(--secondary);
}

.form-text {
  font-size: 0.8rem;
  color: var(--gray);
  margin-top: 4px;
}

/* ==========================================
   BUTTONS - Mobile Friendly
   ========================================== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 16px;
  border: none;
  border-radius: 8px;
  font-weight: 600;
  font-size: 0.9rem;
  cursor: pointer;
  transition: var(--transition);
  text-decoration: none;
  touch-action: manipulation;
  min-height: 40px;
  min-width: 40px;
}

.btn-primary {
  background: var(--primary);
  color: var(--white);
}

.btn-primary:hover {
  background: var(--primary-dark);
  transform: translateY(-2px);
  box-shadow: var(--shadow-hover);
}

.btn-success {
  background: var(--secondary);
  color: var(--white);
}

.btn-danger {
  background: var(--danger);
  color: var(--white);
}

.btn-outline {
  background: transparent;
  color: var(--primary);
  border: 2px solid var(--primary);
}

.btn-outline:hover {
  background: var(--primary);
  color: var(--white);
}

.btn-sm {
  padding: 4px 10px;
  font-size: 0.8rem;
  min-height: 32px;
  min-width: 32px;
}

.btn-block {
  width: 100%;
  justify-content: center;
}

/* ==========================================
   ALERTS
   ========================================== */
.alert {
  padding: 12px 16px;
  border-radius: 8px;
  margin-bottom: 1rem;
  display: flex;
  align-items: center;
  gap: 10px;
}

.alert-success {
  background: #e6f4ea;
  color: var(--secondary);
  border: 1px solid #c8e6c9;
}

.alert-error {
  background: #fce8e6;
  color: var(--danger);
  border: 1px solid #ffcdd2;
}

.alert-warning {
  background: #fef7e0;
  color: #e37400;
  border: 1px solid #ffe0b2;
}

/* ==========================================
   API RESPONSE
   ========================================== */
.api-response {
  background: #1e1e1e;
  color: #d4d4d4;
  padding: 1rem;
  border-radius: 8px;
  font-family: "Consolas", "Courier New", monospace;
  font-size: 0.85rem;
  overflow-x: auto;
  max-height: 300px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.api-response .text-muted {
  color: #888;
}

.api-response pre {
  margin: 0;
  white-space: pre-wrap;
  word-wrap: break-word;
  font-size: 0.8rem;
}

/* ==========================================
   CONFIG STATUS
   ========================================== */
.config-status {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 0.75rem;
  font-weight: 600;
}

.config-status.success {
  background: #e6f4ea;
  color: var(--secondary);
}

.config-status.warning {
  background: #fef7e0;
  color: #e37400;
}

.config-status.error {
  background: #fce8e6;
  color: var(--danger);
}

.config-status.primary {
  background: var(--primary-light);
  color: var(--primary);
}

/* ==========================================
   FOOTER
   ========================================== */
.footer {
  text-align: center;
  padding: 1.5rem;
  color: var(--gray);
  margin-top: 1rem;
  border-top: 1px solid var(--light-gray);
}

.footer-content {
  max-width: 1400px;
  margin: 0 auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.5rem;
  font-size: 0.85rem;
}

.footer-version {
  background: var(--light-gray);
  padding: 2px 10px;
  border-radius: 12px;
  font-size: 0.75rem;
}

/* ==========================================
   LOGIN PAGE
   ========================================== */
.login-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  padding: 1rem;
}

.login-container {
  background: var(--white);
  border-radius: var(--radius);
  padding: 2rem;
  width: 100%;
  max-width: 400px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
}

.login-logo {
  text-align: center;
  margin-bottom: 1.5rem;
}

.login-logo img {
  height: 50px;
  width: auto;
}

.login-title {
  text-align: center;
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--dark);
  margin-bottom: 0.25rem;
}

.login-subtitle {
  text-align: center;
  color: var(--gray);
  font-size: 0.9rem;
  margin-bottom: 1.5rem;
}

.login-error {
  background: #fce8e6;
  color: var(--danger);
  padding: 10px 14px;
  border-radius: 8px;
  margin-bottom: 1rem;
  display: none;
}

.login-error.show {
  display: block;
}

/* ==========================================
   UTILITIES
   ========================================== */
.text-center {
  text-align: center;
}
.text-muted {
  color: var(--gray);
}
.mt-1 {
  margin-top: 0.75rem;
}
.mt-2 {
  margin-top: 1.5rem;
}
.mb-1 {
  margin-bottom: 0.75rem;
}
.mb-2 {
  margin-bottom: 1.5rem;
}
.gap-1 {
  gap: 0.75rem;
}
.gap-2 {
  gap: 1.5rem;
}
.flex {
  display: flex;
}
.flex-wrap {
  flex-wrap: wrap;
}
.flex-between {
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.flex-center {
  display: flex;
  align-items: center;
  justify-content: center;
}
.flex-col {
  flex-direction: column;
}
.w-full {
  width: 100%;
}

/* ==========================================
   RESPONSIVE - Mobile First
   ========================================== */

/* Tablet and small laptop */
@media (max-width: 1024px) {
  .grid-4 {
    grid-template-columns: repeat(2, 1fr);
  }
  .grid-3 {
    grid-template-columns: repeat(2, 1fr);
  }
}

/* Tablet */
@media (max-width: 768px) {
  .nav-toggle {
    display: block;
  }

  .nav-menu {
    display: none;
    flex-direction: column;
    position: absolute;
    top: 60px;
    left: 0;
    right: 0;
    background: var(--white);
    padding: 0.75rem;
    box-shadow: var(--shadow);
    gap: 2px;
    width: 100%;
    max-height: calc(100vh - 60px);
    overflow-y: auto;
  }

  .nav-menu.active {
    display: flex;
  }

  .nav-link {
    padding: 10px 14px;
    width: 100%;
    justify-content: flex-start;
  }

  .grid-2,
  .grid-3,
  .grid-4 {
    grid-template-columns: 1fr;
  }

  .main-content {
    padding: 0.75rem;
  }

  .navbar {
    padding: 0 0.75rem;
  }

  .card {
    padding: 1rem;
  }

  .stat-card {
    padding: 1rem;
  }

  .stat-value {
    font-size: 1.3rem;
  }

  .table {
    font-size: 0.8rem;
    min-width: 500px;
  }

  .table th,
  .table td {
    padding: 8px 10px;
  }

  .login-container {
    padding: 1.5rem;
    margin: 0.5rem;
  }

  .footer-content {
    flex-direction: column;
    text-align: center;
  }
}

/* Mobile */
@media (max-width: 480px) {
  .nav-brand {
    font-size: 1rem;
  }

  .brand-icon {
    height: 30px;
  }

  .nav-link {
    font-size: 0.85rem;
    padding: 8px 12px;
  }

  .btn {
    padding: 6px 12px;
    font-size: 0.8rem;
    min-height: 36px;
  }

  .btn-sm {
    padding: 3px 8px;
    font-size: 0.7rem;
    min-height: 28px;
    min-width: 28px;
  }

  .stat-icon {
    width: 40px;
    height: 40px;
    font-size: 1rem;
  }

  .stat-value {
    font-size: 1.1rem;
  }

  .stat-label {
    font-size: 0.7rem;
  }

  .card-title {
    font-size: 1rem;
  }

  .form-control {
    padding: 8px 12px;
    font-size: 0.9rem;
  }

  .api-response {
    font-size: 0.75rem;
    padding: 0.75rem;
    max-height: 200px;
  }

  .table {
    font-size: 0.7rem;
    min-width: 400px;
  }

  .table th,
  .table td {
    padding: 6px 8px;
  }

  .table code {
    font-size: 0.7rem;
  }

  .login-title {
    font-size: 1.1rem;
  }

  .grid-2,
  .grid-3,
  .grid-4 {
    grid-template-columns: 1fr;
    gap: 0.75rem;
  }

  .main-content {
    padding: 0.5rem;
  }

  .card {
    padding: 0.75rem;
    border-radius: 8px;
  }

  .card-header {
    flex-direction: column;
    align-items: stretch;
    gap: 0.5rem;
  }

  .flex-between {
    flex-direction: column;
    align-items: stretch;
    gap: 0.5rem;
  }
}

/* Touch optimization for mobile */
@media (hover: none) {
  .btn:hover {
    transform: none;
  }

  .stat-card:hover {
    transform: none;
  }

  .card:hover {
    box-shadow: var(--shadow);
  }

  .nav-link:hover {
    background: transparent;
    color: var(--gray);
  }
}

/* Dark mode support */
@media (prefers-color-scheme: dark) {
  :root {
    --light-gray: #2d2d2d;
    --white: #1e1e1e;
    --dark: #e0e0e0;
    --gray: #aaa;
    --shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
    --shadow-hover: 0 4px 20px rgba(0, 0, 0, 0.4);
  }

  body {
    background: #121212;
  }

  .stat-card,
  .card {
    background: #1e1e1e;
  }

  .navbar {
    background: #1e1e1e;
  }

  .nav-menu {
    background: #1e1e1e;
  }

  .form-control {
    background: #2d2d2d;
    border-color: #444;
    color: #e0e0e0;
  }

  .table th {
    background: #2d2d2d;
    color: #aaa;
  }

  .table td {
    border-bottom-color: #2d2d2d;
  }

  .table tr:hover td {
    background: #252525;
  }

  .login-container {
    background: #1e1e1e;
  }
}
