/* ====================================================
   PORTAL SHINY — OIRSA/FAO
   ==================================================== */

:root {
  --oirsa-green-dark:    #2E6B4A;
  --oirsa-green-mid:     #4A8C6A;
  --oirsa-green-light:   #A8D5BC;
  --oirsa-green-pale:    #EAF5EF;
  --oirsa-header-bg:     #1E4D35;
  --oirsa-accent:        #F0A500;
  --oirsa-accent-light:  #FFF3D6;
  --fao-blue:            #0E73BE;
  --fao-blue-light:      #E8F3FB;
  --text-dark:           #1A2E25;
  --text-mid:            #3D5C4A;
  --text-light:          #6B8C7A;
  --bg-page:             #F4F8F5;
  --bg-card:             #FFFFFF;
  --border-color:        #C8DDD3;
  --shadow-sm:           0 1px 3px rgba(46,107,74,0.08);
  --shadow-md:           0 4px 12px rgba(46,107,74,0.12);
  --radius-sm:           6px;
  --radius-md:           10px;
  --radius-lg:           16px;
}

* { box-sizing: border-box; }
html, body {
  background-color: var(--bg-page);
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  color: var(--text-dark);
  margin: 0;
  padding: 0;
  min-height: 100vh;
  -webkit-text-size-adjust: 100%;
}
img { max-width: 100%; height: auto; }

/* RESPONSIVE GRIDS */
.gallery-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 18px;
}
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 16px;
}
.form-grid { display: grid; gap: 14px; }
.form-grid-2    { grid-template-columns: 1fr 1fr; }
.form-grid-desc { grid-template-columns: 2fr 1fr 1fr; }

/* HEADER */
.platform-header {
  background: var(--oirsa-header-bg);
  border-bottom: 3px solid var(--oirsa-accent);
  position: sticky;
  top: 0;
  z-index: 1000;
  box-shadow: 0 2px 8px rgba(0,0,0,0.2);
}
.header-top-bar {
  background: rgba(0,0,0,0.15);
  padding: 4px 24px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 11px;
  color: rgba(255,255,255,0.7);
}
.header-main {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 24px;
  gap: 20px;
  flex-wrap: wrap;
}
.header-logos { display: flex; align-items: center; gap: 20px; }
.header-logos img { height: 50px; object-fit: contain; }
.header-divider { width: 1px; height: 42px; background: rgba(255,255,255,0.25); }
.header-titles { color: white; }
.header-title {
  color: white; font-size: 19px; font-weight: 600; letter-spacing: 0.3px; margin: 0;
}
.header-subtitle {
  color: rgba(255,255,255,0.7); font-size: 12px; margin-top: 2px;
}
.header-user {
  display: flex; align-items: center; gap: 12px;
  color: white; font-size: 13px;
}
.header-user .user-badge {
  background: rgba(255,255,255,0.12);
  padding: 6px 12px;
  border-radius: 20px;
  display: flex;
  align-items: center;
  gap: 8px;
}

/* NAV */
.platform-nav {
  background: var(--oirsa-green-dark);
  border-bottom: 1px solid rgba(255,255,255,0.1);
}
.nav-tabs-row {
  display: flex;
  padding: 0 16px;
  max-width: 1280px;
  margin: 0 auto;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,0.25) transparent;
}
.nav-tabs-row::-webkit-scrollbar { height: 4px; }
.nav-tabs-row::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.25); border-radius: 2px; }
.nav-tab {
  color: rgba(255,255,255,0.88) !important;
  background: transparent !important;
  border: none !important;
  border-bottom: 3px solid transparent !important;
  border-radius: 0 !important;
  padding: 14px 22px !important;
  font-size: 14px;
  font-weight: 500;
  letter-spacing: 0.2px;
  cursor: pointer;
  text-decoration: none !important;
  transition: background 0.2s, color 0.2s, border-color 0.2s;
  display: inline-block;
  white-space: nowrap;
  flex-shrink: 0;
}
.nav-tab:hover {
  background: rgba(255,255,255,0.08) !important;
  color: white !important;
  text-decoration: none !important;
}
.nav-tab.active {
  background: rgba(255,255,255,0.15) !important;
  color: white !important;
  border-bottom-color: var(--oirsa-accent) !important;
}

/* CONTENT */
.main-content {
  max-width: 1280px;
  margin: 0 auto;
  padding: 28px 24px;
}
.page-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 22px;
  flex-wrap: wrap;
  gap: 12px;
}
.gallery-search { width: 240px; max-width: 100%; }
@media (max-width: 480px) {
  .gallery-search { width: 100%; }
  .gallery-search .form-group { width: 100%; margin-bottom: 0; }
}
.page-title {
  font-size: 22px;
  font-weight: 700;
  color: var(--text-dark);
  margin: 0;
}
.page-subtitle {
  font-size: 13px;
  color: var(--text-light);
  margin-top: 4px;
}

