/* ============================================
   CASA APPLE - APPLE-INSPIRED DESIGN SYSTEM
   Modern, clean, and professional styling
   ============================================ */

/* ========== CSS VARIABLES ========== */
:root {
  /* Apple Color Palette */
  --apple-blue: #007AFF;
  --apple-green: #34C759;
  --apple-red: #FF3B30;
  --apple-orange: #FF9500;
  --apple-yellow: #FFCC00;
  --apple-gray: #8E8E93;
  --apple-gray-light: #C7C7CC;
  --apple-gray-lighter: #E5E5EA;
  
  /* Backgrounds */
  --bg-primary: #FFFFFF;
  --bg-secondary: #F2F2F7;
  --bg-tertiary: #FAFAFA;
  --bg-elevated: #FFFFFF;
  
  /* Text Colors */
  --text-primary: #000000;
  --text-secondary: #3C3C43;
  --text-tertiary: #8E8E93;
  --text-quaternary: #C7C7CC;
  
  /* Borders & Separators */
  --separator-light: rgba(60, 60, 67, 0.12);
  --separator-medium: rgba(60, 60, 67, 0.18);
  --separator-dark: rgba(60, 60, 67, 0.25);
  
  /* Shadows */
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.08);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.1);
  --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.12);
  --shadow-xl: 0 16px 48px rgba(0, 0, 0, 0.14);
  
  /* Border Radius */
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --radius-xl: 18px;
  --radius-full: 9999px;
  
  /* Spacing */
  --space-xs: 4px;
  --space-sm: 8px;
  --space-md: 12px;
  --space-lg: 16px;
  --space-xl: 24px;
  --space-2xl: 32px;
  --space-3xl: 48px;
  
  /* Typography */
  --font-system: -apple-system, BlinkMacSystemFont, "SF Pro Display", "SF Pro Text", "Helvetica Neue", Helvetica, Arial, sans-serif;
  --font-mono: "SF Mono", Monaco, "Cascadia Code", "Roboto Mono", Consolas, "Courier New", monospace;
}

/* ========== GLOBAL RESETS ========== */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

body {
  font-family: var(--font-system);
  background: var(--bg-secondary);
  color: var(--text-primary);
  line-height: 1.5;
  min-height: 100vh;
}

/* ========== TYPOGRAPHY ========== */
h1, h2, h3, h4, h5, h6 {
  font-weight: 600;
  line-height: 1.3;
  color: var(--text-primary);
  margin: 0;
}

h1 { font-size: 26px; letter-spacing: -0.015em; }
h2 { font-size: 22px; letter-spacing: -0.01em; }
h3 { font-size: 18px; letter-spacing: -0.008em; }
h4 { font-size: 16px; }
h5 { font-size: 14px; }
h6 { font-size: 13px; }

p {
  margin: 0;
  color: var(--text-secondary);
  font-size: 14px;
}

a {
  color: var(--apple-blue);
  text-decoration: none;
  transition: opacity 0.2s ease;
}

a:hover {
  opacity: 0.7;
}

/* ========== LAYOUT STRUCTURE ========== */
.app-shell {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ========== HEADER NAVIGATION ========== */
.app-header {
  background: rgba(255, 255, 255, 0.9);
  backdrop-filter: blur(20px) saturate(180%);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  border-bottom: 1px solid var(--separator-light);
  padding: 12px 24px;
  position: sticky;
  top: 0;
  z-index: 1000;
  box-shadow: 0 1px 0 rgba(0, 0, 0, 0.05);
}

.app-header-inner {
  max-width: 1400px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-lg);
}

.app-header-left {
  display: flex;
  align-items: center;
  gap: var(--space-md);
}

.app-logo {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-md);
  overflow: hidden;
  background: var(--bg-primary);
  box-shadow: var(--shadow-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.2s ease;
}

.app-logo:hover {
  transform: scale(1.05);
}

.app-logo img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.app-title {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.app-title-main {
  font-size: 17px;
  font-weight: 600;
  color: var(--text-primary);
  letter-spacing: -0.01em;
}

.app-title-sub {
  font-size: 13px;
  color: var(--text-tertiary);
  font-weight: 400;
}

/* Navigation Links */
.app-nav {
  display: flex;
  gap: var(--space-xs);
  flex-wrap: wrap;
  align-items: center;
}

.app-nav a {
  font-size: 14px;
  font-weight: 500;
  padding: 6px 14px;
  border-radius: var(--radius-full);
  color: var(--text-secondary);
  transition: all 0.2s ease;
  background: transparent;
}

.app-nav a:hover {
  background: var(--bg-secondary);
  color: var(--text-primary);
  opacity: 1;
}

.app-nav a.active {
  background: var(--apple-blue);
  color: white;
}

/* ========== MAIN CONTENT ========== */
.app-main {
  flex: 1;
  padding: var(--space-2xl) var(--space-lg);
  max-width: 1400px;
  width: 100%;
  margin: 0 auto;
}

.page-card {
  background: var(--bg-primary);
  border-radius: var(--radius-lg);
  padding: 20px;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--separator-light);
}

