/* ═══════════════════════════════════════════════════════════════
   RESPONSIVE CSS - radio.kbrbaik.live
   Mobile-first responsive design with breakpoints
   ═══════════════════════════════════════════════════════════════ */

/* ── HAMBURGER MENU BUTTON ── */
.hamburger {
  display: none;
  width: 40px;
  height: 40px;
  border: none;
  background: rgba(255,255,255,0.1);
  border-radius: 6px;
  cursor: pointer;
  flex-shrink: 0;
  position: relative;
  z-index: 1001;
}

.hamburger span {
  display: block;
  width: 20px;
  height: 2px;
  background: #fff;
  margin: 4px auto;
  transition: all 0.3s ease;
  border-radius: 2px;
}

.hamburger.active span:nth-child(1) {
  transform: rotate(45deg) translate(5px, 5px);
}

.hamburger.active span:nth-child(2) {
  opacity: 0;
}

.hamburger.active span:nth-child(3) {
  transform: rotate(-45deg) translate(5px, -5px);
}

/* ── SIDEBAR OVERLAY (Mobile) ── */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 999;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.sidebar-overlay.active {
  display: block;
  opacity: 1;
}

/* ═══════════════════════════════════════════════════════════════
   BREAKPOINT: Tablet (max-width: 1024px)
   ═══════════════════════════════════════════════════════════════ */
@media (max-width: 1024px) {
  /* Header adjustments */
  #header {
    padding: 8px 16px;
    gap: 12px;
  }

  .h-left {
    min-width: auto;
  }

  .h-sub {
    display: none;
  }

  .h-center {
    padding: 0 8px;
  }

  .h-nowtitle {
    max-width: 200px;
  }

  .h-right {
    min-width: auto;
    gap: 12px;
  }

  #clock {
    font-size: 22px;
  }

  /* Sidebar - still visible but narrower */
  #sidebar {
    width: 180px;
    min-width: 180px;
  }

  /* Calendar grid - fewer columns visible */
  .cal-grid {
    grid-template-columns: repeat(7, 1fr);
    font-size: 12px;
  }

  .cal-day .day-num {
    font-size: 13px;
    padding: 2px 4px;
  }

  .cal-ev {
    font-size: 12px;
    padding: 1px 3px;
  }

  /* Weekly schedule */
  .ws-day-label {
    font-size: 11px;
    padding: 3px 0;
  }

  .ws-ev {
    font-size: 11px;
    padding: 3px 6px;
  }

  .ws-ev-name {
    font-size: 11px;
  }

  /* Stream settings grid */
  .ss-grid {
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  }
}

/* ═══════════════════════════════════════════════════════════════
   BREAKPOINT: Mobile Landscape (max-width: 768px)
   ═══════════════════════════════════════════════════════════════ */
