/* Responsive Styles */

/* File Card Responsive Layouts */
@media (min-width: 768px) {
  .file-card-desktop {
    display: grid !important;
  }

  .file-card-mobile {
    display: none !important;
  }
}

@media (max-width: 767px) {
  .mobile-hidden {
    display: none !important;
  }

  .file-card-desktop {
    display: none !important;
  }

  .file-card-mobile {
    display: block !important;
  }

  /* Message Card Responsive - Mobile */
  .message-card-display {
    border-radius: 16px !important;
  }

  /* Message Card Header - Mobile Grid */
  .message-card-header {
    padding: 20px !important;
    grid-template-columns: 1fr 1fr !important;
    grid-template-areas: 'emblem photo' 'text text' !important;
  }

  .header-text {
    text-align: center !important;
  }

  .header-emblem {
    justify-self: start !important;
  }

  .header-emblem img {
    width: 60px !important;
  }

  .header-photo {
    justify-self: end !important;
  }

  .header-photo img {
    width: 90px !important;
    height: 90px !important;
  }

  /* Message Card Content - Mobile */
  .message-card-display h1 {
    font-size: 1.8rem !important;
    margin-bottom: 20px !important;
  }

  .message-card-display>div:nth-child(2) {
    padding: 24px 20px !important;
  }

  .message-card-display>div:nth-child(2)>div:nth-child(2) {
    font-size: 0.85rem !important;
    /* Message content - smaller on mobile */
    line-height: 1.6 !important;
  }

  .message-card-display>div:nth-child(2)>div:nth-child(2) p {
    font-size: 0.85rem !important;
    /* Paragraph text - smaller on mobile */
    margin-bottom: 12px !important;
  }

  /* Message Card Footer - Mobile */
  .message-card-footer {
    padding: 20px !important;
    flex-direction: row !important;
    align-items: flex-start !important;
    gap: 12px !important;
  }

  /* HTML Content Display - Mobile */
  .html-content-display {
    border-radius: 12px !important;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1) !important;
  }

  .html-content-display>div:first-child {
    padding: 12px 16px !important;
  }

  .html-content-display>div:first-child h3 {
    font-size: 1rem !important;
  }

  .html-content-display>div:first-child p {
    font-size: 0.8rem !important;
  }

  .html-content-display>div:nth-child(2) {
    padding: 0 !important;
  }

  .html-content-display>div:nth-child(2)>div:first-child {
    padding: 4px 8px !important;
    font-size: 0.65rem !important;
  }

  .html-content-display>div:nth-child(2)>div:last-child {
    min-height: 200px !important;
    padding: 12px !important;
  }

  .html-content-display>div:last-child {
    padding: 12px !important;
  }

  .html-content-display>div:last-child button {
    padding: 6px 10px !important;
    font-size: 0.75rem !important;
  }

  .html-content-preview {
    min-height: 200px !important;
    padding: 8px !important;
    font-size: 0.8rem !important;
    line-height: 1.4 !important;
  }

  /* Quote - Smaller fonts on mobile */
  .message-card-footer>div:first-child {
    font-size: 0.85rem !important;
  }

  .message-card-footer>div:first-child>div:first-child {
    font-size: 0.9em !important;
  }

  .message-card-footer>div:first-child>div:last-child {
    font-size: 0.75em !important;
  }

  /* Signature - Smaller fonts on mobile */
  .message-card-footer>div:last-child {
    font-size: 0.85rem !important;
  }

  .message-card-footer>div:last-child>div:first-child {
    font-size: 0.9rem !important;
    /* Signature name */
  }

  .message-card-footer>div:last-child>div:nth-child(2) {
    font-size: 0.75rem !important;
    /* Title */
  }

  .message-card-footer>div:last-child>div:nth-child(3) {
    font-size: 0.65rem !important;
    /* Date */
  }
}

/* Desktop (768px and above) */
@media (min-width: 768px) {
  .sidebar {
    display: flex;
  }

  .mobile-grid {
    display: none;
  }

  .bottom-nav {
    display: none;
  }

  .brand-title-sub {
    display: block;
  }

  /* Message Card Desktop Layout */
  .message-card-header {
    grid-template-columns: 1fr auto 1fr !important;
    grid-template-areas: 'text emblem photo' !important;
  }

  .header-text {
    text-align: left !important;
  }

  .header-emblem {
    justify-self: center !important;
  }

  .header-emblem img {
    width: 85px !important;
  }

  .header-photo img {
    width: 130px !important;
    height: 130px !important;
  }
}

