:root {
  --bs-primary: #343a40;
  --bs-secondary: #f8c471;
}

body {
  background-color: #f5f5f5;
  margin: 0;
  padding: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

/* ===== CARDS Y HOVER EFFECTS ===== */
.card-book {
  transition: transform 0.2s ease-in-out;
}

.card-book:hover {
  transform: scale(1.03);
}

.col-sm-6.col-md-4.col-lg-3:hover {
  transform: scale(1.03);
}

/* ===== BOOKS CONTAINER - RESPONSIVE ===== */
#books-container {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  width: 100%;
  margin: 0;
  padding: 0;
}

/* Bootstrap columns dentro del contenedor de libros */
#books-container .col-sm-6,
#books-container .col-md-4, 
#books-container .col-lg-3 {
  flex: 0 0 auto;
  transition: transform 0.2s ease-in-out;
}

/* Cards de libros */
#books-container .card {
  width: 100%;
  height: 100%;
  transition: transform 0.2s ease-in-out;
  box-shadow: 0 2px 4px rgba(0,0,0,0.1);
  border: 1px solid #dee2e6;
}

#books-container .card:hover {
  transform: scale(1.03);
  box-shadow: 0 4px 8px rgba(0,0,0,0.15);
}

#books-container .card-img-top {
  height: 200px;
  object-fit: cover;
  border-radius: 0.375rem 0.375rem 0 0;
}

#books-container .card-body {
  padding: 0.75rem;
}

#books-container .card-title {
  font-size: 0.9rem;
  font-weight: 600;
  margin-bottom: 0.5rem;
  line-height: 1.3;
}

#books-container .card-text {
  font-size: 0.8rem;
}

#books-container .badge {
  font-size: 0.7rem;
}

#books-container .btn-sm {
  padding: 0.4rem 0.8rem;
  font-size: 0.8rem;
}

/* ===== CHAT BOX - RESPONSIVE ===== */
#chat-box {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  height: clamp(300px, 50vh, 500px);
  overflow-y: auto;
  padding: clamp(0.5rem, 2vw, 1rem);
  background: #e5ddd5;
  border-radius: 8px;
  margin: 0;
  width: 100%;
  box-sizing: border-box;
}

.message {
  display: flex;
  width: 100%;
}

.message.user {
  justify-content: flex-end;
}

.message.bot {
  justify-content: flex-start;
}

.message-content {
  max-width: min(70%, 400px);
  padding: clamp(6px, 1.5vw, 12px) clamp(8px, 2vw, 16px);
  border-radius: 18px;
  line-height: 1.4;
  word-wrap: break-word;
  font-size: clamp(0.8rem, 2.5vw, 1rem);
}

.message.user .message-content {
  background: #dcf8c6;
}

.message.bot .message-content {
  background: #fff;
}

/* ===== NOTES CONTAINER - RESPONSIVE ===== */
#notes-container {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 1rem;
  padding: 1rem;
  width: 100%;
}

.note-card {
  position: relative;
  width: 100%;
  min-height: 150px;
  padding: 1rem;
  border-radius: 8px;
  box-shadow: 0 2px 5px rgba(0,0,0,0.2);
  box-sizing: border-box;
}

.note-actions {
  position: absolute;
  top: 4px;
  right: 4px;
  display: flex;
  gap: 0.25rem;
}

/* ===== DASHBOARD LAYOUT - RESPONSIVE ===== */
.dashboard-container {
  min-height: 100vh;
  display: flex;
  width: 100%;
}

/* ===== SIDEBAR - RESPONSIVE ===== */
.sidebar {
  width: 220px;
  background: #f8f9fa;
  padding: 1rem;
  border-right: 1px solid #ddd;
  position: fixed;
  top: 0;
  left: 0;
  height: 100vh;
  z-index: 1000;
  overflow-y: auto;
  transition: transform 0.3s ease-in-out;
  box-sizing: border-box;
}

/* Content area adjustment for sidebar */
.content-area {
  margin-left: 220px;
  width: calc(100% - 220px);
  padding: 1rem;
  box-sizing: border-box;
  transition: all 0.3s ease-in-out;
}