/* ========== BUTTONS ========== */
.btn {
  display: inline-flex;
  align-items: center;
  gap: var(--space-xs);
  padding: 7px 14px;
  font-size: 13px;
  font-weight: 500;
  border-radius: var(--radius-md);
  border: none;
  background: var(--bg-secondary);
  color: var(--text-primary);
  cursor: pointer;
  transition: all 0.2s ease;
  text-decoration: none;
  white-space: nowrap;
}

.btn:hover {
  background: var(--apple-gray-lighter);
  transform: translateY(-1px);
  box-shadow: var(--shadow-sm);
}

.btn:active {
  transform: translateY(0);
}

.btn-primary {
  background: var(--apple-blue);
  color: white;
}

.btn-primary:hover {
  background: #0056D6;
  opacity: 1;
}

.btn-danger {
  background: var(--apple-red);
  color: white;
}

.btn-danger:hover {
  background: #D32F2F;
  opacity: 1;
}

.btn-success {
  background: var(--apple-green);
  color: white;
}

.btn-success:hover {
  background: #28A745;
  opacity: 1;
}

.btn-small {
  padding: 4px 9px;
  font-size: 12px;
}

.btn-icon {
  padding: 7px;
  width: 32px;
  height: 32px;
  justify-content: center;
}

/* ========== FORM ELEMENTS ========== */
.form-group {
  margin-bottom: var(--space-lg);
}

label {
  display: block;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: var(--space-xs);
}

input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
input[type="date"],
input[type="tel"],
select,
textarea {
  width: 100%;
  padding: 8px 12px;
  font-size: 14px;
  font-family: var(--font-system);
  border: 1px solid var(--separator-medium);
  border-radius: var(--radius-md);
  background: var(--bg-primary);
  color: var(--text-primary);
  transition: all 0.2s ease;
  outline: none;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--apple-blue);
  box-shadow: 0 0 0 3px rgba(0, 122, 255, 0.1);
}

input::placeholder,
textarea::placeholder {
  color: var(--text-quaternary);
}

select {
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg width='12' height='8' viewBox='0 0 12 8' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M1 1L6 6L11 1' stroke='%238E8E93' stroke-width='2' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 40px;
}

textarea {
  resize: vertical;
  min-height: 80px;
}

input[type="checkbox"] {
  width: 18px;
  height: 18px;
  cursor: pointer;
  accent-color: var(--apple-blue);
}

/* ========== TOOLBAR ========== */
.toolbar {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  flex-wrap: wrap;
  margin-bottom: var(--space-lg);
  padding: var(--space-md);
  background: var(--bg-tertiary);
  border-radius: var(--radius-md);
  border: 1px solid var(--separator-light);
}

.toolbar form {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  flex-wrap: wrap;
  flex: 1;
}

.toolbar input[type="text"],
.toolbar input[type="number"],
.toolbar select {
  padding: 6px 10px;
  font-size: 14px;
  min-width: 120px;
}

.toolbar label {
  display: flex;
  align-items: center;
  gap: var(--space-xs);
  font-size: 13px;
  margin: 0;
  cursor: pointer;
  color: var(--text-secondary);
}

/* ========== TABLES ========== */
table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 13px;
  margin-top: var(--space-lg);
}

thead {
  background: var(--bg-tertiary);
}

th {
  padding: 10px 14px;
  text-align: left;
  font-weight: 600;
  font-size: 12px;
  color: var(--text-secondary);
  border-bottom: 1px solid var(--separator-medium);
  white-space: nowrap;
}

th:first-child {
  border-top-left-radius: var(--radius-md);
}

th:last-child {
  border-top-right-radius: var(--radius-md);
}

td {
  padding: 10px 14px;
  border-bottom: 1px solid var(--separator-light);
  color: var(--text-primary);
  vertical-align: middle;
}

tr:last-child td {
  border-bottom: none;
}

tbody tr {
  transition: background-color 0.15s ease;
}

tbody tr:hover {
  background: var(--bg-tertiary);
}

/* ========== BADGES ========== */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 8px;
  border-radius: var(--radius-full);
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
}

.badge-ingresado {
  background: rgba(0, 122, 255, 0.1);
  color: var(--apple-blue);
}

.badge-en_diagnostico {
  background: rgba(255, 149, 0, 0.1);
  color: var(--apple-orange);
}

.badge-presupuestado {
  background: rgba(175, 82, 222, 0.1);
  color: #AF52DE;
}

.badge-en_reparacion {
  background: rgba(255, 204, 0, 0.1);
  color: #F2994A;
}

.badge-a_espera_repuesto {
  background: rgba(142, 142, 147, 0.1);
  color: var(--apple-gray);
}

.badge-listo {
  background: rgba(52, 199, 89, 0.1);
  color: var(--apple-green);
}

.badge-entregado {
  background: rgba(142, 142, 147, 0.1);
  color: var(--apple-gray);
}