/* Tablet (max 767px) */
@media (max-width: 767px) {
  .top-bar {
    padding: 8px 12px;
  }

  .brand-title-sub {
    display: none;
  }

  .zone-badge {
    display: none;
  }

  /* Hide profile and logout buttons in mobile - use bottom nav instead */
  .btn-profile {
    display: none !important;
  }

  /* Make logout button smaller on mobile */
  .btn-logout {
    padding: 4px 8px;
    font-size: 11px;
  }

  /* Hide user info display on mobile to save space */
  #userInfoDisplay {
    display: none !important;
  }

  /* Notification Bell - Mobile */
  .notification-bell {
    margin-right: 4px !important;
  }

  .notification-bell .btn-notification {
    width: 36px !important;
    height: 36px !important;
  }

  .notification-bell .btn-notification svg {
    width: 18px !important;
    height: 18px !important;
  }

  .notification-badge {
    min-width: 16px !important;
    height: 16px !important;
    font-size: 9px !important;
    top: -3px !important;
    right: -3px !important;
  }

  /* Notification Dropdown - Mobile */
  .notification-dropdown {
    width: calc(100vw - 20px) !important;
    max-width: 380px !important;
    right: 10px !important;
    left: auto !important;
  }

  .main-content {
    padding: 0px;
  }

  .card {
    padding: 12px;
  }

  .page-title {
    font-size: 18px;
  }

  .modal-card {
    padding: 16px;
  }

  .form-grid {
    grid-template-columns: 1fr;
  }

  .search-controls {
    flex-direction: column;
    align-items: stretch;
  }

  .search-input {
    width: 100%;
  }

  .quiz-details-form {
    grid-template-columns: 1fr;
  }

  .dashboard-grid {
    grid-template-columns: 1fr;
  }

  .division-grid {
    grid-template-columns: 1fr;
  }

  /* Folder Cards - Mobile */
  .folder-card-grid {
    grid-template-columns: 1fr !important;
  }

  /* Profile Page Tablet Styles */
  .profile-page-tabs {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 6px;
  }

  .profile-page-tab {
    min-width: auto;
    padding: 12px 8px;
  }
}

/* Mobile (max 480px) */
@media (max-width: 480px) {
  .brand-title-main {
    font-size: 15px;
  }

  .btn-login {
    padding: 6px 8px;
    font-size: 11px;
  }

  .avatar {
    width: 28px;
    height: 28px;
    font-size: 14px;
  }

  .mobile-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
  }

  .tile {
    padding: 8px;
  }

  .bottom-nav {
    width: calc(100% - 8px);
    bottom: 4px;
  }

  .bottom-nav-item {
    font-size: 9px;
  }

  .modal-card {
    width: 100%;
    border-radius: 12px 12px 0 0;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
  }

  /* Profile Page Mobile Styles */
  .profile-page-tabs {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 6px;
    padding: 4px;
  }

  .profile-page-tab {
    min-width: auto;
    padding: 10px 4px;
    margin: 0;
    font-size: 11px;
  }

  .profile-page-tab .tab-icon {
    font-size: 20px;
  }

  .profile-page-tab .tab-label {
    font-size: 9.5px;
    line-height: 1.2;
  }

  .profile-avatar-large {
    font-size: 60px;
  }

  .profile-name {
    font-size: 22px;
  }

  .profile-stats {
    gap: 15px;
    flex-wrap: wrap;
  }

  .stat-value {
    font-size: 16px;
  }

  .profile-grid {
    grid-template-columns: 1fr;
  }

  .profile-card .card-icon {
    font-size: 36px;
  }

  .rating-stars .star {
    font-size: 24px;
  }
}