/* ===== NAVIGATION LINKS ===== */
.sidebar .nav-link {
  color: #6c757d;
  padding: 0.75rem 1rem;
  margin-bottom: 0.25rem;
  border-radius: 0.5rem;
  transition: all 0.3s ease;
  text-decoration: none;
  display: flex;
  align-items: center;
  font-size: clamp(0.8rem, 2vw, 1rem);
}

.sidebar .nav-link:hover {
  color: #0d6efd;
  background-color: rgba(13, 110, 253, 0.1);
  transform: translateX(3px);
}

.sidebar .nav-link.active {
  color: #ffffff;
  background-color: #0d6efd;
  font-weight: 500;
  box-shadow: 0 2px 4px rgba(13, 110, 253, 0.3);
}

.sidebar .nav-link.active i {
  color: #ffffff;
}

.sidebar .nav-link i {
  width: 20px;
  text-align: center;
  transition: color 0.3s ease;
  margin-right: 0.5rem;
}

/* ===== ANIMATIONS ===== */
.section-dashboard {
  animation: fadeIn 0.3s ease-in-out;
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ===== MODAL IMPROVEMENTS ===== */
#createPostModal .modal-body textarea {
  min-height: 100px;
  resize: vertical;
  width: 100%;
  box-sizing: border-box;
}

#createPostModal .modal-body input[type="file"] {
  border: 2px dashed #dee2e6;
  padding: clamp(10px, 3vw, 20px);
  border-radius: 0.5rem;
  background-color: #f8f9fa;
  transition: all 0.3s ease;
  width: 100%;
  box-sizing: border-box;
}

#createPostModal .modal-body input[type="file"]:hover {
  border-color: #0d6efd;
  background-color: rgba(13, 110, 253, 0.05);
}

/* ===== POST CARDS ===== */
.post-card {
  border: 1px solid #dee2e6;
  border-radius: 0.75rem;
  transition: all 0.3s ease;
  overflow: hidden;
  width: 100%;
  box-sizing: border-box;
}

.post-card:hover {
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
  transform: translateY(-2px);
}

.post-card img, .post-card video {
  border-radius: 0.5rem;
  max-width: 100%;
  height: auto;
  display: block;
}

.user-email {
  font-size: clamp(0.7rem, 2vw, 0.85rem);
}

/* ===== TOP BAR ===== */
.topbar {
  background: #fff;
  border-bottom: 1px solid #eee;
  padding: 0.5rem 1rem;
  width: 100%;
  box-sizing: border-box;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
}

.user-icon {
  background: #007bff;
  color: #fff;
  border-radius: 50%;
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: bold;
  font-size: 1rem;
  flex-shrink: 0;
}

.config {
  text-align: left;
  font-size: clamp(0.8rem, 2vw, 0.9rem);
}

#post-feed {
  width: 100%;
  max-width: 600px;
  margin: 0 auto;
}

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

/* Large tablets and small desktops */
@media (max-width: 992px) {
  .sidebar {
    width: 200px;
  }
  
  .content-area {
    margin-left: 200px;
    width: calc(100% - 200px);
  }
  
  #books-container {
    gap: 0.75rem;
  }
  
  #books-container .card-img-top {
    height: 180px;
  }
  
  #books-container .card-body {
    padding: 0.5rem;
  }
  
  #books-container .card-title {
    font-size: 0.85rem;
  }
}

/* Tablets */
@media (max-width: 768px) {
  .dashboard-container {
    flex-direction: column;
  }

  .sidebar {
    position: static;
    width: 100%;
    height: auto;
    border-right: none;
    border-bottom: 1px solid #ddd;
    display: flex;
    flex-direction: row;
    justify-content: space-around;
    overflow-x: auto;
    padding: 0.5rem;
  }

  .content-area {
    margin-left: 0;
    width: 100%;
    padding: 0.5rem;
  }

  .sidebar .nav-link {
    white-space: nowrap;
    margin-right: 0.5rem;
    margin-bottom: 0;
    padding: 0.5rem 0.75rem;
    min-width: max-content;
  }

  .topbar {
    flex-direction: column;
    align-items: stretch;
    gap: 0.5rem;
  }

  .topbar input {
    width: 100%;
  }

  .user-icon {
    align-self: center;
  }

  #post-feed {
    width: 100%;
    max-width: none;
  }

  #books-container {
    gap: 0.5rem;
  }
  
  #books-container .card-img-top {
    height: 160px;
  }
  
  #books-container .card-body {
    padding: 0.4rem;
  }
  
  #books-container .card-title {
    font-size: 0.8rem;
  }
  
  #books-container .card-text {
    font-size: 0.7rem;
  }

  #notes-container {
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 0.5rem;
    padding: 0.5rem;
  }

  #chat-box {
    height: clamp(250px, 40vh, 400px);
    padding: 0.5rem;
  }

  .message-content {
    max-width: 85%;
    font-size: 0.9rem;
  }
}

