/* Ensure proper scrolling on mobile and PWA */
html {
  height: 100%;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  /* PWA-specific fixes */
  position: relative;
  overscroll-behavior: none;
}

/* PWA-specific scrolling fixes */
@media (display-mode: standalone) {
  html {
    height: 100%;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: none;
  }
  
  body {
    height: 100%;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: none;
    position: relative;
  }
  
  .dashboard {
    height: auto;
    min-height: 100vh;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: none;
  }
}

/* Light mode (default) */
body {
  font-family: 'Poppins', 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: linear-gradient(135deg, #f8fafc 0%, #e0e7ef 100%);
  color: var(--text);
  margin: 0;
  padding: 0;
  letter-spacing: 0.01em;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  min-height: 100%;
}

/* Dark mode */
body.dark {
  background: linear-gradient(135deg, #1a1a1a 0%, #232946 100%);
  color: #f4f4f9;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
}

/* Responsive Design */
@media (max-width: 768px) {
  body {
    padding: 1rem;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
  }
  h1 {
    font-size: 1.5em;
  }
  .container {
    width: 100%;
    padding: 1rem;
    justify-content: flex-start;
  }
}

@media (max-width: 480px) {
  body {
    padding: 5px;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
  }
  h1 {
    font-size: 1.2em;
  }
  .container {
    padding: 5px;
    justify-content: flex-start;
  }
}

/* Flexible Layouts */
.container {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  max-width: 1200px;
  margin: auto;
}

/* Responsive Images */
img {
  max-width: 100%;
  height: auto;
}

/* Base styles */
:root {
  --primary: #2563eb;
  --secondary: #22d3ee;
  --success: #22c55e;
  --warning: #f59e42;
  --danger: #ef4444;
  --background: #f4f7fa;
  --card: #fff;
  --text: #1e293b;
  --muted: #64748b;
  --shadow: 0 4px 24px rgba(37,99,235,0.08);
  --radius: 1.25rem;
  --transition: 0.2s cubic-bezier(.4,0,.2,1);
}

/* Loading indicators */
.loading {
    position: relative;
    pointer-events: none;
}

.loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 24px;
    height: 24px;
    margin: -12px 0 0 -12px;
    border: 2px solid var(--primary);
    border-top-color: transparent;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

/* Notifications */
.notification {
    position: fixed;
    top: 20px;
    right: 20px;
    padding: 15px 25px;
    border-radius: 5px;
    background: var(--card-background);
    color: var(--text-color);
    box-shadow: var(--shadow);
    transform: translateX(120%);
    transition: transform 0.3s ease;
    z-index: 1000;
}

.notification.show {
    transform: translateX(0);
}

.notification.success {
    border-left: 4px solid var(--secondary-color);
}

.notification.error {
    border-left: 4px solid var(--danger-color);
}

.notification.warning {
    border-left: 4px solid var(--warning-color);
}

/* Form elements */
input, select, textarea {
    width: 100%;
    padding: 10px;
    border: 1px solid var(--border-color);
    border-radius: 5px;
    background: var(--card-background);
    color: var(--text-color);
    transition: var(--transition);
}

input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 2px rgba(52, 152, 219, 0.2);
}

/* Cards */
.card, .dashboard-tile {
  background: var(--card-background);
  border-radius: 10px;
  padding: 20px;
  box-shadow: var(--shadow);
  margin: 10px;
  display: inline-block;
  min-width: 180px;
  font-weight: bold;
  border-left: 5px solid var(--primary-color);
  transition: var(--transition);
}

.card:hover, .dashboard-tile:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 8px rgba(0,0,0,0.1);
}

/* Tables */
table {
    width: 100%;
    border-collapse: collapse;
    margin: 20px 0;
}

th, td {
    padding: 12px;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
}

th {
    background: var(--primary-color);
    color: white;
}

tr:hover {
    background: rgba(52, 152, 219, 0.1);
}

/* Responsive design */
@media (max-width: 768px) {
    .card {
        padding: 15px;
    }
    
    button {
        width: 100%;
        margin: 5px 0;
    }
    
    table {
        display: block;
        overflow-x: auto;
    }
}