/* Extra Small Mobile (max 360px) */
@media (max-width: 360px) {
  .profile-page-tabs {
    grid-template-columns: repeat(3, 1fr);
    gap: 3px;
    padding: 3px;
  }

  .profile-page-tab {
    padding: 6px 2px;
  }

  .profile-page-tab .tab-icon {
    font-size: 16px;
  }

  .profile-page-tab .tab-label {
    font-size: 8px;
  }

  .profile-name {
    font-size: 20px;
  }

  .profile-stats {
    gap: 10px;
  }

  /* Extra small adjustments for HTML content */
  .html-content-preview {
    font-size: 0.75rem !important;
    line-height: 1.3 !important;
  }

  .html-content-display>div:last-child button {
    padding: 4px 8px !important;
    font-size: 0.7rem !important;
  }
}

/* Print Styles */
@media print {

  .top-bar,
  .sidebar,
  .bottom-nav,
  .btn-sm,
  .search-controls {
    display: none !important;
  }

  .app-shell {
    box-shadow: none;
  }

  .page {
    display: block !important;
  }

  .card {
    break-inside: avoid;
    page-break-inside: avoid;
  }
}

/* Responsive form grids for movement details form */
@media (max-width: 1024px) {

  .form-grid-2,
  .form-grid-3,
  .form-grid-4 {
    grid-template-columns: 1fr !important;
  }

  .form-grid-2>.form-group,
  .form-grid-3>.form-group,
  .form-grid-4>.form-group {
    margin-bottom: 12px;
  }

  /* Fix for tablet view */
  .logbook-table {
    display: block;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  .logbook-table thead,
  .logbook-table tbody,
  .logbook-table th,
  .logbook-table td,
  .logbook-table tr {
    display: block;
  }

  .logbook-table thead tr {
    position: absolute;
    top: -9999px;
    left: -9999px;
  }

  .logbook-table tr {
    border: 1px solid var(--border-light);
    margin-bottom: 10px;
    padding: 12px;
    border-radius: var(--radius-md);
  }

  .logbook-table td {
    border: none;
    position: relative;
    padding-left: 50% !important;
    text-align: left;
  }

  .logbook-table td:before {
    content: attr(data-label) " ";
    position: absolute;
    left: 12px;
    width: 45%;
    font-weight: 600;
    color: var(--text-soft);
  }

  /* Responsive buttons container */
  .logbook-buttons-container {
    grid-template-columns: 1fr !important;
  }
}

@media (max-width: 767px) {

  .form-grid-2,
  .form-grid-3,
  .form-grid-4 {
    grid-template-columns: 1fr !important;
  }

  .form-grid-2>.form-group,
  .form-grid-3>.form-group,
  .form-grid-4>.form-group {
    margin-bottom: 12px;
  }

  /* Mobile view for table */
  .logbook-table {
    display: block;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  .logbook-table thead,
  .logbook-table tbody,
  .logbook-table th,
  .logbook-table td,
  .logbook-table tr {
    display: block;
  }

  .logbook-table thead tr {
    position: absolute;
    top: -9999px;
    left: -9999px;
  }

  .logbook-table tr {
    border: 1px solid var(--border-light);
    margin-bottom: 10px;
    padding: 12px;
    border-radius: var(--radius-md);
  }

  .logbook-table td {
    border: none;
    position: relative;
    padding-left: 50% !important;
    text-align: left;
  }

  .logbook-table td:before {
    content: attr(data-label) " ";
    position: absolute;
    left: 12px;
    width: 45%;
    font-weight: 600;
    color: var(--text-soft);
  }

  /* Responsive buttons container */
  .logbook-buttons-container {
    grid-template-columns: 1fr !important;
  }

  /* Admin Hero Responsive */
  .admin-hero-content {
    flex-direction: column !important;
    text-align: center !important;
  }

  .admin-hero-content .hero-logo {
    margin: 0 auto 15px !important;
  }

  .admin-hero-content .hero-title-group {
    margin-left: 0 !important;
  }

  .admin-tabs-grid,
  .admin-stats-grid {
    grid-template-columns: repeat(2, 1fr) !important;
  }

  .logbook-info-grid,
  .logbook-filter-grid {
    grid-template-columns: 1fr !important;
  }
}

@media (min-width: 768px) and (max-width: 1024px) {

  .form-grid-3,
  .form-grid-4 {
    grid-template-columns: 1fr 1fr !important;
  }
}

@media (min-width: 1025px) {
  .admin-tabs-grid {
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)) !important;
  }
}