/* =========================================
   BILLING.CSS - COMPREHENSIVE STYLES
   Billing system interface with responsive design
   ========================================= */

/* =========================================
   BASE BILLING CONTAINER
   ========================================= */

.billing {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 0;
  min-height: 500px;
  margin: 0;
  align-items: center;
  justify-content: flex-start;
  padding: 20px 0;
}

/* =========================================
   CONTENT WRAPPER - MATCH SITE STYLE
   ========================================= */

.billing-container {
  max-width: 1200px;
  margin: 20px auto;
  background-color: white;
  border-radius: 25px;
  padding: 40px;
  box-sizing: border-box;
  color: #333;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
  width: calc(100% - 40px);
  overflow: visible;
}

/* =========================================
   BILLING HEADER
   ========================================= */

.billing-header {
  text-align: center;
  margin-bottom: 40px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 15px;
}

.billing-header h1 {
  font-size: 2.2rem;
  color: #222;
  margin: 0;
  font-weight: 700;
}

.billing-header p {
  font-size: 1.1rem;
  color: #666;
  max-width: 700px;
  margin: 0;
  line-height: 1.6;
}

/* =========================================
   LOADING STATES
   ========================================= */

.billing-loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 60px 20px;
  text-align: center;
}

.billing-spinner {
  width: 40px;
  height: 40px;
  border: 4px solid #f3f3f3;
  border-top: 4px solid #0066cc;
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin-bottom: 20px;
}

@keyframes spin {
  0% {
    transform: rotate(0deg);
  }
  100% {
    transform: rotate(360deg);
  }
}

.billing-loading p {
  color: #666;
  font-size: 1.1rem;
  margin: 0;
}

/* =========================================
   BILLING CARDS
   ========================================= */

.billing-card {
  background: #f8f8f8;
  border-radius: 16px;
  padding: 30px;
  margin-bottom: 30px;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
  transition: background-color 0.3s ease, opacity 0.3s ease;
}

.billing-card:hover {
  background-color: #f0f0f0;
}

.billing-current-plan {
  display: flex;
  justify-content: space-between;
}

.billing-card h3 {
  font-size: 1.4rem;
  margin-bottom: 20px;
  color: #222;
  font-weight: 700;
}

/* =========================================
   PLAN SELECTION STYLES
   ========================================= */

.billing-plans {
  display: grid;
  gap: 30px;
  margin-top: 30px;
  justify-items: center;
}

/* Default: 3 column layout */
.billing-plans-three {
  grid-template-columns: repeat(3, 1fr);
}

/* 2 plans: centered 2 column layout */
.billing-plans-two {
  grid-template-columns: repeat(2, 1fr);
  max-width: 800px;
  margin: 30px auto 0;
}

/* Fallback for other counts */
.billing-plans-default {
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
}

/* Responsive breakpoints for different plan layouts */
@media (max-width: 1200px) {
  .billing-container {
    max-width: 1000px;
  }

  .billing-plans-three {
    grid-template-columns: 1fr;
  }

  .billing-plans-two {
    grid-template-columns: 1fr;
    max-width: 500px;
  }

  .billing-plans-default {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 1024px) {
  .billing-container {
    max-width: 900px;
  }
}

@media (max-width: 640px) {
  .billing-container {
    max-width: 600px;
  }
}

.billing-plan-card {
  background: #e9e9e9;
  border-radius: 16px;
  padding: 30px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
  transition: background-color 0.3s ease, border-color 0.3s ease,
    opacity 0.3s ease;
  border: 2px solid #e9ecef;
  position: relative;
  display: flex;
  flex-direction: column;
  max-width: 400px;
}

.billing-plan-card:hover {
  background-color: #f8f9fa;
  border-color: #0066cc;
}

.billing-plan-header {
  text-align: center;
  margin-bottom: 25px;
  padding-bottom: 20px;
  border-bottom: 2px solid #f8f9fa;
}

.billing-plan-header h3 {
  font-size: 1.6rem;
  color: #222;
  margin-bottom: 10px;
  font-weight: 700;
}

.billing-price {
  font-size: 1.2rem;
  color: #222;
  font-weight: 800;
  margin-bottom: 5px;
}

.billing-period {
  font-size: 1rem;
  color: #666;
  font-weight: 400;
}

.billing-plan-features {
  flex-grow: 1;
  margin-bottom: 25px;
}

.billing-feature {
  display: flex;
  align-items: center;
  padding: 8px 0;
  color: #495057;
  font-size: 1rem;
}

.billing-feature-check {
  color: #28a745;
  margin-right: 12px;
  font-weight: bold;
  font-size: 16px;
}

/* =========================================
   SUBSCRIPTION DASHBOARD
   ========================================= */

.billing-dashboard {
  display: flex;
  flex-direction: column;
  gap: 25px;
}

.billing-plan-info {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 15px;
}

.billing-plan-name {
  font-weight: 600;
  color: #495057;
}

.billing-info-grid {
  display: grid;
  gap: 15px;
}

.billing-info-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 0;
  border-bottom: 1px solid #e9ecef;
}