@media (max-width: 768px) {
  /* Show hamburger menu */
  .hamburger {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
  }

  /* Header - compact */
  #header {
    padding: 8px 12px;
    height: 60px;
    gap: 8px;
  }

  .h-logo {
    font-size: 22px;
  }

  .h-title {
    font-size: 15px;
  }

  .h-center {
    display: none;
  }

  .h-right {
    gap: 8px;
  }

  #clock {
    font-size: 18px;
    letter-spacing: 0;
  }

  .h-user {
    padding: 4px 8px;
    font-size: 12px;
  }

  .h-avatar {
    display: none;
  }

  /* Sidebar - off-canvas on mobile */
  #sidebar {
    position: fixed;
    left: -220px;
    top: 60px;
    width: 220px;
    height: calc(100vh - 60px);
    z-index: 1000;
    transition: left 0.3s ease;
    border-right: none;
    box-shadow: 2px 0 20px rgba(0,0,0,0.3);
  }

  #sidebar.open {
    left: 0;
  }

  /* Body layout */
  #body {
    flex-direction: column;
  }

  /* Main content - full width */
  #main {
    width: 100%;
    overflow-y: auto;
  }

  /* Dashboard panels - stack vertically */
  .main-body {
    flex-direction: column;
    overflow: visible;
  }

  .left-panel {
    border-right: none;
    border-bottom: 1px solid #bae6fd;
    min-height: 300px;
    max-height: 50vh;
  }

  .right-panel {
    min-height: 300px;
  }

  /* Now Playing Card */
  #nowCard {
    padding: 8px 12px;
    gap: 8px;
  }

  #nowCard .nc-cover {
    width: 36px;
    height: 36px;
    font-size: 14px;
  }

  #nowCard .nc-title {
    font-size: 12px;
  }

  #nowCard .nc-artist {
    font-size: 11px;
  }

  #nowCard .nc-label {
    font-size: 10px;
  }

  #nowCard .nc-time {
    font-size: 10px;
  }

  /* Footer - compact player */
  #footer {
    padding: 0 12px;
    height: 56px;
    flex-wrap: wrap;
    gap: 4px;
  }

  #footer .f-logo {
    display: none;
  }

  #footer .f-stations {
    padding: 0 6px;
  }

  #footer .f-stations select {
    font-size: 13px;
    min-width: 70px;
    padding: 3px 20px 3px 6px;
  }

  #footer .f-play {
    width: 32px;
    height: 32px;
    font-size: 14px;
    margin-right: 6px;
  }

  #footer .f-info .status {
    font-size: 11px;
    padding: 2px 6px;
  }

  #footer .f-info .now {
    font-size: 12px;
  }

  /* Tracks table - hide some columns */
  .tr-row .tr-creator,
  .tr-row .tr-genre,
  .tr-row .tr-uploaded {
    display: none;
  }

  .tr-row .tr-title {
    min-width: 80px;
  }

  .tr-row .tr-art {
    width: 24px;
    height: 24px;
  }

  /* Schedule groups */
  .sg-track .tartist {
    display: none;
  }

  .sg-add {
    flex-direction: column;
  }

  .sg-add-select {
    width: 100%;
  }

  /* Calendar */
  .cal-tabs {
    flex-wrap: wrap;
  }

  .cal-tab {
    padding: 4px 10px;
    font-size: 13px;
  }

  .cal-header {
    flex-wrap: wrap;
    gap: 8px;
  }

  /* Weekly schedule */
  .ws-body {
    flex-direction: column;
  }

  .ws-days {
    grid-template-columns: repeat(3, 1fr);
  }

  .ws-day-label {
    font-size: 10px;
    padding: 2px 0;
  }

  .ws-ev {
    font-size: 10px;
    padding: 2px 4px;
  }

  .ws-ev-name {
    font-size: 10px;
  }

  .ws-ev-time {
    font-size: 9px;
  }

  /* Stream settings */
  .ss-grid {
    grid-template-columns: 1fr;
  }

  .ss-card .ss-row {
    flex-direction: column;
    gap: 2px;
  }

  .ss-card .ss-label {
    width: auto;
    font-weight: 600;
  }

  /* Login box */
  #loginBox {
    width: calc(100% - 32px);
    max-width: 340px;
    padding: 24px 20px;
  }

  /* Toast */
  #toast {
    bottom: 64px;
    right: 12px;
    left: 12px;
    text-align: center;
  }

  /* Playlist items */
  .pl-track .plt-artist {
    display: none;
  }

  /* Library table - scroll horizontally */
  .tr-lib-list {
    overflow-x: auto;
  }

  .tr-lib-list table {
    min-width: 500px;
  }

  /* Show builder */
  .sb-toolbar {
    flex-wrap: wrap;
    gap: 4px;
  }

  .sb-toolbar select,
  .sb-toolbar input {
    font-size: 13px;
  }

  /* LibreTime tabs */
  .lt-tab {
    width: 80px;
    height: 36px;
  }

  .lt-tab .lt-day {
    font-size: 12px;
  }

  .lt-row {
    padding: 10px 12px;
  }

  .lt-row .lt-time,
  .lt-row .lt-name {
    font-size: 13px;
  }

  /* Schedule tracks overlay */
  .st-overlay-body {
    flex-direction: column;
  }

  .st-lib {
    flex: 0 0 auto;
    max-height: 50vh;
    border-right: none;
    border-bottom: 2px solid #e0f2fe;
  }

  .st-lib-tabs {
    overflow-x: auto;
    flex-wrap: nowrap;
  }

  .st-lib-tab {
    padding: 6px 12px;
    font-size: 12px;
    white-space: nowrap;
  }

  .st-lib-table th,
  .st-lib-table td {
    padding: 4px 6px;
    font-size: 12px;
  }

  /* Context menu */
  .cal-ctx {
    min-width: 160px;
  }

  .cal-ctx-item {
    padding: 6px 12px;
    font-size: 13px;
  }

  /* Modal */
  #plAddModal .modal {
    width: calc(100% - 32px);
    max-width: 500px;
    max-height: 90vh;
  }
}

