/* KaiMail v2.0 - KaiOS 3.1 Optimized Styles */

/* Reset and Base Styles */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: 'Open Sans', Arial, sans-serif;
  font-size: 14px;
  line-height: 1.4;
  color: #333;
  background-color: #f5f5f5;
  overflow: hidden;
}

/* App Container */
.app-container {
  display: flex;
  flex-direction: column;
  height: 100vh;
  width: 100vw;
}

/* Header */
.header {
  background: linear-gradient(135deg, #0078d4 0%, #005a9e 100%);
  color: white;
  padding: 8px 12px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  box-shadow: 0 2px 4px rgba(0,0,0,0.1);
  z-index: 100;
}

.app-title {
  font-size: 16px;
  font-weight: 600;
  margin: 0;
}

.connection-status {
  display: flex;
  align-items: center;
  font-size: 11px;
}

.status-indicator {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background-color: #ff4444;
  margin-right: 4px;
  animation: pulse 2s infinite;
}

.status-indicator.online {
  background-color: #00c851;
}

.status-text {
  font-weight: 500;
}

/* Main Content */
.main-content {
  flex: 1;
  position: relative;
  overflow: hidden;
}

/* Screen Management */
.screen {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  visibility: hidden;
  transition: all 0.3s ease;
  background-color: #f5f5f5;
}

.screen.active {
  opacity: 1;
  visibility: visible;
}

/* Login Screen */
.login-container {
  padding: 20px;
  height: 100%;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  text-align: center;
}

.app-logo {
  margin-bottom: 30px;
}

.logo-icon {
  font-size: 48px;
  margin-bottom: 10px;
}

.app-logo h2 {
  color: #0078d4;
  font-size: 20px;
  margin-bottom: 8px;
  font-weight: 600;
}

.app-logo p {
  color: #666;
  font-size: 12px;
  margin-bottom: 0;
}

.login-options {
  width: 100%;
  max-width: 280px;
  margin-bottom: 20px;
}

.login-option {
  display: flex;
  align-items: center;
  padding: 12px 16px;
  margin-bottom: 8px;
  background-color: white;
  border-radius: 8px;
  border: 2px solid #e0e0e0;
  cursor: pointer;
  transition: all 0.2s ease;
  text-align: left;
  width: 100%;
  font-family: inherit;
  font-size: inherit;
}

.login-option.focused {
  border-color: #0078d4;
  background-color: #f0f8ff;
  transform: translateY(-1px);
  box-shadow: 0 4px 8px rgba(0,120,212,0.2);
}

.provider-icon {
  font-size: 24px;
  margin-right: 12px;
  width: 32px;
  text-align: center;
}

.provider-info {
  flex: 1;
}

.provider-name {
  display: block;
  font-weight: 600;
  color: #333;
  font-size: 14px;
  margin-bottom: 2px;
}

.provider-desc {
  display: block;
  color: #666;
  font-size: 11px;
}

.login-help {
  text-align: center;
  color: #666;
  font-size: 11px;
}

.login-help p {
  margin-bottom: 4px;
}

.security-note {
  color: #0078d4;
  font-weight: 500;
}

/* Loading Screen */
.loading-container {
  padding: 20px;
  height: 100%;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  text-align: center;
}

.spinner {
  width: 40px;
  height: 40px;
  border: 3px solid #e0e0e0;
  border-top: 3px solid #0078d4;
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin-bottom: 20px;
}

.loading-container h3 {
  color: #0078d4;
  font-size: 18px;
  margin-bottom: 8px;
  font-weight: 600;
}

.loading-container p {
  color: #666;
  font-size: 12px;
  margin-bottom: 20px;
}

.loading-progress-container {
  margin: 20px 0;
  width: 100%;
  max-width: 280px;
  margin-left: auto;
  margin-right: auto;
}

.loading-progress-bar {
  width: 100%;
  height: 6px;
  background: #e0e0e0;
  border-radius: 3px;
  overflow: hidden;
  margin-bottom: 8px;
}

.loading-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, #0078d4, #106ebe);
  border-radius: 3px;
  width: 0%;
  transition: width 0.3s ease;
}

.loading-step {
  font-size: 12px;
  color: #666;
  margin-bottom: 10px;
}

.loading-steps {
  width: 100%;
  max-width: 250px;
}

.step {
  padding: 8px 12px;
  margin-bottom: 6px;
  background-color: white;
  border-radius: 6px;
  border-left: 4px solid #e0e0e0;
  font-size: 11px;
  text-align: left;
  transition: all 0.3s ease;
}

.step.active {
  border-left-color: #0078d4;
  background-color: #f0f8ff;
  color: #0078d4;
  font-weight: 500;
}

.step.completed {
  border-left-color: #00c851;
  background-color: #f0fff0;
  color: #00c851;
}

