/**
 * Renovation Cost Estimator - Styles
 * Mobile-first responsive design
 */

/* ============================================
   CSS Variables
   ============================================ */
:root {
  --primary-color: #2563eb;
  --primary-hover: #1d4ed8;
  --secondary-color: #64748b;
  --success-color: #22c55e;
  --danger-color: #ef4444;
  --warning-color: #f59e0b;

  --bg-color: #f1f5f9;
  --panel-bg: #ffffff;
  --border-color: #e2e8f0;
  --text-color: #1e293b;
  --text-muted: #64748b;

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.1);
  --shadow-lg: 0 10px 15px rgba(0, 0, 0, 0.1);

  --radius-sm: 4px;
  --radius-md: 8px;
  --radius-lg: 12px;

  --header-height: 60px;
  --footer-height: 80px;
}

/* ============================================
   Reset & Base
   ============================================ */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html, body {
  height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
  font-size: 16px;
  line-height: 1.5;
  color: var(--text-color);
  background-color: var(--bg-color);
}

/* ============================================
   App Layout
   ============================================ */
.app-container {
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
}

/* Header */
.header {
  height: var(--header-height);
  background: var(--panel-bg);
  border-bottom: 1px solid var(--border-color);
  box-shadow: var(--shadow-sm);
  z-index: 100;
}

.header-content {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 100%;
  padding: 0 16px;
  max-width: 1920px;
  margin: 0 auto;
}

.logo {
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--primary-color);
}

.header-actions {
  display: flex;
  gap: 8px;
}

/* Main Content - Mobile First */
.main-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* Panels */
.panel {
  background: var(--panel-bg);
  border: 1px solid var(--border-color);
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border-color);
}

.panel-header h2 {
  font-size: 1rem;
  font-weight: 600;
}

/* Left Panel - Rooms */
.panel-left {
  order: 2;
  border-radius: 0;
  max-height: 200px;
  overflow-y: auto;
}

/* Center Panel - 3D Viewer */
.panel-center {
  order: 1;
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 250px;
}

.viewer-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 16px;
  border-bottom: 1px solid var(--border-color);
}

.viewer-header h2 {
  font-size: 0.9rem;
  font-weight: 600;
}

.viewer-3d {
  flex: 1;
  position: relative;
  background: linear-gradient(135deg, #e0e7ff 0%, #f0f9ff 100%);
  overflow: hidden;
}

.viewer-3d canvas {
  display: block;
  width: 100% !important;
  height: 100% !important;
}

.viewer-placeholder {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  text-align: center;
  color: var(--text-muted);
}

.viewer-info {
  padding: 8px 16px;
  font-size: 0.85rem;
  color: var(--text-muted);
  border-top: 1px solid var(--border-color);
}

/* Right Panel - Options & Chat */
.panel-right {
  order: 3;
  max-height: 300px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

/* Footer Panel */
.footer-panel {
  height: var(--footer-height);
  background: var(--panel-bg);
  border-top: 1px solid var(--border-color);
  box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.05);
  z-index: 100;
}

.summary-container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 100%;
  padding: 0 16px;
  gap: 16px;
  flex-wrap: wrap;
}

.summary-stats {
  display: flex;
  gap: 16px;
}

.stat {
  display: flex;
  flex-direction: column;
}

.stat-label {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.stat-value {
  font-size: 1rem;
  font-weight: 600;
}

.total-cost {
  text-align: center;
}

.total-label {
  font-size: 0.85rem;
  color: var(--text-muted);
}

.total-value {
  display: block;
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--primary-color);
}

.summary-actions {
  display: flex;
  gap: 8px;
}

/* ============================================
   Buttons
   ============================================ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 10px 16px;
  font-size: 0.9rem;
  font-weight: 500;
  border: none;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all 0.2s ease;
  text-decoration: none;
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

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

.btn-primary:hover:not(:disabled) {
  background: var(--primary-hover);
}

.btn-secondary {
  background: var(--bg-color);
  color: var(--text-color);
  border: 1px solid var(--border-color);
}

.btn-secondary:hover:not(:disabled) {
  background: var(--border-color);
}

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

.btn-small {
  padding: 6px 12px;
  font-size: 0.8rem;
}

/* ============================================
   Forms
   ============================================ */
.form-group {
  margin-bottom: 12px;
}

.form-group label {
  display: block;
  margin-bottom: 4px;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-muted);
}

.form-control {
  width: 100%;
  padding: 10px 12px;
  font-size: 1rem;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  background: white;
  transition: border-color 0.2s;
}