/* ═══════════════════════════════════════════════════════════════
   BREAKPOINT: Mobile Portrait (max-width: 480px)
   ═══════════════════════════════════════════════════════════════ */
@media (max-width: 480px) {
  /* Header - minimal */
  #header {
    padding: 6px 10px;
    height: 52px;
    gap: 6px;
  }

  .h-logo {
    font-size: 18px;
  }

  .h-title {
    font-size: 13px;
    max-width: 100px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .h-right {
    gap: 6px;
  }

  #clock {
    font-size: 16px;
  }

  .h-user {
    padding: 4px 6px;
    font-size: 11px;
    gap: 4px;
  }

  /* Sidebar - full width on very small screens */
  #sidebar {
    width: 100%;
    left: -100%;
  }

  #sidebar.open {
    left: 0;
  }

  /* Footer - stacked layout */
  #footer {
    height: auto;
    padding: 8px;
    flex-direction: column;
    gap: 6px;
  }

  #footer .f-stations {
    width: 100%;
    padding: 0;
  }

  #footer .f-stations select {
    width: 100%;
  }

  #footer .f-play {
    margin-right: 0;
  }

  #footer .f-info {
    width: 100%;
    justify-content: center;
  }

  /* Now Playing Card - stacked */
  #nowCard {
    flex-direction: column;
    align-items: flex-start;
    gap: 6px;
    padding: 8px;
  }

  #nowCard .nc-meta {
    flex-wrap: wrap;
    gap: 4px;
  }

  #nowCard .nc-bar {
    width: 100%;
  }

  /* Dashboard panels */
  .left-panel,
  .right-panel {
    min-height: 250px;
  }

  /* Tracks - even more compact */
  .tr-row {
    padding: 5px 8px;
    font-size: 12px;
    gap: 6px;
  }

  .tr-row .tr-type {
    display: none;
  }

  .tr-row .tr-actions {
    width: 40px;
  }

  .tr-row .tr-act-btn {
    width: 20px;
    height: 20px;
    font-size: 12px;
  }

  /* Schedule */
  .sgroup-head {
    padding: 5px 8px;
    font-size: 13px;
  }

  .sg-time {
    width: 40px;
    font-size: 13px;
  }

  .sg-track {
    padding: 3px 8px;
    font-size: 13px;
  }

  .sg-track .ttime {
    width: 30px;
    font-size: 12px;
  }

  /* Calendar - single column view on very small */
  .cal-grid {
    grid-template-columns: 1fr;
    grid-template-rows: auto;
  }

  .cal-dow {
    display: none;
  }

  .cal-day {
    min-height: 60px;
  }

  .cal-day .day-num {
    font-size: 14px;
  }

  /* Weekly schedule - single day view */
  .ws-days {
    grid-template-columns: 1fr;
  }

  .ws-day-label {
    font-size: 12px;
    padding: 6px 0;
  }

  .ws-ev {
    font-size: 11px;
    padding: 4px 6px;
  }

  /* Stream settings */
  .ss-card {
    padding: 8px 10px;
  }

  .ss-card h4 {
    font-size: 14px;
  }

  /* Buttons - larger touch targets */
  .build-btn,
  .lp-btn,
  .sg-add-btn {
    padding: 8px 12px;
    font-size: 14px;
    min-height: 36px;
  }

  /* Search inputs */
  .lp-search input,
  .st-lib-search input {
    padding: 8px 10px;
    font-size: 16px; /* Prevents zoom on iOS */
  }

  /* Login */
  #loginBox h2 {
    font-size: 16px;
  }

  #loginBox input {
    padding: 10px 12px;
    font-size: 16px;
  }

  #loginBox button {
    padding: 12px;
    font-size: 16px;
  }

  /* Modal adjustments */
  .cal-edit-panel.open {
    width: 100%;
    position: fixed;
    inset: 0;
    z-index: 500;
  }

  /* Overlay */
  .st-overlay-header {
    padding: 8px 12px;
    min-height: 48px;
  }

  .st-overlay-header h2 {
    font-size: 16px;
  }

  .st-close {
    font-size: 24px;
    padding: 0 4px;
  }

  /* Touch-friendly adjustments */
  .sect,
  .cal-ctx-item,
  .ws-item,
  .pod-item {
    padding: 12px 16px;
    min-height: 44px;
  }

  /* Scrollbar - thinner on mobile */
  ::-webkit-scrollbar {
    width: 4px;
    height: 4px;
  }

  /* Table horizontal scroll indicator */
  .tr-lib-list::after {
    content: '';
    position: sticky;
    right: 0;
    top: 0;
    bottom: 0;
    width: 20px;
    background: linear-gradient(90deg, transparent, rgba(0,0,0,0.1));
    pointer-events: none;
  }
}