.badge-cancelado {
  background: rgba(255, 59, 48, 0.1);
  color: var(--apple-red);
}

/* ========== PRIORITY INDICATORS ========== */
.prio-0 {
  color: var(--apple-green);
  font-weight: 600;
}

.prio-1 {
  color: var(--apple-orange);
  font-weight: 600;
}

.prio-2 {
  color: var(--apple-red);
  font-weight: 700;
}

/* ========== CARDS ========== */
.card {
  background: var(--bg-primary);
  border: 1px solid var(--separator-light);
  border-radius: var(--radius-lg);
  padding: var(--space-lg);
  box-shadow: var(--shadow-sm);
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-md);
}

.card-title {
  font-size: 17px;
  font-weight: 600;
  color: var(--text-primary);
}

.card-body {
  color: var(--text-secondary);
}

/* ========== MODAL/DIALOG ========== */
.modal-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.4);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-lg);
}

.modal-content {
  background: var(--bg-primary);
  border-radius: var(--radius-xl);
  max-width: 600px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow-xl);
  animation: modalSlideIn 0.3s ease-out;
}

@keyframes modalSlideIn {
  from {
    opacity: 0;
    transform: translateY(20px) scale(0.95);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

/* ========== ALERTS & MESSAGES ========== */
.alert {
  padding: var(--space-md) var(--space-lg);
  border-radius: var(--radius-md);
  font-size: 14px;
  margin-bottom: var(--space-lg);
  display: flex;
  align-items: center;
  gap: var(--space-sm);
}

.alert-info {
  background: rgba(0, 122, 255, 0.1);
  color: var(--apple-blue);
  border: 1px solid rgba(0, 122, 255, 0.2);
}

.alert-success {
  background: rgba(52, 199, 89, 0.1);
  color: var(--apple-green);
  border: 1px solid rgba(52, 199, 89, 0.2);
}

.alert-warning {
  background: rgba(255, 149, 0, 0.1);
  color: var(--apple-orange);
  border: 1px solid rgba(255, 149, 0, 0.2);
}

.alert-error {
  background: rgba(255, 59, 48, 0.1);
  color: var(--apple-red);
  border: 1px solid rgba(255, 59, 48, 0.2);
}

/* ========== LOADING STATES ========== */
.loading {
  display: inline-block;
  width: 20px;
  height: 20px;
  border: 2px solid var(--separator-light);
  border-top-color: var(--apple-blue);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ========== RESPONSIVE DESIGN ========== */
@media (max-width: 768px) {
  .app-header {
    padding: 10px 16px;
  }
  
  .app-header-inner {
    flex-direction: column;
    align-items: flex-start;
    gap: var(--space-sm);
  }
  
  .app-nav {
    width: 100%;
    justify-content: flex-start;
  }
  
  .app-main {
    padding: var(--space-lg) var(--space-md);
  }
  
  .page-card {
    padding: var(--space-lg);
    border-radius: var(--radius-md);
  }
  
  .toolbar {
    flex-direction: column;
    align-items: stretch;
  }
  
  .toolbar form {
    flex-direction: column;
    align-items: stretch;
  }
  
  .toolbar input[type="text"],
  .toolbar select {
    width: 100%;
    min-width: 0;
  }
  
  h1 { font-size: 28px; }
  h2 { font-size: 24px; }
  h3 { font-size: 20px; }
  
  table {
    font-size: 13px;
  }
  
  th, td {
    padding: 8px 10px;
  }
}

@media (max-width: 480px) {
  .app-logo {
    width: 36px;
    height: 36px;
  }
  
  .app-title-main {
    font-size: 16px;
  }
  
  .app-title-sub {
    font-size: 12px;
  }
  
  .app-nav a {
    font-size: 13px;
    padding: 5px 12px;
  }
  
  .page-card {
    padding: var(--space-md);
  }
  
  .btn {
    padding: 7px 14px;
    font-size: 13px;
  }
}

/* ========== UTILITY CLASSES ========== */
.text-center { text-align: center; }
.text-right { text-align: right; }
.text-muted { color: var(--text-tertiary); }
.text-small { font-size: 13px; }
.text-bold { font-weight: 600; }

.mt-xs { margin-top: var(--space-xs); }
.mt-sm { margin-top: var(--space-sm); }
.mt-md { margin-top: var(--space-md); }
.mt-lg { margin-top: var(--space-lg); }
.mt-xl { margin-top: var(--space-xl); }

.mb-xs { margin-bottom: var(--space-xs); }
.mb-sm { margin-bottom: var(--space-sm); }
.mb-md { margin-bottom: var(--space-md); }
.mb-lg { margin-bottom: var(--space-lg); }
.mb-xl { margin-bottom: var(--space-xl); }

.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-sm { gap: var(--space-sm); }
.gap-md { gap: var(--space-md); }
.gap-lg { gap: var(--space-lg); }

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

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.slide-up {
  animation: slideUp 0.3s ease-out;
}

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