.billing-info-item:last-child {
  border-bottom: none;
}

.billing-info-item label {
  font-weight: 600;
  color: #495057;
  margin: 0;
}

.billing-info-item span {
  color: #212529;
  font-weight: 500;
}

/* =========================================
   STATUS BADGES
   ========================================= */

.billing-badge {
  display: inline-block;
  padding: 6px 12px;
  border-radius: 20px;
  font-size: 0.85rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.billing-badge-success {
  background-color: #d4edda;
  color: #155724;
  border: 1px solid #c3e6cb;
}

.billing-badge-warning {
  background-color: #fff3cd;
  color: #856404;
  border: 1px solid #ffeaa7;
}

.billing-badge-danger {
  background-color: #f8d7da;
  color: #721c24;
  border: 1px solid #f5c6cb;
}

.billing-badge-info {
  background-color: #d1ecf1;
  color: #0c5460;
  border: 1px solid #bee5eb;
}

.billing-badge-secondary {
  background-color: #e2e3e5;
  color: #383d41;
  border: 1px solid #d6d8db;
}

/* =========================================
   WARNING MESSAGES
   ========================================= */

.billing-warning {
  background: #fff3cd;
  color: #856404;
  padding: 15px;
  border-radius: 8px;
  border: 1px solid #ffeaa7;
  margin-top: 15px;
  font-weight: 500;
}

/* =========================================
   BUTTONS
   ========================================= */

.billing-btn {
  display: inline-block;
  padding: 12px 24px;
  border-radius: 8px;
  font-weight: 600;
  text-decoration: none;
  transition: all 0.3s ease;
  font-size: 1rem;
  border: none;
  cursor: pointer;
  text-align: center;
  min-height: 44px;
  box-sizing: border-box;
  line-height: 1.2;
}

.billing-btn-primary {
  background-color: #0066cc;
  color: white;
}

.billing-btn-primary:hover {
  background-color: #004d99;
}

.billing-btn-secondary {
  background-color: #6c757d;
  color: white;
}

.billing-btn-secondary:hover {
  background-color: #545b62;
}

.billing-btn-success {
  background-color: #28a745;
  color: white;
}

.billing-btn-success:hover {
  background-color: #218838;
}

.billing-btn-danger {
  background-color: #dc3545;
  color: white;
}

.billing-btn-danger:hover {
  background-color: #c82333;
}

.billing-actions {
  display: flex;
  gap: 15px;
  flex-wrap: wrap;
  margin-top: 15px;
}

.billing-actions .billing-btn {
  max-width: 250px;
}

/* Center content in manage subscription card */
.billing-card:has(.billing-actions) {
  text-align: center;
}

.billing-card:has(.billing-actions) p {
  text-align: center;
}

.billing-actions {
  justify-content: center;
}

/* Equal width buttons on larger screens */
@media (min-width: 769px) {
  .billing-actions {
    display: flex;
    gap: 15px;
  }

  .billing-actions .billing-btn {
    flex: 1;
    text-align: center;
  }
}

/* =========================================
   MODAL STYLES
   ========================================= */

.billing-modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.5);
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  box-sizing: border-box;
}

.billing-modal-content {
  background: white;
  border-radius: 16px;
  padding: 30px;
  max-width: 500px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  position: relative;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
}

.billing-modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
  padding-bottom: 15px;
  border-bottom: 2px solid #f8f9fa;
}

.billing-modal-header h3 {
  margin: 0;
  font-size: 1.5rem;
  color: #222;
  font-weight: 700;
}

.billing-modal-close {
  background: none;
  border: none;
  font-size: 24px;
  cursor: pointer;
  padding: 5px;
  color: #666;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.billing-modal-close:hover {
  color: #222;
}

.billing-modal-actions {
  display: flex;
  gap: 15px;
  justify-content: flex-end;
  margin-top: 25px;
  flex-wrap: wrap;
}

/* =========================================
   FORM STYLES
   ========================================= */

.billing-form-group {
  margin-bottom: 20px;
}

.billing-form-group label {
  display: block;
  margin-bottom: 8px;
  font-weight: 600;
  color: #495057;
}