.form-control:focus {
  outline: none;
  border-color: var(--primary-color);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.form-row {
  display: flex;
  gap: 12px;
}

.form-row .form-group {
  flex: 1;
}

.form-actions {
  display: flex;
  gap: 8px;
  margin-top: 16px;
}

/* ============================================
   Rooms List
   ============================================ */
.rooms-list {
  padding: 8px;
}

.room-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px;
  margin-bottom: 8px;
  background: var(--bg-color);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all 0.2s;
}

.room-item:hover {
  background: var(--border-color);
}

.room-item.active {
  background: var(--primary-color);
  color: white;
}

.room-item.active .room-area {
  color: rgba(255, 255, 255, 0.8);
}

.room-info {
  flex: 1;
}

.room-name {
  font-weight: 500;
}

.room-area {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.room-actions {
  display: flex;
  gap: 4px;
}

.room-actions button {
  padding: 4px 8px;
  font-size: 0.75rem;
  background: transparent;
  border: none;
  cursor: pointer;
  opacity: 0.7;
}

.room-actions button:hover {
  opacity: 1;
}

/* Room Editor */
.room-editor {
  padding: 16px;
  border-top: 1px solid var(--border-color);
  background: var(--bg-color);
}

.room-editor h3 {
  margin-bottom: 12px;
  font-size: 1rem;
}

/* ============================================
   Tabs
   ============================================ */
.tabs {
  display: flex;
  border-bottom: 1px solid var(--border-color);
}

.tab-btn {
  flex: 1;
  padding: 12px;
  font-size: 0.9rem;
  font-weight: 500;
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  cursor: pointer;
  transition: all 0.2s;
}

.tab-btn:hover {
  background: var(--bg-color);
}

.tab-btn.active {
  border-bottom-color: var(--primary-color);
  color: var(--primary-color);
}

.tab-content {
  display: none;
  flex: 1;
  overflow-y: auto;
}

.tab-content.active {
  display: block;
}

/* ============================================
   Options Panel
   ============================================ */
.no-selection {
  padding: 32px 16px;
  text-align: center;
  color: var(--text-muted);
}

.options-panel {
  padding: 16px;
}

.options-section {
  margin-bottom: 20px;
}

.options-section h3 {
  font-size: 0.9rem;
  font-weight: 600;
  margin-bottom: 8px;
  color: var(--text-muted);
}

.options-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.option-item {
  display: flex;
  align-items: center;
  padding: 10px 12px;
  background: var(--bg-color);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all 0.2s;
}

.option-item:hover {
  background: var(--border-color);
}

.option-item.selected {
  background: rgba(37, 99, 235, 0.1);
  border: 1px solid var(--primary-color);
}

.option-item input[type="checkbox"] {
  margin-right: 10px;
  width: 18px;
  height: 18px;
  cursor: pointer;
}

.option-info {
  flex: 1;
}

.option-name {
  font-weight: 500;
  font-size: 0.9rem;
}

.option-price {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.option-cost {
  font-weight: 600;
  color: var(--primary-color);
}

/* Color Pickers */
.color-pickers {
  display: flex;
  gap: 16px;
}

.color-picker-group {
  display: flex;
  align-items: center;
  gap: 8px;
}

.color-picker-group label {
  font-size: 0.85rem;
}

.color-picker-group input[type="color"] {
  width: 40px;
  height: 30px;
  padding: 0;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  cursor: pointer;
}

/* ============================================
   Chat
   ============================================ */
.chat-container {
  display: flex;
  flex-direction: column;
  height: 100%;
}

.chat-messages {
  flex: 1;
  padding: 16px;
  overflow-y: auto;
}

.chat-message {
  margin-bottom: 12px;
  padding: 10px 14px;
  border-radius: var(--radius-lg);
  max-width: 85%;
}

.chat-message.user {
  background: var(--primary-color);
  color: white;
  margin-left: auto;
}

.chat-message.assistant {
  background: var(--bg-color);
}

.chat-message p {
  font-size: 0.9rem;
  line-height: 1.4;
}

.chat-input-container {
  display: flex;
  gap: 8px;
  padding: 12px;
  border-top: 1px solid var(--border-color);
}

.chat-input {
  flex: 1;
  padding: 10px 14px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  font-size: 0.9rem;
}

.chat-input:focus {
  outline: none;
  border-color: var(--primary-color);
}

/* ============================================
   Modal
   ============================================ */
.modal {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 16px;
}

.modal.hidden {
  display: none;
}

.modal-content {
  background: var(--panel-bg);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 500px;
  box-shadow: var(--shadow-lg);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-color);
}

.modal-header h3 {
  font-size: 1.1rem;
}

.modal-close {
  background: none;
  border: none;
  font-size: 1.5rem;
  cursor: pointer;
  color: var(--text-muted);
  line-height: 1;
}

.modal-body {
  padding: 20px;
}

.share-link-container {
  display: flex;
  gap: 8px;
  margin: 16px 0;
}

.share-link-container input {
  flex: 1;
}

.share-note {
  font-size: 0.85rem;
  color: var(--text-muted);
}

/* ============================================
   Utility Classes
   ============================================ */
.hidden {
  display: none !important;
}

.text-center {
  text-align: center;
}

.text-muted {
  color: var(--text-muted);
}

/* ============================================
   Tablet Styles (min-width: 768px)
   ============================================ */
@media (min-width: 768px) {
  .main-content {
    flex-direction: row;
  }

  .panel-left {
    order: 1;
    width: 280px;
    max-height: none;
    border-right: 1px solid var(--border-color);
    border-bottom: none;
  }

  .panel-center {
    order: 2;
    flex: 1;
    min-height: auto;
  }

  .panel-right {
    order: 3;
    width: 320px;
    max-height: none;
    border-left: 1px solid var(--border-color);
  }

  .footer-panel {
    height: 70px;
  }

  .summary-container {
    flex-wrap: nowrap;
  }
}

/* ============================================
   Desktop Styles (min-width: 1024px)
   ============================================ */
@media (min-width: 1024px) {
  .panel-left {
    width: 300px;
  }

  .panel-right {
    width: 380px;
  }

  .total-value {
    font-size: 1.75rem;
  }
}

/* ============================================
   Large Desktop (min-width: 1440px)
   ============================================ */
@media (min-width: 1440px) {
  .panel-left {
    width: 340px;
  }

  .panel-right {
    width: 420px;
  }
}

/* ============================================
   Admin Panel Specific Styles
   ============================================ */
.admin-container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 20px;
}

