@import url('https://fonts.googleapis.com/css2?family=Libertinus+Math&display=swap');

/* frontend/css/main.css */
/* Global Reset & Base */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  font-family: "Libertinus Math", sans-serif;
}

/* Ensure proper viewport scaling on mobile devices */
body {
  background-color: var(--primary-bg);
  color: var(--text-dark);
  /* Prevent horizontal scrolling */
  overflow-x: hidden;
}

/* Better selection colors for mobile */
::selection {
  background-color: var(--primary-color);
  color: var(--text-light);
}

:root {
  --primary-bg: #fee3c3;
  --primary-color: #c1946e;
  --primary-light: #d4a982;
  --primary-dark: #a67c52;
  --text-dark: #333;
  --text-light: #fff;
  --border-color: #ddd;
  --shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
  --radius: 8px;
  --transition: all 0.3s ease;
  /* Mobile-friendly sizes */
  --mobile-padding: 15px;
  --mobile-gap: 15px;
}

.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 20px;
}

/* ==========================================
   SHARED COMPONENT STYLES (Used on all pages)
   ========================================== */

/* Sidebar Container */
.sidebar {
  width: 250px;
  background-color: var(--primary-color);
  color: var(--text-light);
  position: fixed;
  top: 0;
  bottom: 0;
  left: 0;
  padding: 20px;
  overflow-y: auto;
  z-index: 1000;
  transition: transform 0.3s ease, width 0.3s ease;
  box-shadow: 2px 0 10px rgba(0, 0, 0, 0.1);
}

/* Sidebar Header with Menu Label */
.sidebar-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding-bottom: 20px;
  border-bottom: 1px solid #a67c52;
  margin-bottom: 20px;
}

.sidebar-header h3 {
  margin: 0;
  color: white;
  font-size: 1.2rem;
}

.sidebar-profile {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-left: auto;
  color: white;
  font-size: 1.8rem;
  cursor: pointer;
  transition: var(--transition);
  text-decoration: none;
  padding: 5px;
  border-radius: 8px;
}

.sidebar-profile:hover {
  background-color: rgba(255, 255, 255, 0.1);
  transform: scale(1.1);
}

.sidebar-profile i {
  color: var(--primary-bg);
  transition: var(--transition);
}

.sidebar-profile:hover i {
  color: white;
}

/* New Folder Button */
.new-folder-btn {
  width: 100%;
  background-color: var(--primary-bg);
  color: var(--text-dark);
  border: none;
  padding: 12px;
  border-radius: var(--radius);
  font-size: 1rem;
  font-weight: 500;
  cursor: pointer;
  margin-bottom: 20px;
  transition: var(--transition);
}

/* Navigation Menu */
.nav-menu ul {
  list-style: none;
  padding: 0;
}

.nav-menu li {
  margin-bottom: 8px;
}

/* Navigation Links */
.nav-link {
  display: flex;
  align-items: center;
  color: var(--text-light);
  text-decoration: none;
  padding: 12px 15px;
  border-radius: var(--radius);
  transition: var(--transition);
  font-weight: 500;
  gap: 12px;
}

.nav-link i {
  width: 20px;
  text-align: center;
  font-size: 1.1rem;
}

.nav-link span {
  font-size: 0.95rem;
}

.nav-link.active,
.nav-link:hover {
  background-color: var(--primary-bg);
  color: var(--text-light);
}

/* Dropdown Styles */
.nav-item-dropdown {
  position: relative;
}

.dropdown-toggle {
  cursor: pointer;
  justify-content: space-between;
}

.dropdown-icon {
  font-size: 0.8rem;
  transition: transform 0.3s ease;
}

.nav-item-dropdown.active .dropdown-icon {
  transform: rotate(180deg);
}

.sub-menu {
  list-style: none;
  padding-left: 20px;
  display: none;
  background-color: rgba(0, 0, 0, 0.1);
  border-radius: var(--radius);
  margin-top: 5px;
}

.nav-item-dropdown.active .sub-menu {
  display: block;
}

.sub-menu li {
  margin-bottom: 5px;
}

.sub-menu .nav-link {
  padding: 8px 12px;
  font-size: 0.9rem;
}

/* Collapsed Sidebar (Desktop) */
.sidebar.collapsed {
  transform: translateX(-210px); /* Show only toggle bar */
  width: 40px;
}

.sidebar.collapsed .sidebar-header h3,
.sidebar.collapsed .sidebar-profile,
.sidebar.collapsed .nav-menu li a span,
.sidebar.collapsed .new-folder-btn,
.sidebar.collapsed .dropdown-icon,
.sidebar.collapsed .sub-menu {
  display: none;
}

.sidebar.collapsed .menu-toggle i {
  margin-right: 0;
}

.sidebar.collapsed ~ .main-content {
  margin-left: 40px;
}

/* Mobile: Sidebar Slide In/Out */
@media (max-width: 768px) {
  .sidebar {
    transform: translateX(-100%);
    width: 250px;
  }

  .sidebar.active {
    transform: translateX(0);
  }

  .main-content {
    margin-left: 0;
  }
}

/* Mobile-friendly base styles */
button, input, select, textarea {
  font-size: 16px; /* Prevents zoom on mobile devices when form elements are focused */
}

