/* General Reset and Body Styling */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html, body {
    height: 100%;
    min-height: 100vh;
    overflow-x: hidden; /* Prevent horizontal scroll */
}

body {
    font-family: 'Space Mono', monospace; /* Consistent font */
    background-color: #0e0e2c; /* Deep space background color */
    color: #e0e0e0; /* Light text color */
    position: relative;
    display: flex;
    flex-direction: column;
}

/* Background gradient and image overlay for space theme */
body::before {
    content: "";
    position: fixed;
    top: 0; left: 0;
    height: 100vh; width: 100vw;
    background: radial-gradient(ellipse at center, rgba(14,14,44,0.8) 0%, rgba(0,0,0,0.95) 100%), url('https://i.imgur.com/zVb6yNj.jpg');
    background-size: cover;
    z-index: -3; /* Ensures it's behind everything */
}

/* Stars Background (consistent with homepage) */
.stars {
    position: fixed;
    z-index: -2; /* Behind main content but above background */
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    overflow: hidden; /* Contain stars within the viewport */
}

.star {
    position: absolute;
    background: white;
    width: 2px;
    height: 2px;
    border-radius: 50%;
    animation: twinkle 3s infinite ease-in-out;
}

@keyframes twinkle {
    0%, 100% { opacity: 0.3; }
    50% { opacity: 1; }
}

/* Navbar (consistent with homepage) */
.navbar {
  width: 100vw;
  background: rgba(0, 0, 0, 0.4);
  color: white;
  padding: 15px 0;
  position: sticky;
  top: 0;
  z-index: 1000;
}

.container1 {
  width: 100%;
  max-width: 1200px;
  margin: auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
  position: relative;
  padding: 0 1.2rem;
}

.brand {
  text-shadow: 0px 0px 3px white ;
  font-size: 2.2rem;
  text-align: left;
  font-weight: bold;
  letter-spacing: 2px;
  font-family:Georgia, 'Times New Roman', Times, serif;
  color: #ffde99;
}

.nav-links {
  list-style: none;
  display: flex;
  gap: 1.5rem;
  align-items: center;
}

.nav-links li a {
  text-decoration: none;
  color: #ddd;
  padding: 0.4rem 0.7rem;
  transition: 0.3s;
}

.nav-links li a.active,
.nav-links li a:hover {
  color: #fff;
  border-bottom: 2px solid #f9c74f;
}

.nav-links li {
  display: flex;
  align-items: center;
}

.menubar {
  font-size: 2rem;
  color: #fff;
  display: none;
  cursor: pointer;
}
/* Dropdown shared */
    .dropdown-menu {
      position: absolute;
      top: 120%;
      right: 0;
      background-color: #222;
      border: 1px solid #444;
      border-radius: 8px;
      display: none;
      flex-direction: column;
      min-width: 180px;
      z-index: 1002;
      cursor: pointer;
    }

    .dropdown-menu.show {
      display: flex;
    }

    .dropdown-menu li {
      padding: 10px 15px;
    }

    .dropdown-menu li a {
      color: white;
      text-decoration: none;
      transition: 0.2s;
    }
    dropdown-menu li a:hover {
      color: white;
    }

    .user-icon {
      font-size: 1.8rem;
      color: #ffde99;
      padding: 5px;
    }


.dark-btn {
  padding: 8px 15px;
  border: 2px solid #ffde99;
  background: transparent;
  border-radius: 5px;
  color: #ffde99;
  cursor: pointer;
  margin-left: 20px;
  transition: 0.3s ease;
}

.dark-btn:hover {
  background: #ffde99;
  color: #000;
}

@media (max-width: 900px) {
  .container1 {
    max-width: 98vw;
    padding: 0 0.5rem;
  }
}

@media (max-width: 768px) {
  .menubar {
    display: block;
  }
  .nav-links {
    display: none;
    flex-direction: column;
    background-color: #222;
    position: absolute;
    top: 60px;
    right: 10px;
    width: 180px;
    border-radius: 8px;
    padding: 10px 0;
    z-index: 1001;
  }
  .nav-links.show {
    display: flex;
  }
  .nav-links li {
    text-align: center;
    padding: 10px 0;
  }
}