/* CARDS */
.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 18px 20px;
  box-shadow: var(--shadow-sm);
}
.stat-number { font-size: 28px; font-weight: 700; color: var(--oirsa-green-dark); line-height: 1; }
.stat-label  { font-size: 13px; color: var(--text-light); margin-top: 6px; }

.app-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 18px;
  transition: transform 0.2s, box-shadow 0.2s, border-color 0.2s;
  height: 100%;
  display: flex;
  flex-direction: column;
}
.app-card:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-md);
  border-color: var(--oirsa-green-mid);
}
.app-card-header { display: flex; align-items: flex-start; gap: 12px; margin-bottom: 10px; }
.app-icon {
  width: 48px; height: 48px;
  background: var(--oirsa-green-pale);
  border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
  font-size: 24px; flex-shrink: 0;
}
.app-card-title {
  font-size: 16px; font-weight: 600; color: var(--text-dark); margin: 0 0 4px 0;
}
.app-card-author {
  font-size: 12px; color: var(--text-light);
}
.app-card-desc {
  font-size: 13px; color: var(--text-mid); margin: 10px 0;
  line-height: 1.45;
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical;
  overflow: hidden; min-height: 56px;
}
.app-card-footer {
  display: flex; justify-content: space-between; align-items: center;
  margin-top: auto; padding-top: 12px;
  border-top: 1px solid var(--border-color);
}

