/*
 * Modern CSS — Home Website
 * External stylesheet with CSS custom properties
 */

/* ── 1. Custom Properties ── */
:root {
  --bg-dark: #1a1a2e;
  --bg-darker: #16213e;
  --bg-light: #f0f2f5;
  --accent: #3b82f6;
  --accent-hover: #2563eb;
  --success: #10b981;
  --danger: #ef4444;
  --warning: #f59e0b;
  --text: #1f2937;
  --text-light: #94a3b8;
  --card-bg: #ffffff;
  --shadow: rgba(0,0,0,0.08);
  --radius: 12px;
  --transition: 0.2s ease;
}

/* ── 2. Reset ── */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  scroll-behavior: smooth;
}

/* ── 3. Body ── */
body {
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: var(--bg-light);
  color: var(--text);
  line-height: 1.6;
  overflow-x: hidden;
}

/* ── 4. Sidebar ── */
.sidebar {
  position: fixed;
  left: 0;
  top: 0;
  width: 260px;
  max-width: 80vw;
  height: 100vh;
  background: linear-gradient(180deg, var(--bg-dark), var(--bg-darker));
  color: #fff;
  padding: 20px;
  overflow-y: auto;
  transition: transform 0.3s ease;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  box-shadow: 4px 0 20px rgba(0,0,0,0.15);
}

.sidebar.collapsed {
  transform: translateX(-100%);
}

/* ── 5. Sidebar Nav ── */
.sidebar ul {
  list-style: none;
  padding: 0;
  margin-top: 0;
  flex: 1;
}

.sidebar li {
  margin: 4px 0;
}

.sidebar a {
  display: block;
  padding: 12px 18px;
  color: #cfd8dc;
  border-radius: 8px;
  text-decoration: none;
  transition: all 0.2s ease;
  font-size: 15px;
}

.sidebar a:hover {
  background: rgba(255,255,255,0.1);
  color: #fff;
  padding-left: 24px;
}

.sidebar a.active {
  background: var(--accent);
  color: #fff;
}

/* ── 6. Auth Section ── */
.auth-btn {
  margin-top: auto;
  padding-top: 20px;
  border-top: 1px solid rgba(255,255,255,0.1);
}

.auth-btn button {
  width: 100%;
  padding: 14px;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  font-size: 16px;
  font-weight: 600;
  transition: background 0.2s ease;
}

/* ── 7. Login Button ── */
.login-btn {
  background: var(--accent);
  color: #fff;
}

.login-btn:hover {
  background: var(--accent-hover);
}

/* ── 8. Logout Button ── */
.logout-btn {
  background: var(--danger);
  color: #fff;
}

.logout-btn:hover {
  background: #dc2626;
}

/* ── 9. Content ── */
.content {
  margin-left: 260px;
  padding: 30px;
  transition: margin-left 0.3s ease;
  min-height: 100vh;
  box-sizing: border-box;
}

.sidebar.collapsed ~ .content {
  margin-left: 0;
}

/* ── 10. Toggle Button ── */
.toggle-btn {
  position: fixed;
  top: 30px;
  background: var(--bg-dark);
  color: #fff;
  border: none;
  padding: 10px 14px;
  font-size: 24px;
  cursor: pointer;
  transition: left 0.3s ease, background 0.3s ease;
  border-radius: 0 8px 8px 0;
  z-index: 1001;
  box-shadow: 2px 2px 8px rgba(0,0,0,0.2);
}

.toggle-btn:hover {
  background: #495057;
}

.sidebar:not(.collapsed) ~ .toggle-btn {
  left: 260px;
}

.sidebar.collapsed ~ .toggle-btn {
  left: 0;
}

.toggle-btn span {
  pointer-events: none;
}

/* ── 11. Cards ── */
.card {
  background: var(--card-bg);
  border-radius: var(--radius);
  box-shadow: 0 2px 8px var(--shadow);
  padding: 24px;
  margin: 10px 0;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.card:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 25px rgba(0,0,0,0.12);
}

/* ── 12. Dashboard Grid ── */
.dashboard-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 20px;
  margin-top: 20px;
}

/* ── 13. Tables ── */
.table {
  width: 100%;
  border-collapse: collapse;
  background: #fff;
  border-radius: 8px;
  overflow: hidden;
  margin-top: 10px;
}

.table th,
.table td {
  padding: 12px 16px;
  text-align: left;
}

.table thead {
  background: var(--bg-dark);
  color: #fff;
  position: sticky;
  top: 0;
  z-index: 2;
}

.table tr:nth-child(even) {
  background: #f8f9fa;
}

.table tr:hover {
  background: #e8f0fe;
}

/* ── 14. Forms ── */
.form-group {
  margin-bottom: 16px;
}

.form-label {
  display: block;
  margin-bottom: 6px;
  font-weight: 600;
  color: var(--text);
}

.form-control {
  width: 100%;
  padding: 12px 16px;
  border: 1px solid #d1d5db;
  border-radius: 8px;
  font-size: 1rem;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
  background: #fff;
  color: var(--text);
}

.form-control:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(59,130,246,0.2);
}

/* ── 15. Buttons ── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 10px 20px;
  font-size: 1rem;
  font-weight: 600;
  border-radius: 8px;
  border: none;
  cursor: pointer;
  transition: all 0.2s ease;
  text-decoration: none;
  gap: 8px;
}

.btn-primary {
  background: var(--accent);
  color: #fff;
}
.btn-primary:hover {
  background: var(--accent-hover);
}

.btn-success {
  background: var(--success);
  color: #fff;
}
.btn-success:hover {
  background: #059669;
}

.btn-danger {
  background: var(--danger);
  color: #fff;
}
.btn-danger:hover {
  background: #dc2626;
}

.btn-warning {
  background: var(--warning);
  color: #fff;
}
.btn-warning:hover {
  background: #d97706;
}

/* ── 16. Alerts ── */
.alert {
  padding: 14px 18px;
  border-radius: 8px;
  margin: 10px 0;
  font-weight: 500;
}

.alert.success {
  background: #d1fae5;
  color: #065f46;
}

.alert.danger {
  background: #fee2e2;
  color: #991b1b;
}

.alert.info {
  background: #dbeafe;
  color: #1e40af;
}

.alert.warning {
  background: #fef3c7;
  color: #92400e;
}

/* ── 17. Login Page ── */
.login-container {
  background: #fff;
  padding: 40px;
  border-radius: 16px;
  box-shadow: 0 10px 30px rgba(0,0,0,0.1);
  width: 100%;
  max-width: 420px;
  text-align: center;
}

/* ── 18. Page Headers ── */
h1 {
  font-size: 1.8rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 20px;
}

h2 {
  font-size: 1.4rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 16px;
}

h3 {
  font-size: 1.2rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 12px;
}

/* ── 19. Responsive ── */
@media (max-width: 768px) {
  .sidebar {
    max-width: 80vw;
  }

  .sidebar:not(.collapsed) ~ .content {
    margin-left: 0;
  }

  .content {
    padding: 20px;
    margin-left: 0;
  }

  .toggle-btn {
    border-radius: 8px;
    left: 10px !important;
  }

  .dashboard-grid {
    grid-template-columns: 1fr;
  }
}

/* ── 20. Scrollbar ── */
::-webkit-scrollbar {
  width: 8px;
}

::-webkit-scrollbar-track {
  background: var(--bg-light);
}

::-webkit-scrollbar-thumb {
  background: #94a3b8;
  border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
  background: #64748b;
}
