/**
 * Bagrut Calculator & Sticky Strip Styles
 * Version: 2.0
 * Author: Givat Washington
 */

/* ========================================
   Sticky Strip Styles - Side Drawer
   ======================================== */
.class-sticky-strip {
  position: fixed;
  top: 50%;
  transform: translateY(-50%);
  right: 0;
  z-index: 10000;
  pointer-events: none;
}

/* Toggle Button - Rotated 90 degrees, fixed to right side */
.strip-toggle-btn {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  right: 1.2rem;
  transform: translateY(-50%) translateX(50%) rotate(-90deg);
  transform-origin: center center;
  background-color: #001f3f;
  color: #fff;
  border: 0;
  padding: 1rem 2rem;
  cursor: pointer;
  font-size: 1.1rem;
  font-weight: 600;
  white-space: nowrap;
  border-radius: 10px 10px 0 0;
  box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.2);
  z-index: 10001;
  pointer-events: all;
  transition: background-color 0.3s;
}

.strip-toggle-btn:hover {
  background-color: #003366;
}

.strip-toggle-btn span {
  display: block;
}

/* Drawer - Slides from right */
.strip-drawer {
  position: relative;
  right: -600px;
  width: 90vw;
  max-width: 460px;
  height: auto;
  max-height: 90vh;
  background-color: #f5f5f5;
  box-shadow: -2px 0 20px rgba(0, 0, 0, 0.3);
  overflow-y: auto;
  transition: right 0.4s ease;
  pointer-events: all;
  z-index: 10000;
  border-radius: 10px 0 0 10px;
  padding-right: 3rem;
}

.strip-drawer.open {
  right: 0;
}

/* Drawer Header */
.strip-header {
  background-color: #001f3f;
  color: #fff;
  padding: 1.5rem 2rem;
  margin: 0;
  border-bottom: 3px solid #ffc300;
}

.strip-header h2 {
  margin: 0;
  font-size: 1.5rem;
  font-weight: 600;
}

.strip-content {
  padding: 2rem;
}

.strip-content-inner {
  width: 100%;
}

.class-sticky-strip form {
  width: 100%;
  display: flex;
  gap: 0.8rem;
  align-items: center;
  flex-wrap: nowrap;
  flex-direction: column;
}

.class-sticky-strip fieldset {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  margin: 0;
  padding: 0;
  border: 0;
  width: 100%;
}

.class-sticky-strip input[type="text"],
.class-sticky-strip input[type="number"] {
  padding: 0.75rem 1rem;
  border: 1px solid #ddd;
  border-radius: 5px;
  font-size: 1rem;
}

.class-sticky-strip input::placeholder {
  color: #999;
}

/* Buttons inherit theme styles */
.class-sticky-strip .button,
.class-sticky-strip input[type="submit"] {
  white-space: nowrap;
}

/* ========================================
   Modal Styles
   ======================================== */
.bc-modal {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 10000;
}

.bc-modal-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(3px);
}

.bc-modal-content {
  position: relative;
  max-width: 950px;
  max-height: 90vh;
  margin: 2rem auto;
  background: #fff;
  border-radius: 12px;
  overflow-y: auto;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
  animation: modalSlideIn 0.3s ease-out;
}

