/* Root Variables */
:root {
  /* Modern Color Palette */
  --primary-color: #6366f1;
  /* Indigo 500 */
  --primary-dark: #4f46e5;
  /* Indigo 600 */
  --primary-light: #e0e7ff;
  /* Indigo 100 */
  --primary-gradient: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);

  --secondary-color: #10b981;
  /* Emerald 500 */
  --secondary-light: #d1fae5;
  /* Emerald 100 */

  --danger-color: #ef4444;
  /* Red 500 */
  --danger-light: #fee2e2;
  /* Red 100 */

  --warning-color: #f59e0b;
  /* Amber 500 */
  --warning-light: #fef3c7;
  /* Amber 100 */

  /* Neutrals */
  --bg-body: #f8fafc;
  /* Slate 50 */
  --bg-card: #ffffff;
  --text-main: #0f172a;
  /* Slate 900 */
  --text-secondary: #64748b;
  /* Slate 500 */
  --border-color: #e2e8f0;
  /* Slate 200 */

  /* UI Elements */
  --border-radius: 16px;
  --border-radius-sm: 8px;

  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
  --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);

  --transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);

  --font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
}

/* Global Styles */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
  height: 100%;
}

body {
  font-family: var(--font-family);
  background-color: var(--bg-body);
  color: var(--text-main);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  height: 100%;
}

/* Layout */
.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 1.5rem;
}

.page {
  display: none;
  animation: fadeIn 0.4s ease-out;
  min-height: 100vh;
}

.page.active {
  display: block;
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Home/Landing Page */
#home-page {
  background: linear-gradient(135deg, #f8fafc 0%, #e0e7ff 100%);
}

.home-container {
  min-height: calc(100vh - 80px);
  /* Adjust for header */
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  padding: 2rem;
}

.home-content {
  max-width: 1200px;
  width: 100%;
}

.home-hero {
  text-align: center;
  margin-bottom: 4rem;
}

.home-logo {
  font-size: 4rem;
  margin-bottom: 1.5rem;
  animation: float 3s ease-in-out infinite;
}

.home-title {
  font-size: 3.5rem;
  font-weight: 900;
  margin-bottom: 1rem;
  background: var(--primary-gradient);
  background-clip: text;
  -webkit-background-clip: text;
  -moz-background-clip: text;
  -webkit-text-fill-color: transparent;
  letter-spacing: -0.02em;
}

.home-subtitle {
  font-size: 1.5rem;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 1.5rem;
}

.home-description {
  font-size: 1.125rem;
  color: var(--text-secondary);
  max-width: 600px;
  margin: 0 auto 2.5rem;
  line-height: 1.8;
}

.home-buttons {
  display: flex;
  gap: 1rem;
  justify-content: center;
  flex-wrap: wrap;
}

.btn-large {
  padding: 1rem 2.5rem;
  font-size: 1.125rem;
}

.home-features {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 2rem;
  margin-top: 4rem;
}

.feature-card {
  background: rgba(255, 255, 255, 0.9);
  backdrop-filter: blur(20px);
  border-radius: 20px;
  padding: 2.5rem;
  text-align: center;
  border: 1px solid rgba(255, 255, 255, 0.5);
  box-shadow: var(--shadow-lg);
  transition: var(--transition);
}

.feature-card:hover {
  transform: translateY(-8px);
  box-shadow: var(--shadow-xl);
}

.feature-icon {
  font-size: 3rem;
  margin-bottom: 1rem;
}

.feature-card h3 {
  font-size: 1.25rem;
  font-weight: 700;
  margin-bottom: 0.75rem;
  color: var(--text-main);
}

.feature-card p {
  color: var(--text-secondary);
  line-height: 1.6;
}

/* Header/Navigation */
.header {
  background: rgba(255, 255, 255, 0.8);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border-color);
  padding: 1rem 0;
  position: sticky;
  top: 0;
  z-index: 100;
}