/* ═══════════════════════════════════════════════════════════════
   BREAKPOINT: Very Small Screens (max-width: 360px)
   ═══════════════════════════════════════════════════════════════ */
@media (max-width: 360px) {
  #header {
    padding: 4px 8px;
    height: 48px;
  }

  .h-title {
    font-size: 12px;
    max-width: 80px;
  }

  #clock {
    font-size: 14px;
  }

  .h-user span:not(.h-avatar) {
    display: none;
  }

  #footer {
    padding: 6px;
  }

  #footer .f-info .now {
    font-size: 11px;
  }

  .tr-row .tr-length {
    display: none;
  }
}

/* ═══════════════════════════════════════════════════════════════
   TOUCH DEVICE OPTIMIZATIONS
   ═══════════════════════════════════════════════════════════════ */
@media (hover: none) and (pointer: coarse) {
  /* Larger touch targets */
  .tr-row .tr-act-btn,
  .sg-act button,
  .plt-act button {
    width: 32px;
    height: 32px;
    min-width: 32px;
    min-height: 32px;
  }

  /* Remove hover effects that don't work on touch */
  .tr-row:hover,
  .sg-track:hover,
  .pl-item:hover,
  .ws-item:hover {
    background: transparent;
  }

  /* Active states instead */
  .tr-row:active,
  .sg-track:active,
  .pl-item:active,
  .ws-item:active {
    background: #e0f2fe;
  }

  /* Scrollbar - hidden on touch */
  ::-webkit-scrollbar {
    display: none;
  }

  * {
    scrollbar-width: none;
  }
}

/* ═══════════════════════════════════════════════════════════════
   LANDSCAPE PHONE OPTIMIZATION
   ═══════════════════════════════════════════════════════════════ */
@media (max-height: 500px) and (orientation: landscape) {
  #header {
    height: 44px;
    padding: 4px 12px;
  }

  .h-logo {
    font-size: 16px;
  }

  .h-title {
    font-size: 12px;
  }

  #clock {
    font-size: 14px;
  }

  #footer {
    height: 44px;
  }

  #sidebar {
    top: 44px;
    height: calc(100vh - 44px - 44px);
  }

  .main-body {
    flex-direction: row;
  }

  .left-panel,
  .right-panel {
    min-height: auto;
    max-height: none;
  }
}

/* ═══════════════════════════════════════════════════════════════
   ACCESSIBILITY - Reduced Motion
   ═══════════════════════════════════════════════════════════════ */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }

  .hamburger span {
    transition: none;
  }

  #sidebar {
    transition: none;
  }
}

/* ═══════════════════════════════════════════════════════════════
   DARK MODE SUPPORT (optional)
   ═══════════════════════════════════════════════════════════════ */
@media (prefers-color-scheme: dark) {
  /* Uncomment to enable dark mode
  body {
    background: #0f172a;
    color: #e2e8f0;
  }

  #header {
    background: linear-gradient(180deg, #1e293b, #0f172a);
  }

  #sidebar {
    background: #1e293b;
  }

  .left-panel,
  .right-panel {
    background: #1e293b;
  }

  .tr-row,
  .sg-track,
  .pl-item {
    border-color: #334155;
  }

  .tr-row:hover,
  .sg-track:hover,
  .pl-item:hover {
    background: #334155;
  }
  */
}

/* ═══════════════════════════════════════════════════════════════
   PRINT STYLES
   ═══════════════════════════════════════════════════════════════ */
@media print {
  #header,
  #sidebar,
  #footer,
  .hamburger,
  .sidebar-overlay {
    display: none !important;
  }

  #main {
    width: 100%;
    overflow: visible;
  }

  .main-body {
    overflow: visible;
  }

  body {
    overflow: visible;
    height: auto;
  }
}