/* BADGES */
.badge-oirsa {
  display: inline-block;
  font-size: 11px;
  padding: 3px 10px;
  border-radius: 12px;
  font-weight: 600;
  letter-spacing: 0.2px;
}
.badge-public    { background: #E6F4EC; color: #1E6B3A; }
.badge-private   { background: #FFF0E6; color: #8B4513; }
.badge-restricted{ background: var(--fao-blue-light); color: var(--fao-blue); }
.badge-pending   { background: #FFF8E1; color: #B8860B; }
.badge-admin     { background: #F3E5F5; color: #6A1B9A; }
.badge-publisher { background: var(--oirsa-green-pale); color: var(--oirsa-green-dark); }
.badge-visitor   { background: #ECEFF1; color: #455A64; }
.badge-active    { background: #E6F4EC; color: #1E6B3A; }
.badge-suspended { background: #FFEBEE; color: #C62828; }

/* BUTTONS */
.btn-oirsa, .btn-oirsa-outline {
  border-radius: var(--radius-sm);
  padding: 9px 20px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  text-decoration: none !important;
}
.btn-oirsa {
  background: var(--oirsa-green-dark);
  color: white !important;
  border: 1px solid var(--oirsa-green-dark);
}
.btn-oirsa:hover  { background: var(--oirsa-green-mid); border-color: var(--oirsa-green-mid); }
.btn-oirsa:active { transform: scale(0.98); }
.btn-oirsa-outline {
  background: transparent;
  color: var(--oirsa-green-dark) !important;
  border: 1px solid var(--oirsa-green-dark);
}
.btn-oirsa-outline:hover { background: var(--oirsa-green-pale); }
.btn-sm { padding: 5px 12px; font-size: 12px; }

/* AUTH */
.auth-container {
  min-height: 100vh;
  background: linear-gradient(135deg, var(--oirsa-header-bg) 0%, var(--oirsa-green-dark) 60%, var(--oirsa-green-mid) 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.auth-card {
  background: white;
  border-radius: var(--radius-lg);
  padding: 36px 40px;
  width: 100%;
  max-width: 460px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.28);
}
.auth-logos {
  display: flex; align-items: center; justify-content: center;
  gap: 20px; margin-bottom: 22px; padding-bottom: 20px;
  border-bottom: 1px solid var(--border-color);
}
.auth-logos img { height: 44px; object-fit: contain; }
.auth-logos .divider { width: 1px; height: 40px; background: var(--border-color); }
.auth-title { font-size: 20px; font-weight: 700; color: var(--text-dark); text-align: center; margin: 0 0 6px; }
.auth-subtitle { font-size: 13px; color: var(--text-light); text-align: center; margin: 0 0 22px; }
.auth-switch {
  text-align: center; font-size: 13px; color: var(--text-light);
  margin-top: 18px; padding-top: 16px; border-top: 1px solid var(--border-color);
}
.auth-switch a { color: var(--oirsa-green-dark); font-weight: 600; cursor: pointer; }

/* FORMS */
.form-group label { font-weight: 500; color: var(--text-mid); font-size: 13px; }
.form-control {
  border-radius: var(--radius-sm) !important;
  border: 1px solid var(--border-color) !important;
  padding: 9px 12px !important;
  font-size: 14px !important;
}
.form-control:focus {
  border-color: var(--oirsa-green-dark) !important;
  box-shadow: 0 0 0 3px rgba(46,107,74,0.12) !important;
}

/* ALERTS */
.alert-oirsa {
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  margin: 12px 0;
  border-left: 4px solid;
}
.alert-success { background: #E6F4EC; color: #1E6B3A; border-color: #1E6B3A; }
.alert-error   { background: #FFEBEE; color: #C62828; border-color: #C62828; }
.alert-info    { background: var(--fao-blue-light); color: var(--fao-blue); border-color: var(--fao-blue); }
.alert-warning { background: #FFF8E1; color: #B8860B; border-color: #B8860B; }

/* UPLOAD */
.upload-zone {
  border: 2px dashed var(--oirsa-green-light);
  border-radius: var(--radius-md);
  padding: 40px 20px;
  text-align: center;
  background: var(--oirsa-green-pale);
  transition: all 0.2s;
}
.upload-zone:hover {
  border-color: var(--oirsa-green-dark);
  background: #D8EFE3;
}

/* ADMIN SIDEBAR */
.admin-layout {
  display: grid;
  grid-template-columns: 220px 1fr;
  gap: 24px;
}
.admin-sidebar {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 10px 0;
  height: fit-content;
}
.admin-menu-item {
  padding: 11px 18px;
  cursor: pointer;
  color: var(--text-mid);
  font-size: 13.5px;
  display: flex;
  align-items: center;
  gap: 10px;
  border-left: 3px solid transparent;
  transition: all 0.15s;
}
.admin-menu-item:hover, .admin-menu-item.active {
  background: var(--oirsa-green-pale);
  color: var(--oirsa-green-dark);
  border-left-color: var(--oirsa-green-dark);
  font-weight: 600;
}

/* TABLES */
table.dataTable thead th {
  background: var(--oirsa-green-pale) !important;
  color: var(--oirsa-green-dark) !important;
  border-bottom: 2px solid var(--oirsa-green-dark) !important;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.4px;
}
.dataTables_wrapper {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}
.dataTables_wrapper table.dataTable { min-width: 560px; }
.dataTables_wrapper .dataTables_filter input,
.dataTables_wrapper .dataTables_length select {
  max-width: 100%;
}

/* FOOTER */
.platform-footer {
  background: var(--oirsa-header-bg);
  color: rgba(255,255,255,0.7);
  padding: 20px 24px;
  margin-top: 40px;
  font-size: 12px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
}

/* LOADING / MISC */
.shiny-notification {
  border-radius: var(--radius-sm) !important;
  box-shadow: var(--shadow-md) !important;
}
.install-log, #publish_live_log {
  font-family: 'Monaco', 'Consolas', monospace;
  font-size: 12px;
  background: #1A2E25;
  color: #A8D5BC;
  padding: 14px;
  border-radius: var(--radius-sm);
  max-height: 280px;
  overflow-y: auto;
  white-space: pre-wrap;
  border: none;
}

/* PROGRESS BAR de publish */
.publish-progress {
  margin: 20px 0;
}
.publish-progress-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
  font-size: 14px;
  color: var(--text-mid);
}
.publish-progress-header .status {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 500;
}
.publish-progress-header .percentage {
  font-weight: 700;
  color: var(--oirsa-green-dark);
  font-size: 16px;
}
.publish-progress-bar {
  width: 100%;
  height: 14px;
  background: var(--oirsa-green-pale);
  border-radius: 999px;
  overflow: hidden;
  border: 1px solid var(--border-color);
}
.publish-progress-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--oirsa-green-mid), var(--oirsa-green-dark));
  border-radius: 999px;
  transition: width 0.5s ease;
  background-size: 30px 30px;
  background-image: linear-gradient(135deg,
    rgba(255,255,255,0.18) 25%, transparent 25%,
    transparent 50%, rgba(255,255,255,0.18) 50%,
    rgba(255,255,255,0.18) 75%, transparent 75%);
  animation: progress-stripes 1s linear infinite;
}
.publish-progress-bar-fill.indeterminate {
  width: 40% !important;
  animation: progress-stripes 1s linear infinite, indeterminate 2s ease-in-out infinite;
}
@keyframes progress-stripes {
  from { background-position: 0 0; }
  to   { background-position: 30px 0; }
}
@keyframes indeterminate {
  0%   { margin-left: -40%; }
  100% { margin-left: 100%; }
}
.publish-spinner {
  width: 18px;
  height: 18px;
  border: 3px solid var(--oirsa-green-pale);
  border-top-color: var(--oirsa-green-dark);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  display: inline-block;
}
@keyframes spin {
  to { transform: rotate(360deg); }
}
.publish-current-pkg {
  font-family: 'Monaco', 'Consolas', monospace;
  background: var(--oirsa-green-pale);
  padding: 2px 8px;
  border-radius: 4px;
  color: var(--oirsa-green-dark);
}

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

@media (max-width: 1024px) {
  .main-content { max-width: 100%; padding: 24px 18px; }
  .nav-tabs-row { max-width: 100%; padding: 0 8px; }
  .form-grid-desc { grid-template-columns: 1fr 1fr; }
  .admin-layout { grid-template-columns: 180px 1fr; gap: 18px; }
}

@media (max-width: 768px) {
  .header-top-bar { padding: 4px 16px; font-size: 10px; }
  .header-main { padding: 12px 16px; gap: 12px; }
  .header-logos { gap: 12px; }
  .header-logos img { height: 38px; }
  .header-divider { height: 34px; }
  .header-title { font-size: 16px; }
  .header-subtitle { font-size: 11px; }
  .header-user { font-size: 12px; }
  .header-user .user-badge { padding: 4px 10px; gap: 6px; }
  .platform-footer { padding: 16px; font-size: 11px; }

  .auth-card { padding: 24px 22px; }
  .auth-title { font-size: 19px; }

  .admin-layout { grid-template-columns: 1fr; gap: 14px; }
  .admin-sidebar { display: flex; flex-wrap: wrap; padding: 6px; }
  .admin-menu-item { border-left: none; border-bottom: 3px solid transparent; padding: 10px 14px; font-size: 13px; }
  .admin-menu-item:hover, .admin-menu-item.active {
    border-left-color: transparent;
    border-bottom-color: var(--oirsa-green-dark);
  }

  .main-content { padding: 18px 14px; }
  .page-header { margin-bottom: 18px; }
  .page-title { font-size: 19px; }

  .nav-tab { padding: 12px 16px !important; font-size: 13px; }

  .form-grid-2, .form-grid-desc { grid-template-columns: 1fr; }
  .gallery-grid { grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 14px; }

  .app-card { padding: 14px; }
  .stat-card { padding: 14px 16px; }
  .stat-number { font-size: 24px; }

  .upload-zone { padding: 30px 14px; }
}

@media (max-width: 480px) {
  .header-top-bar { display: none; }
  .header-main { padding: 10px 12px; gap: 8px; flex-wrap: nowrap; }
  .header-logos { gap: 8px; }
  .header-logos img { height: 30px; }
  .header-divider { display: none; }
  .header-title { font-size: 14px; letter-spacing: 0; }
  .header-subtitle { display: none; }
  .header-titles { min-width: 0; flex: 1; }
  .header-user { gap: 6px; flex-shrink: 0; }
  .header-user .user-badge { padding: 4px 8px; font-size: 11px; }
  .header-user .user-badge > span:first-of-type { display: none; }

  .platform-footer { flex-direction: column; align-items: flex-start; gap: 4px; font-size: 10px; padding: 14px; }

  .auth-container { padding: 12px; }
  .auth-card { padding: 22px 18px; border-radius: var(--radius-md); }
  .auth-title { font-size: 17px; }
  .auth-logos img { height: 36px; }

  .main-content { padding: 14px 10px; }
  .page-title { font-size: 17px; }
  .page-subtitle { font-size: 12px; }
  .page-header { gap: 8px; }

  .nav-tab { padding: 10px 14px !important; font-size: 12px; }

  .btn-oirsa, .btn-oirsa-outline { padding: 8px 14px; font-size: 13px; }
  .btn-sm { padding: 5px 10px; font-size: 11px; }

  .gallery-grid { grid-template-columns: 1fr; gap: 12px; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .stat-number { font-size: 22px; }
  .stat-label { font-size: 12px; }

  .app-card { padding: 12px; }
  .app-icon { width: 40px; height: 40px; font-size: 20px; }
  .app-card-title { font-size: 15px; }
  .app-card-desc { font-size: 12px; min-height: 0; -webkit-line-clamp: 2; }

  .upload-zone { padding: 24px 12px; }
  .form-control { font-size: 16px !important; } /* evita zoom en iOS */

  .publish-progress-header { flex-direction: column; align-items: flex-start; gap: 6px; }
  .install-log, #publish_live_log { font-size: 11px; padding: 10px; }
}
