/* Arcana News AI - Main Styles */
@import 'variables.css';

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  min-height: 100vh;
  line-height: 1.5;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
}

/* Layout */
.app-layout {
  display: flex;
  min-height: 100vh;
}

/* Sidebar */
.sidebar {
  width: var(--sidebar-width);
  background: var(--bg-sidebar);
  padding: 1rem 0;
  position: fixed;
  left: 0;
  top: 0;
  height: 100vh;
  z-index: 100;
}

.sidebar-nav {
  list-style: none;
}

.sidebar-nav li {
  margin-bottom: 0.25rem;
}

.sidebar-nav a {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 1.25rem;
  color: var(--text-secondary);
  text-decoration: none;
  transition: all 0.2s;
}

.sidebar-nav a:hover {
  color: var(--text-primary);
  background: var(--bg-tertiary);
}

.sidebar-nav a.active {
  background: var(--accent-primary);
  color: white;
}

.sidebar-nav .icon {
  width: 20px;
  height: 20px;
  opacity: 0.8;
}

/* Main Content */
.main-content {
  flex: 1;
  margin-left: var(--sidebar-width);
  padding: 1.5rem;
  padding-left: max(1.5rem, env(safe-area-inset-left));
  padding-right: max(1.5rem, env(safe-area-inset-right));
  min-height: 100vh;
  min-width: 0;
}

/* Header */
.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 0;
  margin-bottom: 1.5rem;
}

.logo {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.logo-icon {
  width: 40px;
  height: 40px;
  background: var(--accent-gradient);
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 1.25rem;
}

.logo-text {
  font-size: 1.25rem;
  font-weight: 600;
}

.search-bar {
  flex: 1;
  max-width: 400px;
  margin: 0 2rem;
}

.search-bar input {
  width: 100%;
  padding: 0.625rem 1rem 0.625rem 2.5rem;
  background: var(--bg-tertiary);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: var(--border-radius);
  color: var(--text-primary);
  font-size: 0.9rem;
}

.search-bar input::placeholder {
  color: var(--text-muted);
}

.search-wrapper {
  position: relative;
}

.search-wrapper::before {
  content: '🔍';
  position: absolute;
  left: 0.75rem;
  top: 50%;
  transform: translateY(-50%);
  font-size: 0.9rem;
  opacity: 0.6;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.header-actions .user-name {
  color: var(--text-secondary);
  font-size: 0.9rem;
}

.header-actions .btn-icon {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--bg-tertiary);
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
}

.header-actions .btn-icon:hover {
  background: var(--accent-primary);
  color: white;
}

.btn-primary {
  padding: 0.5rem 1rem;
  background: var(--accent-primary);
  color: white;
  border: none;
  border-radius: var(--border-radius);
  cursor: pointer;
  font-size: 0.9rem;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
}

.btn-primary:hover {
  background: var(--accent-secondary);
}

/* Section Headers */
.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1rem;
}

.section-title {
  font-size: 1.5rem;
  font-weight: 600;
}

.section-subtitle {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-top: 0.25rem;
}

/* Cards */
.card {
  background: var(--bg-card);
  border-radius: var(--border-radius-lg);
  padding: 1.25rem;
  overflow-x: hidden;
  max-width: 100%;
  margin-bottom: 1.5rem;
  box-shadow: var(--shadow-card);
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1rem;
}

.chart-period-select {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.chart-period-select label {
  font-size: 0.9rem;
  color: var(--text-muted);
}

.period-select {
  padding: 0.5rem 2rem 0.5rem 0.75rem;
  background: var(--bg-tertiary);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: var(--border-radius);
  color: var(--text-primary);
  font-size: 0.9rem;
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='%23a0a0b8' viewBox='0 0 16 16'%3E%3Cpath d='M8 11L3 6h10l-5 5z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.5rem center;
}

.period-select:hover {
  border-color: var(--accent-primary);
}

.card-title {
  font-size: 1.1rem;
  font-weight: 600;
}

/* Company Cards Grid */
.companies-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1rem;
}

