/**
 * Accounts Manager - Frontend Styles (Neumorphic Red Theme)
 */

:root {
  --am-primary: #dc2626;
  --am-primary-dark: #b91c1c;
  --am-primary-light: #fca5a5;
  --am-bg: #e8e8e8;
  --am-bg-dark: #1f2937;
  --am-shadow-light: #ffffff;
  --am-shadow-dark: #bebebe;
  --am-text: #1f2937;
  --am-text-muted: #6b7280;
  --am-success: #10b981;
  --am-warning: #f59e0b;
  --am-danger: #ef4444;
  --am-info: #3b82f6;
  --am-radius: 16px;
  --am-radius-sm: 8px;
}

/* Base */
.am-portal {
  font-family: "Inter", "Segoe UI", system-ui, sans-serif;
  background: var(--am-bg);
  min-height: 100vh;
  padding: 20px;
  color: var(--am-text);
}

.am-portal * {
  box-sizing: border-box;
}

.am-portal input[type="text"],
.am-portal input[type="number"],
.am-portal input[type="email"],
.am-portal input[type="date"],
.am-portal input[type="month"],
.am-portal select,
.am-portal textarea {
  line-height: 1.5 !important;
  height: auto !important;
  box-sizing: border-box !important;
}

/* Header */
.am-header {
  background: var(--am-bg);
  border-radius: var(--am-radius);
  padding: 20px 30px;
  margin-bottom: 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  box-shadow: 8px 8px 16px var(--am-shadow-dark),
    -8px -8px 16px var(--am-shadow-light);
}

.am-header-left {
  display: flex;
  align-items: center;
  gap: 15px;
}

.am-header-left h1 {
  margin: 0;
  font-size: 1.5rem;
  color: var(--am-primary);
  font-weight: 700;
}

.am-logo {
  height: 50px;
  width: auto;
  border-radius: var(--am-radius-sm);
}

.am-user-badge {
  background: var(--am-bg);
  padding: 10px 20px;
  border-radius: 50px;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 8px;
  box-shadow: inset 3px 3px 6px var(--am-shadow-dark),
    inset -3px -3px 6px var(--am-shadow-light);
}

/* Navigation */
.am-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 20px;
  padding: 15px;
  background: var(--am-bg);
  border-radius: var(--am-radius);
  box-shadow: 8px 8px 16px var(--am-shadow-dark),
    -8px -8px 16px var(--am-shadow-light);
}

.am-nav-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 20px;
  border: none;
  background: var(--am-bg);
  border-radius: var(--am-radius-sm);
  cursor: pointer;
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--am-text-muted);
  transition: all 0.3s ease;
  box-shadow: 4px 4px 8px var(--am-shadow-dark),
    -4px -4px 8px var(--am-shadow-light);
}

.am-nav-btn:hover {
  color: var(--am-primary);
}

.am-nav-btn.active {
  color: white;
  background: linear-gradient(
    135deg,
    var(--am-primary),
    var(--am-primary-dark)
  );
  box-shadow: inset 3px 3px 6px rgba(0, 0, 0, 0.2);
}

.am-nav-icon {
  font-size: 1.1rem;
}

/* Content */
.am-content {
  background: var(--am-bg);
  border-radius: var(--am-radius);
  padding: 25px;
  box-shadow: 8px 8px 16px var(--am-shadow-dark),
    -8px -8px 16px var(--am-shadow-light);
}

.am-tab-content {
  display: none;
}

