/* =============================================================================
   OVPS — Office of the Vice President System
   app.css — Theme tokens, utilities, and component styles
   ============================================================================= */

/* -----------------------------------------------------------------------------
   1. CSS Custom Properties — Light theme (default)
   ----------------------------------------------------------------------------- */
:root[data-theme="light"] {
  --color-primary: #1B4332;
  --color-accent:  #B8860B;
  --color-danger:  #9B2226;
  --color-bg:      #FAFAF7;
  --color-surface: #FFFFFF;
  --color-text:    #2D2D2D;
  --color-muted:   #6C757D;
  --color-border:  #D8D4CC;
}

/* -----------------------------------------------------------------------------
   2. CSS Custom Properties — Dark theme
   ----------------------------------------------------------------------------- */
:root[data-theme="dark"] {
  --color-primary: #2D6A4F;
  --color-accent:  #D4A537;
  --color-danger:  #C44569;
  --color-bg:      #0F1419;
  --color-surface: #1A2028;
  --color-text:    #E8E6E1;
  --color-muted:   #8B9199;
  --color-border:  #2A3038;
}

/* Fallback for when data-theme is missing — assume light */
:root {
  --color-primary: #1B4332;
  --color-accent:  #B8860B;
  --color-danger:  #9B2226;
  --color-bg:      #FAFAF7;
  --color-surface: #FFFFFF;
  --color-text:    #2D2D2D;
  --color-muted:   #6C757D;
  --color-border:  #D8D4CC;
}

/* -----------------------------------------------------------------------------
   3. Base resets
   ----------------------------------------------------------------------------- */
*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  font-size: 16px;
  scroll-behavior: smooth;
}

body {
  margin: 0;
  font-family: 'Inter', ui-sans-serif, system-ui, sans-serif;
  background-color: var(--color-bg);
  color: var(--color-text);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

a {
  color: var(--color-primary);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

/* -----------------------------------------------------------------------------
   4. Scrollbar styling
   ----------------------------------------------------------------------------- */
* {
  scrollbar-width: thin;
  scrollbar-color: var(--color-border) transparent;
}

*::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

*::-webkit-scrollbar-track {
  background: transparent;
}

*::-webkit-scrollbar-thumb {
  background-color: var(--color-border);
  border-radius: 3px;
}

*::-webkit-scrollbar-thumb:hover {
  background-color: var(--color-muted);
}

/* -----------------------------------------------------------------------------
   5. Focus ring
   ----------------------------------------------------------------------------- */
:focus-visible {
  outline: 2px solid var(--color-accent);
  outline-offset: 2px;
  border-radius: 4px;
}

/* -----------------------------------------------------------------------------
   6. Sidebar transitions
   ----------------------------------------------------------------------------- */
#sidebar {
  transition: width 0.25s ease, transform 0.25s ease;
  will-change: width, transform;
}

#sidebar.sidebar-collapsed .sidebar-label {
  display: none;
}

#sidebar.sidebar-collapsed {
  width: 64px !important;
}

#sidebar.sidebar-collapsed #sidebar-collapse-btn i {
  transform: rotate(180deg);
}

#main-wrapper {
  transition: margin-left 0.25s ease;
}

/* -----------------------------------------------------------------------------
   7. AI panel slide-in animation
   ----------------------------------------------------------------------------- */
#ai-panel {
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  will-change: transform;
}

#ai-panel.ai-panel-open {
  transform: translateX(0) !important;
}

/* Dim overlay when AI panel is open */
.ai-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.3);
  z-index: 40;
  animation: fadeIn 0.2s ease;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

@keyframes slideInRight {
  from { transform: translateX(100%); }
  to   { transform: translateX(0);    }
}

/* -----------------------------------------------------------------------------
   8. Classification badge colors
   ----------------------------------------------------------------------------- */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.125rem 0.625rem;
  border-radius: 9999px;
  font-size: 0.6875rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  line-height: 1.4;
}

.badge-public {
  background: #065f46;
  color: #a7f3d0;
}

.badge-internal {
  background: #1e3a5f;
  color: #bfdbfe;
}

.badge-confidential {
  background: #713f12;
  color: #fde68a;
}

.badge-secret {
  background: #7c2d12;
  color: #fed7aa;
}

.badge-top-secret {
  background: #7f1d1d;
  color: #fecaca;
  animation: pulse-border 2s infinite;
}

@keyframes pulse-border {
  0%, 100% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.4); }
  50%       { box-shadow: 0 0 0 4px rgba(239, 68, 68, 0); }
}

/* -----------------------------------------------------------------------------
   9. RAG status colors (Red / Amber / Green)
   ----------------------------------------------------------------------------- */
.rag-red {
  color: var(--color-danger);
}

.rag-red-bg {
  background: var(--color-danger);
  color: #ffffff;
}

.rag-amber {
  color: var(--color-accent);
}

.rag-amber-bg {
  background: var(--color-accent);
  color: #ffffff;
}

.rag-green {
  color: var(--color-primary);
}

.rag-green-bg {
  background: var(--color-primary);
  color: #ffffff;
}