/* Dashboard Screen */
.dashboard-container {
  padding: 20px;
  height: 100%;
  overflow-y: auto;
}

.user-info {
  display: flex;
  align-items: center;
  background-color: white;
  padding: 16px;
  border-radius: 12px;
  margin-bottom: 20px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.user-avatar {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: linear-gradient(135deg, #0078d4, #005a9e);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  color: white;
  margin-right: 12px;
}

.user-details {
  flex: 1;
}

.user-details h3 {
  font-size: 16px;
  color: #333;
  margin-bottom: 2px;
  font-weight: 600;
}

.user-details p {
  font-size: 12px;
  color: #666;
  margin: 0;
}

.auth-status {
  text-align: right;
}

.auth-badge {
  background-color: #00c851;
  color: white;
  padding: 4px 8px;
  border-radius: 12px;
  font-size: 10px;
  font-weight: 500;
}

.quick-actions {
  margin-bottom: 20px;
}

.action-item {
  display: flex;
  align-items: center;
  padding: 14px 16px;
  margin-bottom: 8px;
  background-color: white;
  border-radius: 8px;
  border: 2px solid #e0e0e0;
  cursor: pointer;
  transition: all 0.2s ease;
  width: 100%;
  text-align: left;
  font-family: inherit;
  font-size: inherit;
}

.action-item.focused {
  border-color: #0078d4;
  background-color: #f0f8ff;
  transform: translateY(-1px);
  box-shadow: 0 4px 8px rgba(0,120,212,0.2);
}

.action-icon {
  font-size: 24px;
  margin-right: 12px;
  width: 32px;
  text-align: center;
}

.action-info {
  flex: 1;
}

.action-name {
  display: block;
  font-weight: 600;
  color: #333;
  font-size: 14px;
  margin-bottom: 2px;
}

.action-desc {
  display: block;
  color: #666;
  font-size: 11px;
}

.app-info {
  background-color: white;
  padding: 12px 16px;
  border-radius: 8px;
  border-left: 4px solid #0078d4;
  text-align: center;
}

.app-info p {
  font-size: 11px;
  color: #666;
  margin-bottom: 4px;
}

.app-info p:last-child {
  margin-bottom: 0;
}

.version-info {
  color: #0078d4;
  font-weight: 500;
}

/* Navigation Focus */
.nav-selectable {
  outline: none;
}

.nav-selectable:focus {
  outline: none;
}

/* KaiOS Navigation Focus States */
.nav-focused {
  background-color: #0078d4 !important;
  color: white !important;
  border: 2px solid #005a9e !important;
  box-shadow: 0 0 0 2px rgba(0, 120, 212, 0.3) !important;
  transform: scale(1.02);
  transition: all 0.2s ease;
}

.login-option.nav-focused {
  background-color: #0078d4;
  color: white;
  border-color: #005a9e;
}

.action-item.nav-focused {
  background-color: #0078d4;
  color: white;
  border-color: #005a9e;
}

.action-item.nav-focused .action-icon,
.action-item.nav-focused .action-name,
.action-item.nav-focused .action-desc {
  color: white;
}

/* Toast Notifications */
.toast {
  position: fixed;
  bottom: 80px;
  left: 50%;
  transform: translateX(-50%);
  background-color: #333;
  color: white;
  padding: 8px 16px;
  border-radius: 20px;
  font-size: 12px;
  opacity: 0;
  visibility: hidden;
  transition: all 0.3s ease;
  z-index: 1000;
  max-width: 280px;
  text-align: center;
}

.toast.show {
  opacity: 1;
  visibility: visible;
}

.toast.success {
  background-color: #00c851;
}

.toast.error {
  background-color: #ff4444;
}

.toast.warning {
  background-color: #ffbb33;
  color: #333;
}

/* Animations */
@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

@keyframes pulse {
  0% { opacity: 1; }
  50% { opacity: 0.5; }
  100% { opacity: 1; }
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Responsive Design for KaiOS */
@media screen and (max-width: 320px) {
  .login-container,
  .loading-container,
  .dashboard-container {
    padding: 16px;
  }
  
  .app-title {
    font-size: 14px;
  }
  
  .logo-icon {
    font-size: 40px;
  }
  
  .app-logo h2 {
    font-size: 18px;
  }
}

/* High Contrast Mode Support */
@media (prefers-contrast: high) {
  .login-option,
  .action-item {
    border-width: 3px;
  }
  
  .login-option.focused,
  .action-item.focused {
    border-width: 3px;
    box-shadow: 0 0 0 2px #0078d4;
  }
}

/* Inbox Screen Styles */
.folder-navigation {
  display: flex;
  background-color: #fff;
  border-bottom: 1px solid #e0e0e0;
  padding: 8px;
  overflow-x: auto;
}

.folder-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 8px 12px;
  margin-right: 8px;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.2s ease;
  min-width: 60px;
  text-align: center;
}

.folder-item:hover,
.folder-item.nav-focus {
  background-color: #f0f8ff;
  transform: translateY(-1px);
}

.folder-item.active {
  background-color: #0078d4;
  color: white;
}

.folder-icon {
  font-size: 16px;
  margin-bottom: 4px;
}

.folder-name {
  font-size: 10px;
  font-weight: 500;
}

.search-container {
  display: flex;
  padding: 12px;
  background-color: #fff;
  border-bottom: 1px solid #e0e0e0;
  gap: 8px;
}

.search-input {
  flex: 1;
  padding: 8px 12px;
  border: 1px solid #ccc;
  border-radius: 4px;
  font-size: 12px;
}

.search-input:focus {
  outline: none;
  border-color: #0078d4;
  box-shadow: 0 0 0 2px rgba(0, 120, 212, 0.2);
}

.search-button {
  padding: 8px 16px;
  background-color: #0078d4;
  color: white;
  border: none;
  border-radius: 4px;
  font-size: 12px;
  cursor: pointer;
  transition: background-color 0.2s ease;
}

.search-button:hover,
.search-button.nav-focus {
  background-color: #005a9e;
}

.email-list {
  flex: 1;
  overflow-y: auto;
  background-color: #fff;
}

.email-item {
  display: flex;
  padding: 12px;
  border-bottom: 1px solid #f0f0f0;
  cursor: pointer;
  transition: background-color 0.2s ease;
}

.email-item:hover,
.email-item.nav-focus {
  background-color: #f8f9fa;
}

.email-item.unread {
  font-weight: 600;
  background-color: #f0f8ff;
}

.email-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background-color: #0078d4;
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 600;
  margin-right: 12px;
  flex-shrink: 0;
}

.email-content {
  flex: 1;
  min-width: 0;
}

.email-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 4px;
}