/* Responsive Base */
@media (max-width: 1024px) {
  .container {
    padding: 15px;
  }
  
  /* Adjust sidebar width on medium screens */
  .sidebar {
    width: 200px;
  }
  
  .sidebar.collapsed {
    transform: translateX(-160px);
    width: 40px;
  }
  
  .sidebar.collapsed ~ .main-content {
    margin-left: 40px;
  }
}

@media (max-width: 768px) {
  .container {
    padding: 15px;
  }

  /* Mobile menu styles */
  .sidebar {
    transform: translateX(-100%);
    width: 250px;
    transition: transform 0.3s ease;
  }

  .sidebar.active {
    transform: translateX(0);
  }
  
  .sidebar.inactive {
    transform: translateX(-100%);
  }

  .main-content {
    margin-left: 0;
    padding: 15px;
  }
  
  /* Mobile menu toggle button */
  .menu-toggle {
    display: block;
    z-index: 1001;
  }
  
  /* Ensure content doesn't overlap with fixed sidebar */
  body.sidebar-active {
    overflow: hidden;
  }
}

/* Small mobile devices */
@media (max-width: 480px) {
  .container {
    padding: 10px;
  }
  
  .main-content {
    padding: 10px;
  }
  
  /* Adjust text sizes for small screens */
  h1 { font-size: 1.8rem; }
  h2 { font-size: 1.6rem; }
    h3 { font-size: 1.4rem; }
    h4 { font-size: 1.2rem; }
  }

/* ==========================================
   SHARED BUTTON STYLES (For all pages)
   ========================================== */

/* Menu Toggle Button */
.menu-toggle {
  background: none;
  border: none;
  font-size: 1.5rem;
  color: var(--primary-color);
  cursor: pointer;
  padding: 5px;
  transition: var(--transition);
}

.menu-toggle:hover {
  color: var(--primary-dark);
}

/* Logout Button */
.logout-btn {
  color: var(--primary-color);
  text-decoration: none;
  font-weight: 500;
  padding: 8px 16px;
  border-radius: var(--radius);
  background-color: white;
  transition: var(--transition);
}

.logout-btn:hover {
  background-color: var(--primary-dark);
  color: white;
}
  
  /* ==========================================
     MODAL STYLES
     ========================================== */
  .modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5); /* Semi-transparent background */
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 2000; /* Ensure it's above everything */
    opacity: 0;
    animation: fadeIn 0.3s forwards;
  }
  
  @keyframes fadeIn {
    to { opacity: 1; }
  }
  
  .modal-content {
    background-color: white;
    padding: 30px;
    border-radius: 12px;
    box-shadow: 0 5px 20px rgba(0, 0, 0, 0.2);
    width: 90%;
    max-width: 500px;
    position: relative;
    transform: translateY(-20px);
    animation: slideIn 0.3s forwards;
  }
  
  @keyframes slideIn {
    to { transform: translateY(0); }
  }
  
  .close-modal {
    position: absolute;
    top: 15px;
    right: 20px;
    font-size: 1.5rem;
    color: #aaa;
    cursor: pointer;
    transition: color 0.2s;
  }
  
  .close-modal:hover {
    color: var(--text-dark);
  }
  
  .modal h3 {
    margin-bottom: 20px;
    color: var(--primary-color);
    font-size: 1.5rem;
  }
  
  .modal .form-group {
    margin-bottom: 15px;
  }
  
  .modal label {
    display: block;
    margin-bottom: 5px;
    font-weight: 500;
    color: var(--text-dark);
  }
  
  .modal input,
  .modal textarea {
    width: 100%;
    padding: 10px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    font-size: 1rem;
  }
  
  .modal textarea {
    min-height: 100px;
    resize: vertical;
  }
  
  .modal .btn-primary {
    width: 100%;
    padding: 12px;
    background-color: var(--primary-color);
    color: white;
    border: none;
    border-radius: var(--radius);
    font-size: 1rem;
    cursor: pointer;
    transition: background-color 0.2s;
  }
  
  .modal .btn-primary:hover {
    background-color: var(--primary-bg);
  }
  
/* ==========================================
   LOADING STYLES
   ========================================== */
.loading-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 40px;
  text-align: center;
  color: var(--text-dark);
  background-color: rgba(255, 255, 255, 0.8);
  border-radius: var(--radius);
  /* Removed margin to allow it to take full parent space */
  /* If placed directly inside a flex item, this helps it expand */
  flex-grow: 1; 
  min-height: 100%; /* Ensure it has height even if content is sparse */
  box-sizing: border-box; /* Include padding in height calculation */
}

.loading-container i {
  font-size: 3rem;
  color: var(--primary-color);
  margin-bottom: 15px;
  /* Ensure the spinner is perfectly round */
  display: inline-block;
  vertical-align: middle;
  width: 1em;
  height: 1em;
  line-height: 1;
  text-align: center;
  transform-origin: center;
}
  
  .loading-container span {
    font-size: 1.2rem;
    font-weight: 500;
  }
  
  .loading-container .processing-info {
    margin-top: 10px;
    color: #666;
    font-size: 0.9rem;
  }
  
  .error-container {
    padding: 20px;
    background-color: #ffe6e6;
    border: 1px solid #ffcccc;
    border-radius: var(--radius);
    color: #cc0000;
    text-align: center;
  }
  
  .error-container i {
    font-size: 2rem;
    margin-bottom: 10px;
  }
  