.admin-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
}

.admin-header h1 {
  font-size: 1.5rem;
}

.admin-card {
  background: var(--panel-bg);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  margin-bottom: 24px;
}

.admin-card-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-color);
}

.admin-card-header h2 {
  font-size: 1.1rem;
}

.admin-card-body {
  padding: 20px;
}

.login-form {
  max-width: 400px;
  margin: 100px auto;
}

.pricing-table {
  width: 100%;
  border-collapse: collapse;
}

.pricing-table th,
.pricing-table td {
  padding: 12px;
  text-align: left;
  border-bottom: 1px solid var(--border-color);
}

.pricing-table th {
  font-weight: 600;
  color: var(--text-muted);
  font-size: 0.85rem;
}

.pricing-table input {
  width: 100px;
  padding: 6px 10px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
}

.pricing-table .category-row {
  background: var(--bg-color);
  font-weight: 600;
}

.projects-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.project-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px;
  background: var(--bg-color);
  border-radius: var(--radius-md);
}

.project-card-info h3 {
  font-size: 1rem;
  margin-bottom: 4px;
}

.project-card-info p {
  font-size: 0.85rem;
  color: var(--text-muted);
}

/* ============================================
   Project View Page Styles
   ============================================ */
.project-view-container {
  max-width: 1000px;
  margin: 0 auto;
  padding: 20px;
}

.project-summary {
  background: var(--panel-bg);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  padding: 24px;
  margin-bottom: 24px;
}

.project-summary h1 {
  font-size: 1.5rem;
  margin-bottom: 8px;
}

.project-meta {
  color: var(--text-muted);
  font-size: 0.9rem;
  margin-bottom: 20px;
}

.project-total {
  font-size: 2rem;
  font-weight: 700;
  color: var(--primary-color);
  margin-bottom: 20px;
}

.room-details {
  background: var(--panel-bg);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  margin-bottom: 24px;
}

.room-detail-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-color);
  background: var(--bg-color);
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
}

.room-detail-body {
  padding: 20px;
}

.detail-row {
  display: flex;
  justify-content: space-between;
  padding: 8px 0;
  border-bottom: 1px solid var(--border-color);
}

.detail-row:last-child {
  border-bottom: none;
}

/* ============================================
   Touch Device Optimizations
   ============================================ */
@media (hover: none) and (pointer: coarse) {
  .btn {
    min-height: 44px;
    min-width: 44px;
  }

  .option-item {
    min-height: 48px;
  }

  .room-item {
    min-height: 56px;
  }
}