/* Small tablets and large phones */
@media (max-width: 576px) {
  body {
    font-size: 14px;
  }

  .sidebar {
    padding: 0.25rem;
    flex-wrap: nowrap;
    overflow-x: auto;
  }

  .sidebar .nav-link {
    padding: 0.4rem 0.6rem;
    font-size: 0.8rem;
    flex-shrink: 0;
  }

  .sidebar .nav-link i {
    margin-right: 0.25rem;
  }

  .content-area {
    padding: 0.25rem;
  }

  .topbar {
    padding: 0.5rem;
  }

  .table-responsive {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  .table td,
  .table th {
    font-size: 0.75rem;
    padding: 0.3rem;
    white-space: nowrap;
  }

  .btn-sm {
    font-size: 0.7rem;
    padding: 0.25rem 0.4rem;
  }

  #books-container {
    gap: 0.4rem;
  }
  
  #books-container .card-img-top {
    height: 140px;
  }
  
  #books-container .card-body {
    padding: 0.3rem;
  }
  
  #books-container .card-title {
    font-size: 0.75rem;
    margin-bottom: 0.3rem;
  }
  
  #books-container .card-text {
    font-size: 0.65rem;
  }
  
  #books-container .badge {
    font-size: 0.6rem;
  }
  
  #books-container .btn-sm {
    padding: 0.3rem 0.6rem;
    font-size: 0.7rem;
  }

  #notes-container {
    grid-template-columns: 1fr;
    gap: 0.5rem;
    padding: 0.25rem;
  }

  .note-card {
    min-height: 120px;
    padding: 0.75rem;
  }

  #chat-box {
    height: clamp(200px, 35vh, 350px);
    padding: 0.25rem;
  }

  .message-content {
    max-width: 90%;
    padding: 8px 12px;
    font-size: 0.8rem;
  }

  .post-card {
    margin-bottom: 0.5rem;
  }

  .user-icon {
    width: 32px;
    height: 32px;
    font-size: 0.9rem;
  }
}

/* Extra small phones */
@media (max-width: 320px) {
  .sidebar .nav-link {
    padding: 0.3rem 0.4rem;
    font-size: 0.7rem;
  }

  #books-container {
    gap: 0.3rem;
  }
  
  #books-container .card-img-top {
    height: 120px;
  }
  
  #books-container .card-body {
    padding: 0.25rem;
  }
  
  #books-container .card-title {
    font-size: 0.7rem;
    margin-bottom: 0.25rem;
  }

  .message-content {
    font-size: 0.75rem;
    padding: 6px 10px;
  }

  .table td,
  .table th {
    font-size: 0.7rem;
    padding: 0.2rem;
  }
}

/* ===== UTILITY CLASSES FOR RESPONSIVE ===== */
.w-100 {
  width: 100% !important;
}

.h-auto {
  height: auto !important;
}

.d-block {
  display: block !important;
}

.text-center-mobile {
  text-align: center;
}

@media (min-width: 769px) {
  .text-center-mobile {
    text-align: left;
  }
}

/* ===== SCROLL IMPROVEMENTS ===== */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

::-webkit-scrollbar-track {
  background: #f1f1f1;
  border-radius: 3px;
}

::-webkit-scrollbar-thumb {
  background: #c1c1c1;
  border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
  background: #a8a8a8;
}

/* ===== PERFORMANCE OPTIMIZATIONS ===== */
* {
  box-sizing: border-box;
}

img, video {
  max-width: 100%;
  height: auto;
}

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