.email-from {
  font-size: 12px;
  font-weight: 600;
  color: #333;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 150px;
}

.email-date {
  font-size: 10px;
  color: #666;
  white-space: nowrap;
}

.email-subject {
  font-size: 11px;
  color: #333;
  margin-bottom: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.email-preview {
  font-size: 10px;
  color: #666;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 200px;
  color: #666;
  font-size: 12px;
}

/* Email View Screen Styles */
.email-view {
  height: 100%;
  display: flex;
  flex-direction: column;
  background-color: #fff;
}

.email-view .email-header {
  padding: 16px;
  border-bottom: 1px solid #e0e0e0;
  background-color: #f8f9fa;
}

.email-view .email-subject {
  font-size: 14px;
  font-weight: 600;
  color: #333;
  margin-bottom: 8px;
  white-space: normal;
  overflow: visible;
  text-overflow: unset;
}

.email-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.email-view .email-from {
  font-size: 12px;
  color: #0078d4;
  max-width: none;
  white-space: normal;
  overflow: visible;
  text-overflow: unset;
}

.email-view .email-date {
  font-size: 11px;
  color: #666;
}

.email-body {
  flex: 1;
  padding: 16px;
  overflow-y: auto;
  font-size: 12px;
  line-height: 1.5;
  color: #333;
}

.email-attachments {
  padding: 12px 16px;
  border-top: 1px solid #e0e0e0;
  background-color: #f8f9fa;
}

.attachment-item {
  display: flex;
  align-items: center;
  padding: 8px;
  margin-bottom: 4px;
  background-color: #fff;
  border: 1px solid #e0e0e0;
  border-radius: 4px;
  cursor: pointer;
  transition: background-color 0.2s ease;
}

.attachment-item:hover {
  background-color: #f0f8ff;
}

.attachment-icon {
  margin-right: 8px;
  font-size: 14px;
}

.attachment-info {
  flex: 1;
}

.attachment-name {
  font-size: 11px;
  font-weight: 600;
  color: #333;
}

.attachment-size {
  font-size: 10px;
  color: #666;
}

.email-actions {
  display: flex;
  padding: 12px 16px;
  border-top: 1px solid #e0e0e0;
  background-color: #f8f9fa;
  gap: 8px;
}

.action-button {
  display: flex;
  align-items: center;
  padding: 8px 12px;
  background-color: #0078d4;
  color: white;
  border: none;
  border-radius: 4px;
  font-size: 11px;
  cursor: pointer;
  transition: background-color 0.2s ease;
}

.action-button:hover,
.action-button.nav-focus {
  background-color: #005a9e;
}

.action-icon {
  margin-right: 6px;
  font-size: 12px;
}

/* Reduced Motion Support */
@media (prefers-reduced-motion: reduce) {
  .spinner {
    animation: none;
  }
  
  .status-indicator {
    animation: none;
  }
  
  * {
    transition: none !important;
  }
}