.billing-form-group select,
.billing-form-group textarea,
.billing-form-group input {
  width: 100%;
  padding: 12px;
  border: 2px solid #e9ecef;
  border-radius: 8px;
  font-size: 1rem;
  transition: border-color 0.3s ease;
  box-sizing: border-box;
}

.billing-form-group select:focus,
.billing-form-group textarea:focus,
.billing-form-group input:focus {
  outline: none;
  border-color: #0066cc;
}

.billing-radio-group {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 10px;
}

.billing-radio-group label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 500;
  cursor: pointer;
}

.billing-radio-group input[type="radio"] {
  width: auto;
  margin: 0;
}

/* =========================================
   NOTIFICATIONS
   ========================================= */

.billing-notification {
  position: fixed;
  top: 20px;
  right: 20px;
  padding: 15px 20px;
  border-radius: 8px;
  color: white;
  font-weight: 600;
  z-index: 10000;
  max-width: 400px;
  animation: slideIn 0.3s ease-out;
  display: flex;
  justify-content: space-between;
  align-items: center;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

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

.billing-notification-success {
  background-color: #28a745;
}

.billing-notification-error {
  background-color: #dc3545;
}

.billing-notification-info {
  background-color: #17a2b8;
}

.billing-notification-close {
  background: none;
  border: none;
  color: white;
  font-size: 18px;
  cursor: pointer;
  padding: 0;
  margin-left: 10px;
  opacity: 0.8;
  transition: opacity 0.2s ease;
}

.billing-notification-close:hover {
  opacity: 1;
}

/* =========================================
   RESPONSIVE BREAKPOINTS
   ========================================= */

/* Large tablets and below (1240px and below) */
@media (max-width: 1240px) {
  .billing-container {
    margin: 20px;
    width: calc(100% - 40px);
  }
}

/* Tablets (992px and below) */
@media (max-width: 992px) {
  .billing-container {
    max-width: 800px;
    padding: 30px;
  }

  .billing-header h1 {
    font-size: 1.8rem;
  }
}

/* Small tablets and large phones (768px and below) */
@media (max-width: 768px) {
  .billing {
    padding: 15px 0;
  }

  .billing-container {
    max-width: 700px;
    padding: 20px;
    margin: 15px;
    width: calc(100% - 30px);
  }

  .billing-header h1 {
    font-size: 1.6rem;
  }

  .billing-header p {
    font-size: 1rem;
  }

  .billing-card {
    padding: 20px;
  }

  .billing-plan-card {
    padding: 25px;
  }

  .billing-actions {
    flex-direction: column;
  }

  .billing-btn {
    width: 100%;
    text-align: center;
  }

  .billing-modal-content {
    padding: 20px;
    margin: 10px;
  }

  .billing-modal-actions {
    flex-direction: column;
  }

  .billing-notification {
    right: 10px;
    left: 10px;
    max-width: none;
  }
}

.billing-plan-info {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 20px;
}

.billing-plan-status {
  display: flex;
  align-items: center;
  gap: 0;
  flex: 1;
}

.billing-status {
  margin-left: 15px;
}

.billing-plan-price {
  font-weight: 500;
  color: #212529;
  text-align: right;
}

/* Small phones (480px and below) */
@media (max-width: 480px) {
  .billing-container {
    max-width: 100%;
    padding: 15px;
    margin: 10px;
    width: calc(100% - 20px);
  }

  .billing-header h1 {
    font-size: 1.4rem;
  }

  .billing-card {
    padding: 15px;
  }

  .billing-plan-card {
    padding: 20px;
  }

  .billing-price {
    font-size: 1.8rem;
  }

  .billing-modal-content {
    padding: 15px;
  }

  .billing-plan-info {
    flex-direction: column;
    align-items: flex-start;
    gap: 15px;
  }

  .billing-plan-status {
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
    width: 100%;
  }

  .billing-status {
    margin-left: 0;
    margin-top: 5px;
  }

  .billing-plan-price {
    text-align: left;
    font-size: 1.3rem;
  }
}

/* Very small phones (375px and below) */
@media (max-width: 375px) {
  .billing {
    padding: 10px 0;
  }

  .billing-container {
    border-radius: 15px;
  }

  .billing-header h1 {
    font-size: 1.3rem;
  }

  .billing-btn {
    padding: 10px 20px;
    font-size: 0.9rem;
  }
}

/* =========================================
   CHANGE PLAN MODAL STYLES
   ========================================= */

.change-plan-option {
  border: 2px solid #e0e0e0;
  border-radius: 12px;
  padding: 20px;
  margin-bottom: 15px;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 15px;
  transition: all 0.3s ease;
}

.change-plan-option:hover {
  border-color: #007cba;
  box-shadow: 0 2px 8px rgba(0, 124, 186, 0.1);
}

.plan-info {
  flex: 1;
  display: flex;
  flex-direction: row;
  justify-content: space-between;
  align-items: center;
}

.plan-info h4 {
  color: #333;
  font-size: 1.2rem;
}

.plan-price {
  font-size: 1.1rem;
  font-weight: bold;
  color: #222;
  margin: 10px 0;
}

.plan-description {
  margin: 5px 0 0 0;
  color: #666;
  font-size: 0.9rem;
}

.current-plan-info {
  color: #333;
  padding: 15px;
  border-radius: 8px;
  margin-bottom: 20px;
  text-align: center;
  font-weight: 700;
  font-size: 22px;
  background-color: #e6e6e6;
}

.available-plans h4 {
  color: #333;
  margin: 10px 0;
}

.change-plan-notice {
  background: #e3f2fd;
  padding: 15px;
  border-radius: 8px;
  margin-top: 20px;
  border-left: 4px solid #2196f3;
}

.change-plan-notice p {
  margin: 0;
  color: #1565c0;
}

@media (max-width: 768px) {
  .plan-info {
    flex-direction: column;
    align-items: flex-start;
    gap: 5px;
  }

  .change-plan-option button {
    width: 100%;
  }
}

/* =========================================
   POWERED BY STRIPE
   ========================================= */

.powered-by-stripe {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-top: 20px;
  padding: 15px;
  opacity: 0.7;
  font-size: 14px;
  color: #666;
}

.powered-by-stripe img {
  height: 16px;
  width: auto;
  filter: opacity(0.7);
}

.powered-by-stripe:hover {
  opacity: 1;
}

.powered-by-stripe:hover img {
  filter: opacity(1);
}

/* =========================================
   INVOICE CARD STYLES
   ========================================= */

.billing-invoice-info {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 20px;
}

.billing-invoice-details {
  display: flex;
  flex-direction: column;
  gap: 12px;
  flex: 1;
}

.billing-invoice-status {
  padding: 4px 8px;
  border-radius: 4px;
  font-size: 0.85rem;
  font-weight: 600;
  text-transform: capitalize;
}

.billing-invoice-status.paid {
  background: #e8f5e8;
  color: #2e7d32;
}

.billing-invoice-status.pending {
  background: #fff3e0;
  color: #f57c00;
}

.billing-invoice-status.failed {
  background: #ffebee;
  color: #d32f2f;
}

.billing-invoice-actions {
  margin-top: 15px;
  display: flex;
  justify-content: flex-end;
}

@media (max-width: 768px) {
  .billing-invoice-info {
    flex-direction: column;
    gap: 15px;
  }

  .billing-invoice-details {
    gap: 10px;
  }

  .billing-invoice-actions {
    align-self: stretch;
  }

  .billing-invoice-actions button {
    width: 100%;
  }
}

/* =========================================
   COMPACT PLAN DISPLAY (SUBSCRIPTION MANAGEMENT)
   ========================================= */

.billing-plans-compact {
  display: flex;
  flex-direction: row;
  gap: 20px;
  margin-top: 20px;
}

.billing-plan-card-compact {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  align-items: center;
  padding: 20px;
  border: 2px solid #e5e7eb;
  border-radius: 12px;
  background: #f9fafb;
  transition: all 0.3s ease;
  flex: 1;
  text-align: center;
  min-height: 120px;
}

.billing-plan-card-compact:hover {
  border-color: #3b82f6;
  background: #eff6ff;
}

.billing-plan-card-compact.current-plan {
  border-color: #10b981;
  background: #ecfdf5;
}

.billing-plan-header-compact {
  display: flex;
  flex-direction: column;
  gap: 5px;
  margin-bottom: 15px;
}

.billing-plan-header-compact h4 {
  margin: 0;
  font-size: 18px;
  font-weight: 600;
  color: #1f2937;
}

.billing-price-compact {
  font-size: 16px;
  font-weight: 500;
  color: #6b7280;
}

.billing-current-badge {
  background: #10b981;
  color: white;
  padding: 8px 16px;
  border-radius: 20px;
  font-size: 14px;
  font-weight: 500;
  text-align: center;
}

.billing-btn-small {
  padding: 10px 20px;
  font-size: 14px;
  border-radius: 8px;
  white-space: nowrap;
}

.billing-btn-secondary {
  background: #6b7280;
  color: white;
  border: none;
}

.billing-btn-secondary:hover {
  background: #4b5563;
}

@media (max-width: 768px) {
  .billing-plan-card-compact {
    flex-direction: column;
    gap: 15px;
    text-align: center;
  }

  .billing-plan-header-compact {
    align-items: center;
  }

  .billing-btn-small {
    width: 100%;
  }
}
