/* ==== Base Design System & CSS Variables ==== */
:root {
  --primary: #4caf50;
  --primary-hover: #45a049;
  --primary-light: rgba(76, 175, 80, 0.1);

  --win: #4caf50;
  --loss: #f44336;
  --void: #9e9e9e;
  --pending: #ff9800;

  --bg-main: #f4f6f9;
  --bg-card: #ffffff;
  --bg-sidebar: #1e1e2d;
  --bg-sidebar-hover: #2b2b40;

  --text-main: #333333;
  --text-muted: #888888;
  --text-light: #ffffff;

  --border: #e0e0e0;

  --radius: 8px;
  --radius-lg: 16px;
  --shadow: 0 4px 12px rgba(0, 0, 0, 0.05);

  --sidebar-width: 260px;
  --header-height: 70px;

  --transition: all 0.3s ease;
}

[data-theme="dark"] {
  --bg-main: #151521;
  --bg-card: #222233;
  --bg-sidebar: #1e1e2d;
  --bg-sidebar-hover: #2b2b40;

  --text-main: #e0e0e0;
  --text-muted: #aaaaaa;

  --border: #333344;
  --shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

/* ==== Resets and Base Typography ==== */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  font-family: "Inter", "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

body {
  background-color: var(--bg-main);
  color: var(--text-main);
  overflow-x: hidden;
  transition:
    background-color var(--transition),
    color var(--transition);
}

a {
  text-decoration: none;
  color: inherit;
}
button {
  cursor: pointer;
  border: none;
  outline: none;
  background: none;
  font-family: inherit;
}

/* ==== App Layout ==== */
#app-container {
  display: flex;
  height: 100vh;
  width: 100vw;
  overflow: hidden;
}

#app-container.collapsed .sidebar {
  margin-left: calc(var(--sidebar-width) * -1);
}

/* ==== Sidebar ==== */
.sidebar {
  width: var(--sidebar-width);
  flex-shrink: 0;
  background-color: var(--bg-sidebar);
  color: var(--text-light);
  height: 100vh;
  display: flex;
  flex-direction: column;
  z-index: 100;
  transition: margin-left var(--transition);
  overflow: hidden;
}

.brand {
  height: var(--header-height);
  display: flex;
  align-items: center;
  padding: 0 20px;
  font-size: 1.5rem;
  font-weight: 700;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.brand span {
  color: var(--primary);
}

.nav-menu {
  flex: 1;
  padding: 20px 0;
  overflow-y: auto;
}

.nav-link {
  display: flex;
  align-items: center;
  padding: 15px 20px;
  color: #9a9cae;
  transition: var(--transition);
  gap: 15px;
  font-weight: 500;
}

.nav-link i {
  font-size: 1.2rem;
  width: 20px;
  text-align: center;
}
.nav-link:hover,
.nav-link.active {
  background-color: var(--bg-sidebar-hover);
  color: #ffffff;
  border-left: 3px solid var(--primary);
}

/* ==== Main Content Area ==== */
.main-wrapper {
  flex: 1;
  display: flex;
  flex-direction: column;
  height: 100vh;
  min-width: 0; /* Prevents flex children from overflowing */
  background-color: var(--bg-main);
  transition: width var(--transition);
}

.header {
  height: var(--header-height);
  background-color: var(--bg-card);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 30px;
  box-shadow: var(--shadow);
  z-index: 90;
  flex-shrink: 0;
}

.content {
  flex: 1;
  padding: 30px;
  background-color: var(--bg-main);
  overflow-y: auto;
  overflow-x: hidden;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 20px;
}

.theme-toggle,
.logout-btn {
  color: var(--text-muted);
  font-size: 1.2rem;
  transition: var(--transition);
}
.theme-toggle:hover,
.logout-btn:hover {
  color: var(--primary);
}

/* ==== Utility Classes ==== */
.card {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
  margin-bottom: 20px;
}
.card-title {
  font-size: 1.1rem;
  font-weight: 600;
  margin-bottom: 15px;
  color: var(--text-muted);
}

.btn {
  padding: 10px 20px;
  border-radius: var(--radius);
  font-weight: 600;
  transition: var(--transition);
  display: inline-flex;
  align-items: center;
  gap: 8px;
}
.btn-primary {
  background: var(--primary);
  color: white;
}
.btn-primary:hover {
  background: var(--primary-hover);
  transform: translateY(-2px);
}

/* Grid Layouts */
.grid-2 {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 20px;
}
.grid-3 {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 20px;
}
.grid-4 {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 20px;
}

/* Status Badges */
.badge {
  padding: 4px 8px;
  border-radius: 4px;
  font-size: 0.85rem;
  font-weight: 600;
}
.badge-win {
  background: rgba(76, 175, 80, 0.1);
  color: var(--win);
}
.badge-loss {
  background: rgba(244, 67, 54, 0.1);
  color: var(--loss);
}
.badge-void {
  background: rgba(158, 158, 158, 0.1);
  color: var(--void);
}
.badge-pending {
  background: rgba(255, 152, 0, 0.1);
  color: var(--pending);
}

/* Forms */
.form-group {
  margin-bottom: 15px;
}
.form-group label {
  display: block;
  margin-bottom: 5px;
  font-weight: 500;
  font-size: 0.9rem;
}
.form-control {
  width: 100%;
  padding: 10px 12px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--bg-main);
  color: var(--text-main);
  transition: var(--transition);
  font-family: inherit;
}
.form-control:focus {
  border-color: var(--primary);
  outline: none;
}