.page-header {
    text-align: center;
    margin-bottom: 2.5rem;
    color: #b8e3ff; /* Light blue color */
    text-shadow: 0 0 10px rgba(184, 227, 255, 0.6);
}

.page-header h1 {
    font-size: 3rem;
    margin-bottom: 0.8rem;
}

.page-header p {
    font-size: 1.2rem;
    color: white;
}

/* Form Section for creating topic/cards */
.create-form-section {
    background: rgba(255, 255, 255, 0.08); /* Semi-transparent background */
    border-radius: 15px;
    border: 1px solid rgba(255, 255, 255, 0.15);
    padding: 2rem;
    margin-bottom: 2rem;
    display: flex;
    flex-wrap: wrap;
    gap: 1.5rem;
    justify-content: center;
    align-items: flex-end; /* Align items to the bottom */
    box-shadow: 0 0 20px rgba(255, 222, 153, 0.2);
}

.form-group {
    display: flex;
    flex-direction: column;
    flex: 1; /* Allow groups to grow */
    min-width: 250px; /* Minimum width for form groups */
}

.form-group label {
    margin-bottom: 0.5rem;
    font-size: 1.1rem;
    color: white;
    font-weight: bold;
}

.form-group input[type="text"],
.form-group input[type="number"] {
    padding: 0.8rem 1rem;
    border-radius: 8px;
    border: 2px solid #6c7bff; /* Blue border */
    background-color: rgba(255, 255, 255, 0.1); /* Semi-transparent background */
    color: #e0e0e0;
    font-size: 1rem;
    transition: border-color 0.3s ease, box-shadow 0.3s ease;
}

.form-group input[type="text"]:focus,
.form-group input[type="number"]:focus {
    outline: none;
    border-color: #ffde99; /* Yellow border on focus */
    box-shadow: 0 0 10px rgba(255, 222, 153, 0.6); /* Yellow glow */
}

.form-group input::placeholder {
    color: #bbb;
}

/* Color Picker Specific Styling */
.color-picker-group {
    display: flex;
    flex-direction: column;
    align-items: center; /* Center label and input */
    justify-content: center;
    min-width: 150px; /* Adjust min-width for color pickers */
    flex: none; /* Don't let it grow as much as text inputs */
}

.color-picker-group label {
    text-align: center;
    margin-bottom: 0.5rem;
    font-size: 1rem; /* Slightly smaller font for color labels */
}

.form-group input[type="color"] {
    -webkit-appearance: none; /* Remove default browser styling for color input */
    -moz-appearance: none;
    appearance: none;
    width: 60px; /* Size of the color swatch */
    height: 60px;
    border: 3px solid #6c7bff; /* Blue border */
    border-radius: 50%; /* Make it circular */
    padding: 0;
    cursor: pointer;
    transition: border-color 0.3s ease, transform 0.2s ease;
    background-color: transparent; /* Ensure background is transparent */
    overflow: hidden; /* Hide the default color picker inside the circle */
}

.form-group input[type="color"]::-webkit-color-swatch-wrapper {
    padding: 0;
}

.form-group input[type="color"]::-webkit-color-swatch {
    border: none;
    border-radius: 50%; /* Make the swatch itself circular */
}

.form-group input[type="color"]:hover {
    transform: scale(1.05); /* Slightly enlarge on hover */
    border-color: whitesmoke;
}