.header-content {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.logo {
  font-size: 1.5rem;
  font-weight: 800;
  background: var(--primary-gradient);
  background-clip: text;
  -webkit-background-clip: text;
  -moz-background-clip: text;
  -webkit-text-fill-color: transparent;
  text-decoration: none;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  letter-spacing: -0.02em;
}

.logo::before {
  content: '✨';
  /* Changed icon for a fresher look */
  font-size: 1.5rem;
  -webkit-text-fill-color: initial;
}

.auth-title {
  font-size: 2rem;
  font-weight: 800;
  color: var(--text-main);
  margin-bottom: 0.5rem;
  background: var(--primary-gradient);
  background-clip: text;
  -webkit-background-clip: text;
  -moz-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.nav-buttons {
  display: flex;
  gap: 1rem;
  align-items: center;
}

.user-menu {
  position: relative;
}

.user-menu-btn {
  background: white;
  color: var(--text-main);
  border: 1px solid var(--border-color);
  padding: 0.5rem 1rem;
  border-radius: var(--border-radius-sm);
  cursor: pointer;
  font-size: 0.875rem;
  font-weight: 600;
  transition: var(--transition);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.user-menu-btn:hover {
  background: var(--bg-body);
  border-color: var(--primary-color);
  color: var(--primary-color);
}

.dropdown-menu {
  display: none;
  position: absolute;
  top: calc(100% + 0.5rem);
  right: 0;
  background: white;
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius-sm);
  box-shadow: var(--shadow-lg);
  min-width: 220px;
  z-index: 101;
  overflow: hidden;
  animation: slideDown 0.2s ease-out;
}

@keyframes slideDown {
  from {
    opacity: 0;
    transform: translateY(-10px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.dropdown-menu.active {
  display: block;
}

.dropdown-menu button {
  display: block;
  width: 100%;
  text-align: left;
  padding: 0.75rem 1rem;
  border: none;
  background: none;
  cursor: pointer;
  font-size: 0.875rem;
  color: var(--text-secondary);
  transition: var(--transition);
  font-weight: 500;
}

.dropdown-menu button:hover {
  background-color: var(--bg-body);
  color: var(--primary-color);
}

.dropdown-menu button.logout {
  color: var(--danger-color);
  border-top: 1px solid var(--border-color);
}

.dropdown-menu button.logout:hover {
  background-color: var(--danger-light);
}

/* Buttons */
.btn {
  padding: 0.75rem 1.5rem;
  border: none;
  border-radius: var(--border-radius-sm);
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  white-space: nowrap;
  letter-spacing: 0.01em;
}

.btn-primary {
  background: var(--primary-gradient);
  color: white;
  box-shadow: 0 4px 12px rgba(99, 102, 241, 0.3);
}

.btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 16px rgba(99, 102, 241, 0.4);
}

.btn-primary:active {
  transform: translateY(0);
}

.btn-secondary {
  background-color: white;
  color: var(--text-secondary);
  border: 1px solid var(--border-color);
}

.btn-secondary:hover {
  background-color: var(--bg-body);
  color: var(--text-main);
  border-color: var(--gray-300);
}

.btn-danger {
  background-color: var(--danger-light);
  color: var(--danger-color);
}

.btn-danger:hover {
  background-color: var(--danger-color);
  color: white;
}

.btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none !important;
}

/* Link Button (for auth forms) */
.link-button {
  background: none;
  border: none;
  color: var(--primary-color);
  text-decoration: none;
  font-weight: 600;
  cursor: pointer;
  padding: 0;
  font-size: inherit;
  font-family: inherit;
}

.link-button:hover {
  text-decoration: underline;
}

/* Forms */
.form-group {
  margin-bottom: 1.5rem;
}

label {
  display: block;
  font-weight: 600;
  margin-bottom: 0.5rem;
  color: var(--text-main);
  font-size: 0.875rem;
}

input,
textarea,
select {
  width: 100%;
  padding: 0.875rem 1rem;
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius-sm);
  font-size: 0.95rem;
  font-family: inherit;
  transition: var(--transition);
  background-color: white;
  color: var(--text-main);
}

input:focus,
textarea:focus,
select:focus {
  outline: none;
  border-color: var(--primary-color);
  box-shadow: 0 0 0 4px var(--primary-light);
}

textarea {
  resize: vertical;
  min-height: 120px;
}

/* Cards */
.card {
  background: var(--bg-card);
  border-radius: var(--border-radius);
  box-shadow: var(--shadow-sm);
  padding: 1.5rem;
  transition: var(--transition);
  border: 1px solid var(--border-color);
}

.card:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}

/* Dashboard */
.dashboard {
  padding: 2.5rem 0;
}

.dashboard-header {
  margin-bottom: 2.5rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 1rem;
}

.dashboard-title {
  font-size: 2.25rem;
  font-weight: 800;
  color: var(--text-main);
  letter-spacing: -0.03em;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 1.5rem;
  margin-bottom: 3rem;
}

.stat-card {
  background: white;
  border-radius: var(--border-radius);
  padding: 1.75rem;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  position: relative;
  overflow: hidden;
}

.stat-card::after {
  content: '';
  position: absolute;
  top: 0;
  right: 0;
  width: 100px;
  height: 100px;
  background: linear-gradient(135deg, transparent, var(--primary-light));
  border-radius: 0 0 0 100%;
  opacity: 0.5;
}

.stat-label {
  color: var(--text-secondary);
  font-size: 0.875rem;
  font-weight: 600;
  margin-bottom: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.stat-value {
  font-size: 2.5rem;
  font-weight: 800;
  color: var(--text-main);
  letter-spacing: -0.02em;
  line-height: 1.1;
}

.stat-value.total {
  color: var(--primary-color);
}

.stat-value.yearly {
  color: var(--text-main);
}

/* Subscriptions */
.subscriptions-section {
  margin-bottom: 3rem;
}

.section-title {
  font-size: 1.5rem;
  font-weight: 700;
  margin-bottom: 1.5rem;
  color: var(--text-main);
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.subscriptions-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 1.5rem;
}

.subscription-card {
  background: white;
  border-radius: var(--border-radius);
  padding: 1.5rem;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border-color);
  transition: var(--transition);
  display: flex;
  flex-direction: column;
  position: relative;
}

.subscription-card:hover {
  box-shadow: var(--shadow-lg);
  transform: translateY(-4px);
  border-color: var(--primary-light);
}

.subscription-header {
  display: flex;
  gap: 1rem;
  margin-bottom: 1.25rem;
  align-items: flex-start;
}

.subscription-logo {
  width: 56px;
  height: 56px;
  background: var(--bg-body);
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.75rem;
  flex-shrink: 0;
  border: 1px solid var(--border-color);
}

.subscription-logo img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 12px;
}