select option {
  background-color: var(--bg-card);
  color: var(--text-main);
  padding: 10px;
}

/* Login Container */
.login-container {
  height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-sidebar);
}
.login-box {
  background: var(--bg-card);
  width: 100%;
  max-width: 400px;
  padding: 40px;
  border-radius: var(--radius-lg);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
  text-align: center;
}
.login-box h2 {
  margin-bottom: 25px;
  color: var(--text-main);
  font-weight: 700;
}
.login-box span {
  color: var(--primary);
}

/* Responsive */
@media (max-width: 992px) {
  .grid-4 {
    grid-template-columns: repeat(2, 1fr);
  }
  .grid-3 {
    grid-template-columns: repeat(1, 1fr);
  }
}
@media (max-width: 768px) {
  .sidebar {
    position: fixed;
    height: 100vh;
    left: calc(var(--sidebar-width) * -1);
    margin-left: 0;
    transition: left var(--transition);
    z-index: 999;
  }
  #app-container.mobile-open .sidebar {
    left: 0;
  }
  .main-wrapper {
    width: 100vw;
  }
  .grid-4, .grid-2 {
    grid-template-columns: 1fr;
  }
  .header {
    padding: 0 15px;
  }
  .content {
    padding: 15px;
  }
  .stat-value {
    font-size: 1.5rem;
  }
  .card {
    padding: 15px;
  }
  .login-box {
    padding: 20px;
    margin: 15px;
  }
}
@media (max-width: 480px) {
    .header-right { gap: 10px; }
    .btn { padding: 8px 15px; font-size: 0.9rem; }
}

/* Modal */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 1000;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: var(--transition);
  backdrop-filter: blur(3px);
}
.modal-overlay.active {
  opacity: 1;
  pointer-events: auto;
}
.modal {
  background: var(--bg-card);
  width: 100%;
  max-width: 500px;
  border-radius: var(--radius-lg);
  padding: 25px;
  transform: translateY(-20px);
  transition: var(--transition);
  max-height: 90vh;
  overflow-y: auto;
}
.modal-overlay.active .modal {
  transform: translateY(0);
}
.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
}
.modal-close {
  font-size: 1.5rem;
  color: var(--text-muted);
  cursor: pointer;
}
.modal-close:hover {
  color: var(--loss);
}

/* Tables */
.table-responsive {
  overflow-x: auto;
  width: 100%;
}
.table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
}
.table th,
.table td {
  padding: 12px 15px;
  border-bottom: 1px solid var(--border);
}
.table th {
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  font-size: 0.8rem;
}
.table tbody tr:hover {
  background: rgba(0, 0, 0, 0.02);
}
[data-theme="dark"] .table tbody tr:hover {
  background: rgba(255, 255, 255, 0.02);
}

.stat-value {
  font-size: 1.8rem;
  font-weight: 700;
  color: var(--text-main);
}
.stat-trend {
  font-size: 0.9rem;
  margin-top: 5px;
  font-weight: 500;
}
.trend-up {
  color: var(--win);
}
.trend-down {
  color: var(--loss);
}