/* RAG indicator dot */
.rag-dot {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}

.rag-dot-red    { background: var(--color-danger); }
.rag-dot-amber  { background: var(--color-accent); }
.rag-dot-green  { background: var(--color-primary); }

/* -----------------------------------------------------------------------------
   10. Status pill
   ----------------------------------------------------------------------------- */
.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  padding: 0.25rem 0.75rem;
  border-radius: 9999px;
  font-size: 0.75rem;
  font-weight: 600;
  line-height: 1;
  white-space: nowrap;
}

.status-pill::before {
  content: '';
  display: inline-block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
  opacity: 0.7;
}

/* Common status variants */
.status-draft      { background: rgba(108,117,125,0.15); color: var(--color-muted); }
.status-active     { background: rgba(27,67,50,0.15);   color: var(--color-primary); }
.status-pending    { background: rgba(184,134,11,0.15);  color: var(--color-accent); }
.status-approved   { background: rgba(22,101,52,0.15);   color: #16a34a; }
.status-rejected   { background: rgba(155,34,38,0.15);   color: var(--color-danger); }
.status-closed     { background: rgba(108,117,125,0.1);  color: var(--color-muted); }
.status-complete   { background: rgba(22,101,52,0.15);   color: #16a34a; }
.status-overdue    { background: rgba(155,34,38,0.15);   color: var(--color-danger); }

/* -----------------------------------------------------------------------------
   11. Card component
   ----------------------------------------------------------------------------- */
.card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: 0.75rem;
  padding: 1.5rem;
  box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.06);
  transition: box-shadow 0.15s ease;
}

.card:hover {
  box-shadow: 0 4px 12px 0 rgba(0, 0, 0, 0.08);
}

/* -----------------------------------------------------------------------------
   12. Form controls
   ----------------------------------------------------------------------------- */
.form-input,
.form-select,
.form-textarea {
  width: 100%;
  background: var(--color-bg);
  color: var(--color-text);
  border: 1px solid var(--color-border);
  border-radius: 0.5rem;
  padding: 0.5rem 0.75rem;
  font-size: 0.875rem;
  line-height: 1.5;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
  font-family: inherit;
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
  outline: none;
  border-color: var(--color-accent);
  box-shadow: 0 0 0 3px rgba(184, 134, 11, 0.15);
}

.form-label {
  display: block;
  font-size: 0.8125rem;
  font-weight: 600;
  margin-bottom: 0.375rem;
  color: var(--color-text);
}

.form-error {
  font-size: 0.75rem;
  color: var(--color-danger);
  margin-top: 0.25rem;
}

.form-hint {
  font-size: 0.75rem;
  color: var(--color-muted);
  margin-top: 0.25rem;
}

/* -----------------------------------------------------------------------------
   13. Button system
   ----------------------------------------------------------------------------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.5rem 1rem;
  border-radius: 0.5rem;
  font-size: 0.875rem;
  font-weight: 600;
  line-height: 1;
  border: none;
  cursor: pointer;
  transition: opacity 0.15s ease, box-shadow 0.15s ease;
  text-decoration: none;
  white-space: nowrap;
  font-family: inherit;
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-primary {
  background: var(--color-primary);
  color: #ffffff;
}

.btn-primary:hover:not(:disabled) {
  opacity: 0.9;
}

.btn-accent {
  background: var(--color-accent);
  color: #ffffff;
}

.btn-danger {
  background: var(--color-danger);
  color: #ffffff;
}

.btn-outline {
  background: transparent;
  color: var(--color-text);
  border: 1px solid var(--color-border);
}

.btn-outline:hover:not(:disabled) {
  background: var(--color-bg);
}

.btn-sm {
  padding: 0.375rem 0.75rem;
  font-size: 0.8125rem;
}

.btn-lg {
  padding: 0.75rem 1.5rem;
  font-size: 1rem;
}

/* -----------------------------------------------------------------------------
   14. Table styles
   ----------------------------------------------------------------------------- */
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}

.data-table thead th {
  text-align: left;
  padding: 0.75rem 1rem;
  font-size: 0.6875rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--color-muted);
  border-bottom: 1px solid var(--color-border);
  white-space: nowrap;
}

.data-table tbody td {
  padding: 0.875rem 1rem;
  border-bottom: 1px solid var(--color-border);
  color: var(--color-text);
  vertical-align: middle;
}

.data-table tbody tr:hover {
  background: var(--color-bg);
}

.data-table tbody tr:last-child td {
  border-bottom: none;
}

/* -----------------------------------------------------------------------------
   15. Kanban board
   ----------------------------------------------------------------------------- */
.kanban-board {
  display: flex;
  gap: 1rem;
  overflow-x: auto;
  padding-bottom: 1rem;
  align-items: flex-start;
}

.kanban-column {
  flex-shrink: 0;
  width: 280px;
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: 0.75rem;
  display: flex;
  flex-direction: column;
  max-height: calc(100vh - 200px);
}