.subscription-info {
  flex-grow: 1;
}

.subscription-name {
  font-size: 1.125rem;
  font-weight: 700;
  color: var(--text-main);
  margin-bottom: 0.25rem;
}

.subscription-category {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--primary-dark);
  background-color: var(--primary-light);
  padding: 0.25rem 0.75rem;
  border-radius: 20px;
  display: inline-block;
}

.subscription-price {
  font-size: 1.75rem;
  font-weight: 800;
  color: var(--text-main);
  margin: 1rem 0;
  letter-spacing: -0.02em;
}

.subscription-details {
  background: var(--bg-body);
  padding: 1rem;
  border-radius: var(--border-radius-sm);
  margin-bottom: 1.25rem;
}

.detail-row {
  display: flex;
  justify-content: space-between;
  font-size: 0.875rem;
  margin-bottom: 0.5rem;
}

.detail-row:last-child {
  margin-bottom: 0;
}

.detail-label {
  color: var(--text-secondary);
}

.detail-value {
  font-weight: 600;
  color: var(--text-main);
}

.subscription-actions {
  display: flex;
  gap: 0.75rem;
  margin-top: auto;
}

.subscription-actions button {
  flex: 1;
}

/* Search and Filter */
.search-filter {
  display: flex;
  gap: 1rem;
  margin-bottom: 2rem;
  flex-wrap: wrap;
  background: white;
  padding: 1rem;
  border-radius: var(--border-radius);
  border: 1px solid var(--border-color);
  box-shadow: var(--shadow-sm);
}

.search-input {
  flex: 1;
  min-width: 240px;
  border: 1px solid var(--border-color);
}

.filter-select {
  min-width: 180px;
  border: 1px solid var(--border-color);
}

/* Auth Pages */
.auth-container {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 2rem;
  background: linear-gradient(135deg, var(--bg-body) 0%, var(--primary-light) 100%);
}

.auth-card {
  background: rgba(255, 255, 255, 0.9);
  backdrop-filter: blur(20px);
  border-radius: 24px;
  box-shadow: var(--shadow-xl);
  padding: 3rem;
  width: 100%;
  max-width: 440px;
  border: 1px solid rgba(255, 255, 255, 0.5);
  position: relative;
}

.back-home-btn {
  position: absolute;
  top: 1.5rem;
  left: 1.5rem;
  font-size: 0.875rem;
  color: var(--text-secondary);
  text-decoration: none;
  font-weight: 500;
  transition: var(--transition);
}

.back-home-btn:hover {
  color: var(--primary-color);
  transform: translateX(-4px);
}

.auth-logo-link {
  text-decoration: none;
  display: inline-block;
}

.auth-header {
  text-align: center;
  margin-bottom: 2.5rem;
}

.auth-logo {
  font-size: 3rem;
  margin-bottom: 1rem;
  display: inline-block;
  animation: float 3s ease-in-out infinite;
}

@keyframes float {
  0% {
    transform: translateY(0px);
  }

  50% {
    transform: translateY(-10px);
  }

  100% {
    transform: translateY(0px);
  }
}