@keyframes modalSlideIn {
  from {
    opacity: 0;
    transform: translateY(-50px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.bc-modal-close {
  position: absolute;
  top: 1rem;
  right: 1rem;
  background: transparent;
  border: 0;
  font-size: 2rem;
  line-height: 1;
  cursor: pointer;
  color: #666;
  z-index: 10;
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  transition: all 0.2s;
}

.bc-modal-close:hover {
  background: #f0f0f0;
  color: #000;
}

/* ========================================
   Bagrut Calculator Styles
   ======================================== */
.bagrut-calculator {
  font-family: system-ui, -apple-system, Arial, sans-serif;
  padding: 2rem;
}

.bagrut-calculator h2 {
  text-align: center;
}

.bc-toolbar {
  display: flex;
  gap: 1rem;
  align-items: center;
  margin: 0 0 1.5rem;
  flex-wrap: wrap;
}

/* Toolbar buttons inherit theme styles */
.bc-toolbar button {
  cursor: pointer;
}

.bc-toolbar label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-weight: 500;
}

/* Select inherits theme styles */
.bc-toolbar select {
  cursor: pointer;
}

.bc-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  margin-bottom: 1.5rem;
  border: 1px solid #ddd;
}

.bc-table th,
.bc-table td {
  border-right: 1px solid #ddd;
  border-bottom: 1px solid #ddd;
  padding: 0.75rem;
  text-align: center;
}

.bc-table th:last-child,
.bc-table td:last-child {
  border-right: 0;
}

.bc-table tbody tr:last-child td {
  border-bottom: 0;
}

.bc-table thead {
  background-color: #001f3f;
  color: #fff;
}

.bc-table thead th {
  font-weight: 600;
  border-color: #001f3f;
  border-bottom-color: #001f3f;
}

.bc-table tbody tr {
  transition: background-color 0.2s;
}

.bc-table tbody tr:hover {
  background-color: #f8f9fa;
}

.bc-table tbody tr.bc-required {
  background-color: #e3f2fd;
}

.bc-table tbody tr.bc-required:hover {
  background-color: #bbdefb;
}

.bc-table input[type="number"] {
  width: 90px;
  padding: 0.5rem;
  border: 1px solid #ddd;
  border-radius: 4px;
  text-align: center;
  font-size: 1rem;
}

.bc-table input[type="number"]:focus {
  outline: none;
  border-color: #3498db;
}

.bc-table input[type="text"] {
  width: 100%;
  padding: 0.5rem;
  border: 1px solid #ddd;
  border-radius: 4px;
  font-size: 1rem;
}

.bc-table input[type="text"]:focus {
  outline: none;
  border-color: #3498db;
}

/* Select in table inherits theme styles */
.bc-table select {
  width: 100%;
  cursor: pointer;
}

.bc-name-wrap {
  position: relative;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  justify-content: center;
}

.bc-remove {
  position: absolute;
  inset-inline-end: 0.25rem;
  inset-block-start: 0.2rem;
  background: transparent;
  border: 0;
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
  color: #666;
  padding: 0.25rem;
  transition: color 0.2s;
}

.bc-remove:hover {
  color: #e74c3c;
}

.bc-required .bc-remove {
  display: none;
}

.bc-summary {
  margin-top: 1.5rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  font-size: 1.1rem;
  padding: 1rem 1.5rem;
  background-color: #f8f9fa;
  border-radius: 8px;
  flex-wrap: wrap;
}

.bc-summary-results {
  display: flex;
  gap: 2rem;
  flex-wrap: wrap;
  align-items: center;
}

.bc-summary-results > div {
  display: flex;
  gap: 0.5rem;
  align-items: center;
}

.bc-summary strong {
  color: #3498db;
  font-size: 1.3rem;
}

.bc-after {
  font-weight: 600;
  color: #3498db;
}

/* ========================================
   Responsive Styles
   ======================================== */
@media screen and (max-width: 768px) {
  /* Drawer takes full width on mobile */
  .strip-drawer {
    width: 100vw;
    max-width: 100vw;
    right: -100vw;
    padding-right: 3rem;
    /* Keep centered vertically */
    max-height: 80vh;
  }
  
  .strip-drawer.open {
    right: 0;
  }
  
  /* Button stays rotated on mobile too */
  .strip-toggle-btn {
    font-size: 1rem;
    padding: 0.75rem 1.5rem;
  }
  
  /* Header adjustments */
  .strip-header {
    padding: 1rem 1.5rem;
  }
  
  .strip-header h2 {
    font-size: 1.2rem;
  }
  
  /* Adjust padding */
  .strip-content {
    padding: 1.5rem 1rem;
  }
  
  /* Form adjustments */
  .class-sticky-strip form {
    flex-direction: column;
    gap: 0.5rem;
  }
  
  .class-sticky-strip fieldset {
    width: 100%;
    flex-direction: column;
  }
  
  .class-sticky-strip .button,
  .class-sticky-strip input {
    width: 100%;
  }
  
  .bc-modal-content {
    margin: 1rem;
    max-height: 95vh;
  }
  
  .bagrut-calculator {
    padding: 1rem;
  }
  
  .bc-toolbar {
    flex-direction: column;
    align-items: stretch;
  }
  
  .bc-toolbar button,
  .bc-toolbar label {
    width: 100%;
    justify-content: center;
  }
  
  .bc-table {
    font-size: 0.9rem;
  }
  
  .bc-table th,
  .bc-table td {
    padding: 0.5rem;
  }
  
  .bc-table input[type="number"] {
    width: 70px;
  }
  
  .bc-summary {
    flex-direction: column;
    gap: 1rem;
    text-align: center;
  }
  
  .bc-summary-results {
    flex-direction: column;
    gap: 0.75rem;
    width: 100%;
  }
  
  .bc-summary .button {
    width: 100%;
  }
}

/* Card Layout for Mobile - Better UX */
@media screen and (max-width: 600px) {
  /* Make modal full screen on mobile */
  .bc-modal-content {
    margin: 0;
    max-height: 100vh;
    height: 100vh;
    border-radius: 0;
    width: 100%;
  }
  
  .bagrut-calculator {
    padding: 1rem;
  }
  
  .bagrut-calculator h2 {
    margin-bottom: 1rem;
  }
  
  .bc-toolbar {
    gap: 0.5rem;
  }
  
  .bc-toolbar button {
    padding: 0.6rem 1rem;
    font-size: 1rem;
  }
  
  /* Convert table to card layout */
  .bc-table {
    display: block;
    border: 0;
  }
  
  .bc-table thead {
    display: none; /* Hide table headers */
  }
  
  .bc-table tbody {
    display: block;
  }
  
  .bc-table tr {
    display: block;
    margin-bottom: 1rem;
    border: 1px solid #ddd;
    border-radius: 8px;
    padding: 1rem;
    background-color: #fff;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
  }
  
  .bc-table tr.bc-required {
    border-right: 4px solid #3498db;
  }
  
  .bc-table td {
    display: block;
    border: 0;
    padding: 0.5rem 0;
    text-align: right;
  }
  
  /* Add labels before each field */
  .bc-table td:nth-child(1)::before {
    content: "מקצוע:";
    font-weight: 600;
    display: block;
    margin-bottom: 0.3rem;
    color: #001f3f;
  }
  
  .bc-table td:nth-child(2)::before {
    content: "יחידות לימוד:";
    font-weight: 600;
    display: block;
    margin-bottom: 0.3rem;
    color: #001f3f;
  }
  
  .bc-table td:nth-child(3)::before {
    content: "ציון:";
    font-weight: 600;
    display: block;
    margin-bottom: 0.3rem;
    color: #001f3f;
  }
  
  .bc-table td:nth-child(4)::before {
    content: "לאחר הבונוס:";
    font-weight: 600;
    display: block;
    margin-bottom: 0.3rem;
    color: #001f3f;
  }
  
  /* Full width inputs */
  .bc-table input[type="number"],
  .bc-table input[type="text"],
  .bc-table select {
    width: 100%;
    padding: 0.5rem;
    font-size: 1rem;
  }
  
  /* After bonus as text */
  .bc-after {
    display: block;
    font-size: 1.2rem;
    padding: 0.5rem;
    background-color: #e3f2fd;
    border-radius: 5px;
    text-align: center;
  }
  
  /* Name wrap adjustments */
  .bc-name-wrap {
    justify-content: flex-start;
  }
  
  .bc-remove {
    position: static;
    margin-right: auto;
    font-size: 20px;
    padding: 0.5rem;
    color: #e74c3c;
  }
  
  /* Summary adjustments */
  .bc-summary {
    padding: 1rem;
    font-size: 1rem;
  }
  
  .bc-summary strong {
    font-size: 1.3rem;
  }
}

button.bc-open-modal {
  color: #ffc300;
  font-size: 12px;
  padding: 0.5rem;
  border-radius: 10px;
  gap: 0.5rem;
}

button.bc-open-modal svg {
  display: block;
}