/* Action Buttons */
.action-button {
    padding: 0.8rem 1.8rem;
    background: linear-gradient(135deg, #2196f3, #0b7dda); /* Blue gradient */
    color: white;
    border: none;
    border-radius: 30px; /* Pill shape */
    cursor: pointer;
    font-size: 1.1rem;
    font-weight: bold;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    box-shadow: 0 4px 15px rgba(33, 150, 243, 0.4);
    transition: background 0.3s ease, transform 0.2s ease, box-shadow 0.3s ease;
    border: 2px solid #58b0f7; /* Lighter blue border */
    align-self: flex-end; /* Align button to the bottom of the flex container */
}

.action-button:hover {
    background: linear-gradient(135deg, #0b7dda, #2196f3);
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(33, 150, 243, 0.6);
}

.save-button {
    background: linear-gradient(135deg, #4caf50, #2e8b57); /* Green gradient for save */
    border: 2px solid #7edc82; /* Lighter green border */
    box-shadow: 0 4px 15px rgba(76, 175, 80, 0.4);
    margin-top: 2rem; /* Space above save button */
}

.save-button:hover {
    background: linear-gradient(135deg, #2e8b57, #4caf50);
    box-shadow: 0 6px 20px rgba(76, 175, 80, 0.6);
}

/* Flashcard Editor Area */
.flashcard-editor-area {
    display: flex;
    flex-direction: column;
    align-items: center;
    margin-top: 2rem;
}

.flashcard-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); /* Increased min-width for larger cards */
    gap: 1.5rem;
    width: 100%;
    max-width: 1000px; /* Limit grid width */
    margin-bottom: 2rem;
}

/* Individual Editable Flashcard */
.flashcard-editor {
    perspective: 1000px;
    width: 100%;
    height: 350px; /* Increased height for editor cards */
    position: relative;
}

.flashcard-editor-inner {
    width: 100%;
    height: 100%;
    transform-style: preserve-3d;
    transition: transform 0.6s ease-out;
    border-radius: 18px;
    border: 3px solid #6c7bff;
    box-shadow: 0 0 15px rgba(108, 123, 255, 0.5);
    position: relative; /* Needed for positioning flip button */
}

.flashcard-editor-inner.flipped {
    transform: rotateY(180deg);
}

.front-editor, .back-editor {
    position: absolute;
    width: 100%;
    height: 100%;
    backface-visibility: hidden;
    border-radius: 15px;
    padding: 1rem;
    display: flex;
    flex-direction: column;
    justify-content: flex-start; /* Align content to top */
    align-items: center;
    text-align: center;
    box-sizing: border-box;
}

.front-editor {
    background: linear-gradient(135deg, var(--front-card-color, #1f006b), var(--front-card-color-darker, #3b00a0)); /* Use CSS variables */
    color: #b8e3ff;
}

.back-editor {
    background: linear-gradient(135deg, var(--back-card-color, #3b00a0), var(--back-card-color-darker, #1f006b)); /* Use CSS variables */
    color: #ffde99;
    transform: rotateY(180deg);
}

.front-editor label, .back-editor label {
    font-size: 1rem;
    margin-bottom: 0.5rem;
    font-weight: bold;
    color: #f9c74f;
}

.flashcard-editor textarea {
    width: calc(100% - 20px); /* Slightly less than 100% to account for padding */
    height: calc(100% - 60px); /* Adjust height for label and button */
    padding: 0.5rem;
    border-radius: 5px;
    border: 1px solid #58b0f7;
    background-color: rgba(0, 0, 0, 0.4);
    color: #e0e0e0;
    font-size: 0.95rem;
    resize: none; /* Disable manual resize */
    font-family: 'Space Mono', monospace;
    transition: border-color 0.3s ease, background-color 0.3s ease;
    margin-top: 5px; /* Space between label and textarea */
}

.flashcard-editor textarea:focus {
    outline: none;
    border-color: #ffde99;
    background-color: rgba(0, 0, 0, 0.6);
}

/* Flip Button on Card */
.flip-card-button {
    position: absolute;
    bottom: 10px; /* Position at the bottom */
    left: 50%;
    transform: translateX(-50%);
    padding: 0.5rem 1rem;
    background: rgba(255, 255, 255, 0.2); /* Semi-transparent background */
    color: white;
    border: 1px solid rgba(255, 255, 255, 0.4);
    border-radius: 20px;
    cursor: pointer;
    font-size: 0.85rem;
    transition: background 0.3s ease, transform 0.2s ease;
    z-index: 2; /* Ensure it's above the card content */
    backdrop-filter: blur(5px); /* Frosted glass effect */
}

.flip-card-button:hover {
    background: rgba(255, 255, 255, 0.4);
    transform: translateX(-50%) translateY(-2px);
}


/* Message Box for alerts */
.message-box {
    background-color: rgba(76, 175, 80, 0.9); /* Green for success */
    color: white;
    padding: 1rem;
    border-radius: 8px;
    text-align: center;
    margin-top: 1rem;
    font-size: 1.1rem;
    display: none; /* Controlled by JS */
    box-shadow: 0 0 15px rgba(76, 175, 80, 0.6);
}
.message-box.error {
    background-color: rgba(244, 67, 54, 0.9); /* Red for error */
    box-shadow: 0 0 15px rgba(244, 67, 54, 0.6);
}



/* Floating Images (consistent with homepage) */
.rocket,
.astronaut {
    position: fixed;
    width: 240px;
    height: auto;
    z-index: 10;
    pointer-events: none;
}

.rocket {
    top: 40px;
    right: 30px;
    animation: floatRocket 4s infinite ease-in-out;
}

.astronaut {
    bottom: 20px;
    left: 20px;
    animation: float 4s infinite ease-in-out;
}

@keyframes float {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-10px); }
}

@keyframes floatRocket {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-15px); }
}

/* ------------------ Responsive ------------------ */
@media (max-width: 768px) {
    .container1 {
        flex-direction: column;
        align-items: flex-start;
        padding: 0 1rem;
    }

    .brand {
        font-size: 1.8rem;
    }

    .nav-links {
        display: none;
        flex-direction: column;
        position: absolute;
        top: 60px;
        right: 15px;
        background: #222;
        padding: 1rem;
        border-radius: 8px;
        z-index: 999;
        width: calc(100% - 30px);
        max-width: 200px;
        box-shadow: 0 5px 15px rgba(0,0,0,0.5);
    }

    .nav-links.show {
        display: flex;
    }

    .nav-links li {
        margin: 0.5rem 0;
        width: 100%;
        text-align: left; /* Align text left in mobile dropdown */
    }

    .nav-links li a {
        display: block;
        padding: 0.5rem 0; /* Adjust padding for main nav items in mobile */
    }

    /* Mobile specific dropdown styles */
    .dropdown-menu {
        position: static; /* Remove absolute positioning */
        border: none;
        background: none;
        box-shadow: none;
        min-width: unset;
        width: 100%; /* Take full width of parent li */
        padding: 0; /* Remove extra padding */
        opacity: 1; /* Always visible if parent is visible */
        transform: translateY(0);
        pointer-events: auto;
    }
    .dropdown-menu li a {
        padding-left: 20px; /* Indent dropdown items for mobile */
        font-size: 0.9rem; /* Slightly smaller font */
    }

    .menubar {
        display: block;
    }

    .page-header h1 {
        font-size: 2.2rem;
    }

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

    .create-form-section {
        flex-direction: column;
        align-items: stretch;
        padding: 1.5rem;
    }

    .form-group {
        min-width: unset; /* Remove min-width on small screens */
        width: 100%;
    }

    .action-button {
        width: 100%;
        align-self: center; /* Center button when column layout */
    }

    .flashcard-grid {
        grid-template-columns: 1fr; /* Single column on small screens */
    }

    .rocket,
    .astronaut {
        display: none; /* Hide floating images on small screens */
    }

    .flashcard-editor {
        height: 220px; /* Adjust height for smaller screens */
    }

    .flashcard-editor textarea {
        height: calc(100% - 55px); /* Adjust textarea height */
    }
}

@media (max-width: 480px) {
    .main-content {
        padding: 1rem;
    }

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

    .page-header p {
        font-size: 0.9rem;
    }

    .form-group label {
        font-size: 1rem;
    }

    .form-group input {
        font-size: 0.9rem;
        padding: 0.6rem 0.8rem;
    }

    .action-button {
        font-size: 1rem;
        padding: 0.7rem 1.4rem;
    }

    .flashcard-editor {
        height: 180px; /* Slightly smaller cards */
    }

    .flashcard-editor textarea {
        font-size: 0.85rem;
        height: calc(100% - 50px);
    }
}