.auth-title {
  font-size: 2rem;
  font-weight: 800;
  color: var(--text-main);
  margin-bottom: 0.5rem;
  background: var(--primary-gradient);
  background-clip: text;
  -webkit-background-clip: text;
  -moz-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.auth-subtitle {
  color: var(--text-secondary);
  font-size: 1rem;
}

.form-submit {
  width: 100%;
  padding: 1rem;
  font-size: 1rem;
  margin-top: 1rem;
}

.auth-link {
  text-align: center;
  font-size: 0.95rem;
  color: var(--text-secondary);
  margin-top: 1.5rem;
}

.auth-link a {
  color: var(--primary-color);
  text-decoration: none;
  font-weight: 600;
}

/* Footer */
.app-footer {
  text-align: center;
  padding: 2rem 0;
  color: var(--text-secondary);
  font-size: 0.875rem;
  width: 100%;
}

.app-footer a {
  color: var(--primary-color);
  text-decoration: none;
  font-weight: 600;
  transition: var(--transition);
}

.app-footer a:hover {
  text-decoration: underline;
}

.dashboard-footer {
  border-top: 1px solid var(--border-color);
  background: white;
  margin-top: auto;
}

.auth-link a:hover {
  text-decoration: underline;
}

/* Modal */
.modal {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: rgba(15, 23, 42, 0.6);
  backdrop-filter: blur(4px);
  z-index: 1000;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.modal.active {
  display: flex;
  opacity: 1;
}

.modal-content {
  background: white;
  border-radius: 24px;
  box-shadow: var(--shadow-2xl);
  width: 100%;
  max-width: 550px;
  position: relative;
  transform: scale(0.95);
  transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  /* Ensure children don't overflow */
}

/* Make the form take up available space and handle scrolling */
#subscription-form {
  display: flex;
  flex-direction: column;
  height: 100%;
  overflow: hidden;
}

.modal-body {
  padding: 2.5rem;
  overflow-y: auto;
  flex-grow: 1;
  /* Ensure it doesn't expand beyond available space */
  min-height: 0;
}

.modal.active .modal-content {
  transform: scale(1);
}

.modal-header {
  font-size: 1.5rem;
  font-weight: 700;
  padding: 1.5rem 2.5rem;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  justify-content: space-between;
  align-items: center;
  color: var(--text-main);
  flex-shrink: 0;
  background: white;
  /* Ensure header is opaque */
  z-index: 10;
}

.modal-close {
  background: var(--bg-body);
  border: none;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  cursor: pointer;
  color: var(--text-secondary);
  transition: var(--transition);
}

.modal-close:hover {
  background: var(--danger-light);
  color: var(--danger-color);
}

.modal-footer {
  display: flex;
  gap: 1rem;
  padding: 1.5rem 2.5rem;
  border-top: 1px solid var(--border-color);
  background: var(--bg-body);
  border-radius: 0 0 24px 24px;
  flex-shrink: 0;
  z-index: 10;
}

.modal-footer .btn {
  flex: 1;
  padding: 1rem;
}

/* Empty State */
.empty-state {
  text-align: center;
  padding: 4rem 2rem;
  background: white;
  border-radius: var(--border-radius);
  border: 2px dashed var(--border-color);
}

.empty-icon {
  font-size: 4rem;
  margin-bottom: 1.5rem;
  opacity: 0.8;
}

.empty-title {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text-main);
  margin-bottom: 0.75rem;
}

.empty-text {
  color: var(--text-secondary);
  margin-bottom: 2rem;
  max-width: 400px;
  margin-left: auto;
  margin-right: auto;
}

/* Notification/Alert */
.notification {
  position: fixed;
  bottom: 2rem;
  right: 2rem;
  padding: 1rem 1.5rem;
  border-radius: var(--border-radius-sm);
  background: white;
  box-shadow: var(--shadow-lg);
  display: flex;
  align-items: center;
  gap: 0.75rem;
  z-index: 2000;
  animation: slideInRight 0.3s ease-out;
  border-left: 4px solid var(--primary-color);
  font-weight: 500;
}

@keyframes slideInRight {
  from {
    transform: translateX(100%);
    opacity: 0;
  }

  to {
    transform: translateX(0);
    opacity: 1;
  }
}

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

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

/* Responsive */
@media (max-width: 768px) {
  .home-title {
    font-size: 2.5rem;
  }

  .home-subtitle {
    font-size: 1.25rem;
  }

  .home-description {
    font-size: 1rem;
  }

  .home-features {
    grid-template-columns: 1fr;
  }

  .header-content {
    flex-direction: column;
    gap: 1rem;
  }

  .nav-buttons {
    width: 100%;
    justify-content: center;
  }

  .dashboard-header {
    flex-direction: column;
    align-items: flex-start;
  }

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

  .subscriptions-list {
    grid-template-columns: 1fr;
  }

  .search-filter {
    flex-direction: column;
  }

  .search-input,
  .filter-select {
    min-width: 100%;
  }

  .auth-card {
    padding: 2rem;
  }

  .modal-content {
    padding: 1.5rem;
  }

  .home-buttons {
    flex-direction: column;
    width: 100%;
  }

  .btn-large {
    width: 100%;
  }
}