/* Animations */
@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes slideIn {
    from { transform: translateY(20px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

.fade-in {
    animation: fadeIn 0.3s ease;
}

.slide-in {
    animation: slideIn 0.3s ease;
}

/* Buttons */
button {
  padding: 10px 20px;
  border: none;
  border-radius: 5px;
  background: var(--primary-color);
  color: white;
  cursor: pointer;
  transition: var(--transition);
  font-weight: 500;
}

button:hover {
  opacity: 0.9;
  transform: translateY(-1px);
}

button:active {
  transform: translateY(0);
}

button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.tile-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 2rem;
  margin: 3rem auto;
  max-width: 1200px;
}

.tile {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: var(--card-background);
  color: var(--text-color);
  border-radius: 16px;
  box-shadow: var(--shadow);
  padding: 2.5rem 2rem;
  text-decoration: none;
  font-weight: 500;
  transition: var(--transition);
  border: 1px solid var(--border-color);
  position: relative;
  overflow: hidden;
  min-height: 200px;
}

.tile::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 4px;
  background: linear-gradient(90deg, var(--primary-color), var(--secondary-color));
  opacity: 0.8;
}

.tile:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-hover);
}

.tile-icon {
  font-size: 2.75rem;
  margin-bottom: 1.25rem;
  display: block;
  background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  line-height: 1;
}

.tile-title {
  font-size: 1.35rem;
  font-weight: 600;
  text-align: center;
  color: var(--text-color);
  margin-bottom: 0.5rem;
}

.tile-description {
  font-size: 0.95rem;
  color: var(--text-muted);
  text-align: center;
  line-height: 1.5;
}

.subtitle {
  font-size: 1.25rem;
  color: var(--text-muted);
  margin: 1rem 0 2rem;
  font-weight: 500;
  margin: 0.5rem 0;
  opacity: 0.8;
}

header h1 {
  font-size: 2.75rem;
  font-weight: 800;
  margin: 0;
  background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  letter-spacing: -0.02em;
}

.dashboard-tile h3 {
  margin: 0 0 0.75rem 0;
  font-size: 1.35rem;
  font-weight: 600;
  color: var(--text-color);
}

.dashboard-tile p {
  margin: 0;
  font-size: 1.1rem;
  color: var(--text-muted);
  line-height: 1.5;
}

.recent-activity {
  margin-top: 3rem;
  padding-top: 2rem;
  border-top: 1px solid var(--border-color);
  background-color: var(--card-background);
  padding: 1.5rem;
  border-radius: var(--border-radius);
  box-shadow: 0 2px 4px var(--shadow-color);
}

.recent-activity h2 {
  font-size: 1.5rem;
  margin-bottom: 1rem;
  color: var(--text-color);
}

#activityList {
  display: grid;
  gap: 1rem;
}

.dashboard {
  max-width: 1050px;
  margin: 0 auto;
  padding: 1.5rem 0.5rem 2rem 0.5rem;
  overflow-x: hidden;
}

header {
  background: rgba(255,255,255,0.85);
  backdrop-filter: blur(8px);
  border-radius: 1.5rem;
  box-shadow: 0 8px 32px rgba(37,99,235,0.10);
  padding: 1.2rem 2rem 1rem 2rem;
  margin-bottom: 2rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  transition: background 0.3s;
}

.header-title {
  font-size: 1.6rem;
  font-weight: 700;
  letter-spacing: -0.5px;
  display: flex;
  align-items: center;
  gap: 0.7rem;
}

.header-controls {
  display: flex;
  gap: 1.25rem;
  align-items: center;
}

.control-btn {
  background: rgba(255,255,255,0.15);
  color: #fff;
  border: none;
  padding: 0.7rem 1.5rem;
  border-radius: 999px;
  font-weight: 600;
  font-size: 1rem;
  cursor: pointer;
  transition: background var(--transition), color var(--transition);
  box-shadow: 0 2px 8px rgba(0,0,0,0.04);
}

.control-btn:hover {
  background: rgba(255,255,255,0.25);
}

.user-menu {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.user-email {
  color: var(--text-color);
  font-weight: 500;
}

.dashboard-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1.2rem;
  margin-bottom: 2rem;
}