.am-tab-content.active {
  display: block;
  animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Dashboard Grid & Cards Layout */
.am-dashboard-container-layout {
  display: grid;
  grid-template-columns: 4fr 6fr;
  gap: 20px;
  align-items: stretch;
}

.am-dashboard-cards-column {
  display: flex;
  flex-direction: column;
}

.am-dashboard-cards {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 15px;
  margin-bottom: 0 !important;
}

.am-card {
  background: var(--am-bg);
  border-radius: 12px;
  padding: 15px 20px;
  display: flex;
  align-items: center;
  gap: 15px;
  box-shadow: 6px 6px 12px var(--am-shadow-dark),
    -6px -6px 12px var(--am-shadow-light);
  transition: all 0.3s ease;
}

.am-card:hover {
  transform: translateY(-3px);
}

.am-card-icon {
  font-size: 2rem;
  width: 50px;
  height: 50px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: var(--am-bg);
  box-shadow: inset 3px 3px 6px var(--am-shadow-dark),
    inset -3px -3px 6px var(--am-shadow-light);
}

.am-card-body h3 {
  margin: 0 0 5px 0;
  font-size: 1.35rem;
  font-weight: 700;
}

.am-card-body p {
  margin: 0;
  color: var(--am-text-muted);
  font-size: 0.85rem;
  font-weight: 500;
}

.am-card-income .am-card-body h3 {
  color: var(--am-success);
}
.am-card-expense .am-card-body h3 {
  color: var(--am-danger);
}
.am-card-savings .am-card-body h3 {
  color: var(--am-primary);
}
.am-card-students .am-card-body h3 {
  color: var(--am-info);
}
.am-card-fees .am-card-body h3 {
  color: #059669;
}
.am-card-pending .am-card-body h3 {
  color: #dc2626;
}

.clickable-card {
  cursor: pointer;
  transition: all 0.3s ease;
}

.clickable-card:hover {
  transform: translateY(-5px);
  box-shadow: 10px 10px 20px var(--am-shadow-dark),
    -10px -10px 20px var(--am-shadow-light) !important;
}

.am-dashboard-charts-column {
  display: flex;
  flex-direction: column;
}

.am-charts-grid {
  display: grid;
  grid-template-columns: 1.25fr 0.75fr;
  gap: 20px;
  height: 100%;
}

.am-chart-card {
  background: var(--am-bg);
  border-radius: var(--am-radius);
  padding: 15px 20px;
  box-shadow: 6px 6px 12px var(--am-shadow-dark),
    -6px -6px 12px var(--am-shadow-light);
  display: flex;
  flex-direction: column;
  box-sizing: border-box;
}

.am-chart-card h3 {
  margin: 0 0 15px 0;
  font-size: 0.95rem;
  color: var(--am-text);
  font-weight: 700;
}

.am-chart-wrapper {
  position: relative;
  height: 220px;
  width: 100%;
}

@media (max-width: 1100px) {
  .am-dashboard-container-layout {
    grid-template-columns: 1fr;
  }
  .am-charts-grid {
    grid-template-columns: 1.2fr 0.8fr;
  }
}

@media (max-width: 600px) {
  .am-charts-grid {
    grid-template-columns: 1fr;
  }
  .am-dashboard-cards {
    grid-template-columns: 1fr;
  }
}

/* Chart */
.am-chart-container {
  background: var(--am-bg);
  border-radius: var(--am-radius);
  padding: 25px;
  box-shadow: inset 4px 4px 8px var(--am-shadow-dark),
    inset -4px -4px 8px var(--am-shadow-light);
}

.am-chart-container h2 {
  margin: 0 0 20px 0;
  font-size: 1.2rem;
  color: var(--am-text);
}

/* Section Header */
.am-section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
  flex-wrap: wrap;
  gap: 15px;
}

.am-section-header h2 {
  margin: 0;
  font-size: 1.4rem;
}

.am-section-actions {
  display: flex;
  align-items: center;
  gap: 15px;
  flex-wrap: wrap;
}

/* Filter Tabs */
.am-filter-tabs {
  display: flex;
  gap: 5px;
  background: var(--am-bg);
  padding: 5px;
  border-radius: var(--am-radius-sm);
  box-shadow: inset 2px 2px 4px var(--am-shadow-dark),
    inset -2px -2px 4px var(--am-shadow-light);
}

.am-filter-tabs button {
  padding: 8px 16px;
  border: none;
  background: transparent;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--am-text-muted);
  transition: all 0.2s ease;
}

.am-filter-tabs button:hover {
  color: var(--am-primary);
}

.am-filter-tabs button.active {
  background: var(--am-primary);
  color: white;
  box-shadow: 2px 2px 4px rgba(0, 0, 0, 0.1);
}

/* Buttons */
.am-btn {
  padding: 12px 24px;
  border: none;
  border-radius: var(--am-radius-sm);
  cursor: pointer;
  font-size: 0.9rem;
  font-weight: 600;
  transition: all 0.3s ease;
  background: var(--am-bg);
  color: var(--am-text);
  box-shadow: 4px 4px 8px var(--am-shadow-dark),
    -4px -4px 8px var(--am-shadow-light);
}

.am-btn:hover {
  box-shadow: 2px 2px 4px var(--am-shadow-dark),
    -2px -2px 4px var(--am-shadow-light);
}