.company-card {
  background: var(--bg-tertiary);
  border-radius: var(--border-radius);
  padding: 1rem;
  display: flex;
  gap: 1rem;
  transition: all 0.2s;
}

.company-card:hover {
  background: rgba(79, 70, 229, 0.15);
}

.company-icon {
  width: 48px;
  height: 48px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 1.25rem;
  flex-shrink: 0;
}

.company-icon.blue { background: linear-gradient(135deg, #3b82f6, #6366f1); }
.company-icon.purple { background: linear-gradient(135deg, #7c3aed, #a855f7); }
.company-icon.red { background: linear-gradient(135deg, #ef4444, #dc2626); }
.company-icon.green { background: linear-gradient(135deg, #10b981, #059669); }

.company-content {
  flex: 1;
  min-width: 0;
}

.company-name {
  font-weight: 600;
  margin-bottom: 0.25rem;
}

.company-desc {
  font-size: 0.85rem;
  color: var(--text-secondary);
  line-height: 1.4;
}

.company-badge {
  background: var(--negative);
  color: white;
  font-size: 0.75rem;
  padding: 0.2rem 0.5rem;
  border-radius: 4px;
  font-weight: 600;
}

.company-card .dropdown-trigger {
  background: var(--bg-secondary);
  border: 1px solid rgba(255,255,255,0.1);
  padding: 0.35rem 0.75rem;
  border-radius: 6px;
  color: var(--text-secondary);
  font-size: 0.8rem;
  cursor: pointer;
}

/* Countries Section */
.countries-layout {
  display: grid;
  grid-template-columns: 1fr 1fr 1.5fr;
  gap: 1.5rem;
}

.country-list {
  list-style: none;
}

.country-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.5rem 0;
  border-bottom: 1px solid rgba(255,255,255,0.05);
}

.country-item:last-child {
  border-bottom: none;
}

.country-flag {
  width: 32px;
  height: 24px;
  border-radius: 4px;
  object-fit: cover;
}

.country-name {
  flex: 1;
}

.country-value {
  background: var(--bg-tertiary);
  padding: 0.25rem 0.5rem;
  border-radius: 4px;
  font-size: 0.9rem;
}

.progress-bar {
  height: 8px;
  background: var(--bg-tertiary);
  border-radius: 4px;
  margin-top: 1rem;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: var(--accent-gradient);
  border-radius: 4px;
  width: 75%;
}

.economy-donut {
  width: 120px;
  height: 120px;
  margin: 0 auto;
}

.chart-container {
  height: 120px;
  position: relative;
  width: 100%;
  max-width: 100%;
  overflow: hidden;
  min-width: 0;
}

/* Cryptocurrencies */
.crypto-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1rem;
}

.crypto-card {
  background: var(--bg-tertiary);
  border-radius: var(--border-radius);
  padding: 1rem;
  min-width: 0;
  overflow: hidden;
}

.crypto-header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
}

.crypto-icon {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 1rem;
}

.crypto-icon.btc { background: #f7931a; color: white; }
.crypto-icon.eth { background: #627eea; color: white; }
.crypto-icon.xrp { background: #23292f; color: white; }

.crypto-change.negative {
  color: var(--negative);
}

/* Commodities */
.commodities-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 1rem;
}

.commodity-item {
  background: var(--bg-tertiary);
  border-radius: var(--border-radius);
  padding: 1rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  min-width: 0;
  overflow: hidden;
}

.commodity-icon {
  width: 40px;
  height: 40px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.25rem;
}

.commodity-icon.gold { background: linear-gradient(135deg, #fbbf24, #f59e0b); }
.commodity-icon.oil { background: linear-gradient(135deg, #374151, #1f2937); }

/* Page Title */
.page-title {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 1.5rem;
  font-size: 1.5rem;
  font-weight: 600;
}

.page-title .dropdown-arrow {
  font-size: 0.8rem;
  opacity: 0.6;
}

/* Responsive - Tablet */
@media (max-width: 1200px) {
  .countries-layout {
    grid-template-columns: 1fr 1fr;
  }
  
  .crypto-grid {
    grid-template-columns: 1fr 1fr;
  }
  
  .commodities-grid {
    grid-template-columns: 1fr 1fr;
  }
  
  .companies-grid {
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  }
}

/* Responsive - Mobile */
@media (max-width: 768px) {
  .sidebar {
    width: var(--sidebar-width-mobile);
    padding: 0.5rem;
    padding-left: max(0.5rem, env(safe-area-inset-left));
    transform: translateX(0);
    transition: transform 0.3s ease;
  }
  
  .sidebar-nav a {
    padding: 0.75rem;
    justify-content: center;
  }
  
  .sidebar-nav a span:not(.icon) {
    display: none;
  }
  
  .main-content {
    margin-left: var(--sidebar-width-mobile);
    padding: 1rem;
  }
  
  .header {
    flex-wrap: wrap;
    gap: 0.75rem;
    padding: 0.5rem 0;
  }
  
  .logo-icon {
    width: 36px;
    height: 36px;
    font-size: 1rem;
  }
  
  .logo-text {
    font-size: 1rem;
  }
  
  .search-bar {
    order: 3;
    width: 100%;
    max-width: 100%;
    margin: 0;
    flex: 1 1 100%;
  }
  
  .header-actions .user-name {
    display: none;
  }
  
  .header-actions .btn-primary {
    display: none;
  }
  
  .header-actions .btn-icon {
    width: var(--touch-min);
    height: var(--touch-min);
    min-width: var(--touch-min);
    min-height: var(--touch-min);
  }
  
  .page-title {
    font-size: 1.25rem;
    margin-bottom: 1rem;
  }
  
.card {
  padding: 1rem;
  margin-bottom: 1rem;
  overflow-x: hidden;
  max-width: 100%;
}
  
  .card-header {
    flex-wrap: wrap;
    gap: 0.75rem;
    margin-bottom: 0.75rem;
  }
  
  .card-title {
    font-size: 1rem;
  }
  
  .chart-period-select {
    width: 100%;
    justify-content: flex-end;
  }
  
  .period-select {
    padding: 0.5rem 2rem 0.5rem 0.75rem;
    min-height: var(--touch-min);
    font-size: 0.85rem;
  }
  
  .countries-layout,
  .crypto-grid,
  .commodities-grid {
    grid-template-columns: minmax(0, 1fr);
    gap: 1rem;
  }
  
  .companies-grid {
    grid-template-columns: 1fr;
    gap: 0.75rem;
  }
  
  .company-card {
    padding: 0.875rem;
    gap: 0.75rem;
  }
  
  .company-icon {
    width: 40px;
    height: 40px;
    font-size: 1rem;
  }
  
  .company-desc {
    font-size: 0.8rem;
    -webkit-line-clamp: 2;
    display: -webkit-box;
    -webkit-box-orient: vertical;
    overflow: hidden;
  }
  
  .crypto-card {
    padding: 0.875rem;
  }
  
  .crypto-card .chart-container {
    height: 60px;
  }
  
  .commodity-item {
    padding: 0.875rem;
    flex-wrap: wrap;
  }
  
  .commodity-item .chart-container {
    width: 100%;
    height: 50px;
  }
  
  .economy-donut {
    width: 100px;
    height: 100px;
  }
  
  .chart-container {
    height: 100px;
  }
}

/* Responsive - Small mobile */
@media (max-width: 480px) {
  .main-content {
    padding: 0.75rem;
  }
  
  .card {
    padding: 0.875rem;
  }
  
  .sidebar {
    width: 56px;
  }
  
  .main-content {
    margin-left: 56px;
  }
  
  .sidebar-nav a {
    padding: 0.5rem;
  }
  
  .logo-text {
    font-size: 0.9rem;
  }
  
  .logo-icon {
    width: 32px;
    height: 32px;
    font-size: 0.9rem;
  }
  
  .page-title {
    font-size: 1.1rem;
  }
  
  .btn-primary {
    padding: 0.5rem 0.75rem;
    font-size: 0.85rem;
  }
  
  .country-item {
    padding: 0.625rem 0;
  }
  
  .country-flag {
    width: 28px;
    height: 21px;
  }
}