.stat-tile {
  background: rgba(255,255,255,0.65);
  border-radius: 1.25rem;
  box-shadow: 0 4px 24px rgba(37,99,235,0.08), 0 1.5px 8px rgba(0,0,0,0.04);
  padding: 1.2rem 1.1rem;
  display: flex;
  align-items: center;
  gap: 1.1rem;
  border-left: 5px solid var(--primary);
  min-height: 90px;
  transition: box-shadow 0.2s, transform 0.2s;
  position: relative;
  overflow: hidden;
  backdrop-filter: blur(4px);
}
.stat-tile[data-type="success"] { border-left-color: var(--success); }
.stat-tile[data-type="warning"] { border-left-color: var(--warning); }
.stat-tile[data-type="danger"] { border-left-color: var(--danger); }
.stat-tile:hover {
  box-shadow: 0 8px 32px rgba(37,99,235,0.16), 0 2px 12px rgba(0,0,0,0.08);
  transform: translateY(-2px) scale(1.015);
}
.stat-icon {
  font-size: 1.7rem;
  color: var(--primary);
  background: #e0e7ff;
  border-radius: 50%;
  padding: 0.7rem;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 8px rgba(37,99,235,0.07);
}
body.dark .stat-icon { background: #334155; }
.stat-content h3 {
  margin: 0 0 0.2rem 0;
  font-size: 1.05rem;
  color: var(--muted);
  font-weight: 600;
}
.stat-value {
  font-size: 1.45rem;
  font-weight: 700;
  color: var(--primary);
  margin: 0;
}

.tools-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1.2rem;
  margin-bottom: 2.2rem;
}
.tool-card {
  background: rgba(255,255,255,0.65);
  border-radius: 1.25rem;
  box-shadow: 0 4px 24px rgba(37,99,235,0.08), 0 1.5px 8px rgba(0,0,0,0.04);
  text-decoration: none;
  color: var(--text);
  padding: 1.2rem 1.1rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  transition: box-shadow 0.2s, transform 0.2s;
  border: none;
  min-height: 120px;
  overflow: hidden;
  backdrop-filter: blur(4px);
}
.tool-card:hover {
  box-shadow: 0 8px 32px rgba(37,99,235,0.16), 0 2px 12px rgba(0,0,0,0.08);
  transform: translateY(-2px) scale(1.015);
}
.tool-icon {
  font-size: 1.5rem;
  margin-bottom: 0.7rem;
  color: var(--primary);
  background: #e0e7ff;
  border-radius: 50%;
  padding: 0.7rem;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 8px rgba(37,99,235,0.07);
}
body.dark .tool-icon { background: #334155; }
.tool-card h3 {
  margin: 0 0 0.2rem 0;
  font-size: 1.05rem;
  font-weight: 600;
}
.tool-card p {
  margin: 0;
  font-size: 0.98rem;
  color: var(--muted);
}

/* Microinteractions */
.control-btn, .tool-card, .stat-tile {
  transition: box-shadow 0.2s, transform 0.2s, background 0.2s;
}

/* Responsive Tweaks */
@media (max-width: 900px) {
  .dashboard-stats, .tools-grid {
    grid-template-columns: 1fr 1fr;
  }
}
@media (max-width: 600px) {
  .dashboard {
    padding: 0.5rem 0.1rem;
  }
  header {
    flex-direction: column;
    align-items: flex-start;
    padding: 1rem 0.7rem 0.7rem 0.7rem;
  }
  .dashboard-stats, .tools-grid {
    grid-template-columns: 1fr;
    gap: 0.7rem;
  }
}

.session-timeout {
  position: fixed;
  bottom: 2rem;
  right: 2rem;
  background: var(--card);
  padding: 1.25rem 2rem;
  border-radius: var(--radius);
  box-shadow: 0 4px 16px rgba(37,99,235,0.12);
  z-index: 1000;
  border: 1px solid #e0e7ff;
}
.timeout-content {
  display: flex;
  align-items: center;
  gap: 1.25rem;
}
.timeout-content p {
  margin: 0;
  font-weight: 500;
}