.am-btn:active {
  box-shadow: inset 2px 2px 4px var(--am-shadow-dark),
    inset -2px -2px 4px var(--am-shadow-light);
}

.am-btn-primary {
  background: linear-gradient(
    135deg,
    var(--am-primary),
    var(--am-primary-dark)
  );
  color: white;
}

.am-btn-sm {
  padding: 6px 12px;
  font-size: 0.8rem;
}

.am-btn-danger {
  background: linear-gradient(135deg, var(--am-danger), #dc2626);
  color: white;
}

/* Search Bar */
.am-search-bar {
  margin-bottom: 20px;
}

.am-search-bar input {
  width: 100%;
  max-width: 400px;
  padding: 14px 20px;
  border: none;
  border-radius: var(--am-radius-sm);
  font-size: 1rem;
  background: var(--am-bg);
  color: var(--am-text);
  box-shadow: inset 4px 4px 8px var(--am-shadow-dark),
    inset -4px -4px 8px var(--am-shadow-light);
}

.am-search-bar input:focus {
  outline: 2px solid var(--am-primary-light);
}

/* Tables */
.am-table-container {
  overflow-x: auto;
  border-radius: var(--am-radius);
  background: var(--am-bg);
  box-shadow: inset 4px 4px 8px var(--am-shadow-dark),
    inset -4px -4px 8px var(--am-shadow-light);
}

.am-table {
  width: 100%;
  border-collapse: collapse;
}

.am-table th,
.am-table td {
  padding: 14px 16px;
  text-align: left;
}

.am-table th {
  background: transparent;
  font-weight: 600;
  color: var(--am-text-muted);
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  border-bottom: 2px solid var(--am-shadow-dark);
}

.am-table tbody tr {
  transition: background 0.2s ease;
}

.am-table tbody tr:hover {
  background: rgba(220, 38, 38, 0.05);
}

.am-table td {
  border-bottom: 1px solid var(--am-shadow-dark);
}

/* Badges */
.am-badge {
  display: inline-block;
  padding: 4px 12px;
  border-radius: 50px;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
}

.am-badge-success {
  background: #d1fae5;
  color: #065f46;
}
.am-badge-danger {
  background: #fee2e2;
  color: #991b1b;
}
.am-badge-warning {
  background: #fef3c7;
  color: #92400e;
}
.am-badge-info {
  background: #dbeafe;
  color: #1e40af;
}

.am-text-success {
  color: var(--am-success) !important;
}
.am-text-danger {
  color: var(--am-danger) !important;
}
.am-text-warning {
  color: var(--am-warning) !important;
}

/* Modal */
.am-modal {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  -webkit-backdrop-filter: blur(4px);
  backdrop-filter: blur(4px);
  z-index: 9999;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.am-modal.show {
  display: flex;
}

.am-modal-content {
  background: var(--am-bg);
  border-radius: var(--am-radius);
  width: 100%;
  max-width: 500px;
  max-height: 90vh;
  overflow: auto;
  box-shadow: 20px 20px 40px rgba(0, 0, 0, 0.3);
  animation: modalIn 0.3s ease;
}

@keyframes modalIn {
  from {
    opacity: 0;
    transform: scale(0.9);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

.am-modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 20px 25px;
  border-bottom: 1px solid var(--am-shadow-dark);
}

.am-modal-header h3 {
  margin: 0;
  font-size: 1.2rem;
}

.am-modal-close {
  background: none;
  border: none;
  font-size: 1.5rem;
  cursor: pointer;
  color: var(--am-text-muted);
  transition: color 0.2s;
}

.am-modal-close:hover {
  color: var(--am-danger);
}

.am-modal-body {
  padding: 25px;
}

/* Form */
.am-form-group {
  margin-bottom: 20px;
}

.am-form-group label {
  display: block;
  margin-bottom: 8px;
  font-weight: 500;
  color: var(--am-text);
}

.am-form-group input,
.am-form-group select,
.am-form-group textarea {
  width: 100%;
  padding: 12px 16px;
  border: none;
  border-radius: var(--am-radius-sm);
  font-size: 1rem;
  background: var(--am-bg);
  color: var(--am-text);
  box-shadow: inset 3px 3px 6px var(--am-shadow-dark),
    inset -3px -3px 6px var(--am-shadow-light);
}

.am-form-group input:focus,
.am-form-group select:focus,
.am-form-group textarea:focus {
  outline: 2px solid var(--am-primary-light);
}

/* Toast */
.am-toast {
  position: fixed;
  bottom: 30px;
  right: 30px;
  padding: 15px 25px;
  border-radius: var(--am-radius-sm);
  background: var(--am-bg-dark);
  color: white;
  font-weight: 500;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
  transform: translateY(100px);
  opacity: 0;
  transition: all 0.3s ease;
  z-index: 10000;
}

.am-toast.show {
  transform: translateY(0);
  opacity: 1;
}

.am-toast.success {
  background: var(--am-success);
}
.am-toast.error {
  background: var(--am-danger);
}

/* Reports Grid */
.am-reports-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 20px;
}

.am-report-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 30px 20px;
  background: var(--am-bg);
  border-radius: var(--am-radius);
  text-decoration: none;
  color: var(--am-text);
  font-weight: 500;
  box-shadow: 4px 4px 8px var(--am-shadow-dark),
    -4px -4px 8px var(--am-shadow-light);
  transition: all 0.3s ease;
}

.am-report-card:hover {
  transform: translateY(-3px);
  color: var(--am-primary);
}

.am-report-icon {
  font-size: 2rem;
}

/* Responsive */
@media (max-width: 768px) {
  .am-portal {
    padding: 10px;
  }

  .am-header {
    flex-direction: column;
    gap: 15px;
    text-align: center;
  }

  .am-nav {
    justify-content: center;
  }

  .am-nav-btn span:last-child {
    display: none;
  }

  .am-section-header {
    flex-direction: column;
    align-items: flex-start;
  }

  .am-dashboard-cards {
    grid-template-columns: 1fr 1fr;
  }
}

@media (max-width: 480px) {
  .am-dashboard-cards {
    grid-template-columns: 1fr;
  }

  .am-card {
    flex-direction: column;
    text-align: center;
  }
}

/* Loading */
.am-loading {
  display: flex;
  justify-content: center;
  padding: 40px;
}

.am-spinner {
  width: 40px;
  height: 40px;
  border: 4px solid var(--am-shadow-dark);
  border-top-color: var(--am-primary);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* Status Dropdown */
.am-status-select {
  padding: 6px 10px;
  border: none;
  border-radius: 6px;
  font-size: 0.8rem;
  font-weight: 500;
  background: var(--am-bg);
  color: var(--am-text);
  cursor: pointer;
  box-shadow: inset 2px 2px 4px var(--am-shadow-dark),
    inset -2px -2px 4px var(--am-shadow-light);
}

.am-status-select:focus {
  outline: 2px solid var(--am-primary-light);
}

/* Accordion for Installments */
.am-accordion {
  margin-bottom: 15px;
  background: var(--am-bg);
  border-radius: var(--am-radius);
  box-shadow: 4px 4px 8px var(--am-shadow-dark),
    -4px -4px 8px var(--am-shadow-light);
  overflow: hidden;
}

.am-accordion-header {
  padding: 15px 20px;
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 1rem;
  background: var(--am-bg);
  list-style: none;
}

.am-accordion-header::-webkit-details-marker {
  display: none;
}

.am-accordion-header::after {
  content: "▸";
  transition: transform 0.2s;
}

.am-accordion[open] .am-accordion-header::after {
  transform: rotate(90deg);
}

.am-accordion .am-table {
  margin: 0;
}

.am-accordion .am-table-container {
  box-shadow: none;
  border-radius: 0;
}

/* Amount Input Width Fix */
.am-input-amount,
.am-form-group input[type="number"] {
  width: 100% !important;
  min-width: 100% !important;
  display: block !important;
  box-sizing: border-box !important;
}

/* Row Danger */
.am-row-danger {
  background-color: #fef2f2 !important;
}

/* Fullscreen Mode */
.am-fullscreen-mode {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  z-index: 999999;
  background: var(--am-bg);
  overflow-y: auto;
  padding: 0 !important;
  margin: 0 !important;
}

.am-fullscreen-mode .am-header,
.am-fullscreen-mode .am-nav,
.am-fullscreen-mode .am-content {
  border-radius: 0;
  max-width: 100%;
  margin-bottom: 0;
  box-shadow: none;
}

.am-fullscreen-mode .am-header {
  border-bottom: 1px solid var(--am-shadow-dark);
}

.am-fullscreen-mode .am-content {
  min-height: calc(100vh - 140px); /* Adjust for header/nav */
}

/* Student Details Overlay (Frosted Glass) */
.am-frosted-modal {
  -webkit-backdrop-filter: blur(15px) saturate(180%);
  backdrop-filter: blur(15px) saturate(180%);
  background-color: rgba(0, 0, 0, 0.3);
}

.am-frosted-modal .am-modal-content {
  background-color: rgba(255, 255, 255, 0.65);
  -webkit-backdrop-filter: blur(20px);
  backdrop-filter: blur(20px);
  border: 1px solid rgba(255, 255, 255, 0.4);
  box-shadow: 0 8px 32px 0 rgba(31, 38, 135, 0.37);
  border-radius: 24px;
  color: #000;
}

.am-frosted-modal .am-modal-header {
  border-bottom: 1px solid rgba(0, 0, 0, 0.1);
}

.am-frosted-modal .am-modal-close {
  color: #333;
}

/* Student Name Cell in Table */
.am-student-name-cell {
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 12px;
}

.am-student-name-cell:hover strong {
  color: var(--am-primary);
  text-decoration: underline;
}

.am-student-avatar {
  width: 32px;
  height: 32px;
  background: var(--am-primary);
  color: white;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: bold;
  font-size: 0.9rem;
  flex-shrink: 0;
}

.am-meta {
  color: var(--am-text-muted);
  font-size: 0.75rem;
  display: block;
  line-height: 1.2;
}

/* Student Details Grid in Modal */
.am-student-details-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  margin-bottom: 25px;
}

.am-details-card {
  background: rgba(255, 255, 255, 0.5);
  padding: 15px;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.6);
}