.kanban-column-header {
  padding: 0.875rem 1rem;
  font-size: 0.8125rem;
  font-weight: 700;
  color: var(--color-text);
  border-bottom: 1px solid var(--color-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}

.kanban-cards {
  flex: 1;
  overflow-y: auto;
  padding: 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  min-height: 100px;
}

.kanban-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: 0.5rem;
  padding: 0.75rem;
  cursor: grab;
  transition: box-shadow 0.15s ease, transform 0.1s ease;
  font-size: 0.8125rem;
}

.kanban-card:active {
  cursor: grabbing;
}

.kanban-card.dragging {
  opacity: 0.5;
  transform: scale(0.98);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15);
}

.kanban-drop-target {
  border-color: var(--color-accent);
  background: rgba(184, 134, 11, 0.05);
}

.kanban-empty {
  text-align: center;
  padding: 2rem 1rem;
  font-size: 0.75rem;
  color: var(--color-muted);
  border: 2px dashed var(--color-border);
  border-radius: 0.5rem;
}

/* -----------------------------------------------------------------------------
   16. Calendar component
   ----------------------------------------------------------------------------- */
.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 1px;
  background: var(--color-border);
  border: 1px solid var(--color-border);
  border-radius: 0.5rem;
  overflow: hidden;
}

.calendar-cell {
  background: var(--color-surface);
  min-height: 100px;
  padding: 0.375rem;
}

.calendar-cell.other-month {
  background: var(--color-bg);
  opacity: 0.6;
}

.calendar-cell.today {
  background: rgba(27, 67, 50, 0.05);
}

.calendar-day-number {
  font-size: 0.75rem;
  font-weight: 600;
  width: 24px;
  height: 24px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
}

.calendar-cell.today .calendar-day-number {
  background: var(--color-primary);
  color: #ffffff;
}

.calendar-event-pill {
  font-size: 0.6875rem;
  padding: 1px 6px;
  border-radius: 4px;
  margin-bottom: 2px;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  cursor: pointer;
  background: var(--color-primary);
  color: #ffffff;
}

.calendar-week-view {
  display: grid;
  grid-template-columns: 60px repeat(7, 1fr);
  position: relative;
}

.calendar-time-slot {
  height: 48px;
  border-bottom: 1px solid var(--color-border);
  display: flex;
  align-items: flex-start;
  padding: 4px;
  font-size: 0.6875rem;
  color: var(--color-muted);
}

/* -----------------------------------------------------------------------------
   17. Modal styles
   ----------------------------------------------------------------------------- */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 40;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  animation: fadeIn 0.15s ease;
}

.modal-panel {
  background: var(--color-surface);
  border-radius: 0.75rem;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
  max-width: 520px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  animation: scaleIn 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  z-index: 50;
  position: relative;
}

@keyframes scaleIn {
  from { opacity: 0; transform: scale(0.95) translateY(-10px); }
  to   { opacity: 1; transform: scale(1)    translateY(0);      }
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--color-border);
}

.modal-title {
  font-size: 1rem;
  font-weight: 700;
  color: var(--color-text);
}

.modal-body {
  padding: 1.5rem;
}

.modal-footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.75rem;
  padding: 1rem 1.5rem;
  border-top: 1px solid var(--color-border);
}

/* -----------------------------------------------------------------------------
   18. Tooltip
   ----------------------------------------------------------------------------- */
[data-tooltip] {
  position: relative;
}

[data-tooltip]::after {
  content: attr(data-tooltip);
  position: absolute;
  bottom: calc(100% + 6px);
  left: 50%;
  transform: translateX(-50%);
  background: var(--color-text);
  color: var(--color-surface);
  font-size: 0.6875rem;
  padding: 4px 8px;
  border-radius: 4px;
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.15s ease;
  z-index: 100;
}

[data-tooltip]:hover::after {
  opacity: 1;
}

/* -----------------------------------------------------------------------------
   19. Loading / skeleton
   ----------------------------------------------------------------------------- */
.skeleton {
  background: linear-gradient(
    90deg,
    var(--color-border) 25%,
    var(--color-bg) 37%,
    var(--color-border) 63%
  );
  background-size: 400% 100%;
  animation: skeleton-shimmer 1.4s ease infinite;
  border-radius: 0.25rem;
}

@keyframes skeleton-shimmer {
  0%   { background-position: 100% 50%; }
  100% { background-position:   0% 50%; }
}

/* -----------------------------------------------------------------------------
   20. Topbar / sidebar layout helpers
   ----------------------------------------------------------------------------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
}

/* -----------------------------------------------------------------------------
   21. Print media — hide chrome
   ----------------------------------------------------------------------------- */
@media print {
  #sidebar,
  #topbar,
  .topbar,
  #ai-panel,
  #flash-container,
  [role="complementary"],
  .no-print {
    display: none !important;
  }

  body {
    background: #ffffff;
    color: #000000;
  }

  .card {
    box-shadow: none;
    border: 1px solid #cccccc;
  }
}

/* -----------------------------------------------------------------------------
   22. Responsive helpers
   ----------------------------------------------------------------------------- */
@media (max-width: 767px) {
  #sidebar {
    position: fixed;
    z-index: 30;
  }
}