.am-details-card h4 {
  margin: 0 0 10px 0;
  color: var(--am-primary);
  font-size: 1rem;
  border-bottom: 1px solid rgba(0, 0, 0, 0.1);
  padding-bottom: 5px;
}

.am-details-card p {
  margin: 5px 0;
  font-size: 0.9rem;
  display: flex;
  justify-content: space-between;
}

/* Header Right */
.am-header-right {
  display: flex;
  align-items: center;
  gap: 10px;
}

/* Fullscreen Button */
#am-fullscreen-btn {
  padding: 8px 12px;
  font-size: 1.2rem;
  background: var(--am-bg);
  border: none;
  border-radius: var(--am-radius-sm);
  cursor: pointer;
  box-shadow: 3px 3px 6px var(--am-shadow-dark),
    -3px -3px 6px var(--am-shadow-light);
}

#am-fullscreen-btn:hover {
  color: var(--am-primary);
}

/* Action buttons spacing */
.am-table td .am-btn {
  margin-right: 5px;
  margin-bottom: 3px;
}

.am-table td .am-btn:last-child {
  margin-right: 0;
}

/* Course Overview Grid */
.am-course-overview-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(350px, 1fr));
  gap: 25px;
  margin-top: 20px;
}

.am-course-card {
  background: var(--am-bg);
  border-radius: var(--am-radius);
  padding: 0;
  box-shadow: 8px 8px 16px var(--am-shadow-dark),
    -8px -8px 16px var(--am-shadow-light);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transition: transform 0.3s ease;
}

.am-course-card:hover {
  transform: translateY(-5px);
}

.am-course-card-header {
  padding: 15px 20px;
  background: linear-gradient(135deg, #4b5563, #1f2937);
  color: white;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.am-course-card-header h3 {
  margin: 0;
  font-size: 1.1rem;
  font-weight: 600;
  color: white;
}

.am-course-card-body {
  padding: 15px;
  flex-grow: 1;
  max-height: 400px;
  overflow-y: auto;
}

.am-co-student-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px;
  border-bottom: 1px solid var(--am-shadow-dark);
  transition: background 0.2s;
}

.am-co-student-item:last-child {
  border-bottom: none;
}

.am-co-student-item:hover {
  background: rgba(0, 0, 0, 0.02);
}

.am-co-student-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.am-co-student-name {
  font-weight: 600;
  font-size: 0.95rem;
  color: var(--am-text);
}

.am-co-student-meta {
  font-size: 0.8rem;
  color: var(--am-text-muted);
}

.am-course-card-footer {
  padding: 12px 20px;
  background: rgba(0, 0, 0, 0.03);
  border-top: 1px solid var(--am-shadow-dark);
  font-size: 0.85rem;
  font-weight: 600;
  text-align: right;
  color: var(--am-text-muted);
}
