/* ==========================================================================
   1. GLOBAL STYLES & BASE
   ========================================================================== */

body {
  background-color: #121214;
  color: #e1e1e6;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

h1, h2, h3 {
  color: #f7f7f8;
  font-weight: 600;
  margin-top: 0;
}

a, a:visited {
  color: #f59e0b;
  text-decoration: none;
  font-size: 14px;
}


/* ==========================================================================
   2. BUTTONS & INPUTS
   ========================================================================== */

input[type="email"],
input[type="password"],
input[type="text"],
input[type="number"],
select,
textarea {
  width: 100%;
  padding: 12px 16px;
  margin: 8px 0 20px 0;
  background-color: #121214;
  border: 1px solid #29292e;
  border-radius: 8px;
  color: #f7f7f8;
  font-size: 14px;
  box-sizing: border-box;
  transition: border-color 0.2s;
}

input:focus {
  outline: none;
  border-color: #f59e0b;
}

label {
  font-size: 14px;
  color: #a8a8b3;
  font-weight: 500;
}

button, input[type="submit"], .btn-primary {
  background-color: #f59e0b;
  color: #121214;
  padding: 12px 20px;
  border: none;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  width: 100%;
  transition: background-color 0.2s;
  text-decoration: none;
  display: inline-block;
  text-align: center;
  box-sizing: border-box;
}

button:hover, input[type="submit"]:hover, .btn-primary:hover {
  background-color: #d97706;
}

.btn-primary {
  background-color: #f59e0b !important;
  color: #0f172a !important;
  padding: 10px 18px;
  border-radius: 8px;
  font-weight: 700 !important;
  text-decoration: none;
  font-size: 14px;
  box-shadow: 0 2px 4px rgba(245, 158, 11, 0.2);
  transition: background-color 0.2s;
  display: inline-block;
}

.btn-secondary {
  color: #f59e0b;
  text-decoration: none;
  font-size: 16px;
  font-weight: 500;
  line-height: 1;
}

.btn-secondary:hover {
  background-color: transparent !important;
  color: #cc8305 !important;
  text-decoration: none !important;
}
.btn-danger {
  background-color: transparent !important;
  color: #ef4444 !important;
  padding: 0 !important;
  border: none !important;
  border-radius: 0 !important;
  font-weight: 500 !important;
  font-size: 16px !important;
  cursor: pointer;
  box-shadow: none !important;
  display: inline !important;
  text-decoration: none !important;
  line-height: 1 !important;
  vertical-align: baseline !important;
}

.btn-danger:hover {
  background-color: transparent !important;
  color: #dc2626 !important;
  text-decoration: none !important;
}

.btn-back {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background-color: transparent;
  color: #94a3b8;
  border: 1px solid #334155;
  padding: 6px 14px;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 500;
  transition: all 0.2s ease;
  text-decoration: none;
}

.btn-back:hover {
  background-color: rgba(255, 255, 255, 0.03);
  color: #f8fafc;
  border-color: #475569;
  text-decoration: none;
}


/* ==========================================================================
   3. AUTHENTICATION & FORMS LAYOUT
   ========================================================================== */

.auth-container, .form-card {
  max-width: 420px;
  margin: 60px auto;
  padding: 32px;
  background-color: #202024;
  border: 1px solid #29292e;
  border-radius: 12px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
}

.auth-links {
  margin-top: 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.auth-links-center {
  margin-top: 20px;
  text-align: center;
}


/* ==========================================================================
   4. NOTIFICATIONS & FLASH MESSAGES
   ========================================================================== */

.flash-alert, .error-explanation {
  color: #f87171;
  background-color: rgba(248, 113, 113, 0.1);
  border: 1px solid #f87171;
  padding: 12px;
  border-radius: 8px;
  margin-bottom: 20px;
  font-size: 14px;
}

.flash-notice {
  color: #34d399;
  background-color: rgba(52, 211, 153, 0.1);
  border: 1px solid #34d399;
  padding: 12px;
  border-radius: 8px;
  margin-bottom: 20px;
  font-size: 14px;
}

.error-explanation p {
  margin: 0 0 8px 0;
  font-weight: 600;
}

.error-explanation ul {
  margin: 0;
  padding-left: 20px;
}


/* ==========================================================================
   5. NAVBAR COMPONENTS
   ========================================================================== */

.app-navbar {
  background-color: #0f172a;
  border-bottom: 1px solid #1e293b;
  padding: 16px 0;
  margin-bottom: 5px;
}

.navbar-container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.navbar-links {
  display: flex;
  align-items: center;
  gap: 24px;
}

.navbar-brand {
  color: #f8fafc;
  font-weight: 600;
  text-decoration: none;
  font-size: 16px;
}

.navbar-brand:hover {
  color: #f8fafc;
}

.navbar-link {
  color: #94a3b8;
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
  transition: color 0.2s;
}

.navbar-link:hover {
  color: #f8fafc;
}

.btn-logout {
  background-color: transparent;
  color: #94a3b8;
  border: 1px solid #334155;
  padding: 6px 14px;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-logout:hover {
  background-color: #1e293b;
  color: #f8fafc;
  border-color: #475569;
}


/* ==========================================================================
   6. DASHBOARD & HEADERS
   ========================================================================== */

.dashboard-container {
  max-width: 1200px;
  width: 100%;
  margin: 0 auto;
  padding: 30px 20px;
}

.dashboard-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 30px;
  width: 100%;
}

.dashboard-header .btn-primary {
  width: auto; 
}

.dashboard-title {
  color: #f8fafc;
  font-size: 28px;
  font-weight: 600;
  margin: 0;
}

.content-header {
  max-width: 800px;
  margin: 0 auto 20px auto;
}

.content-header h1 {
  font-size: 24px;
  margin: 0;
}

.back-link-container {
  margin-bottom: 30px;
}


/* ==========================================================================
   7. DEVICES INDEX & CARDS
   ========================================================================== */

.devices-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 20px;
}

.device-card {
  background-color: #1e293b;
  border: 1px solid #334155;
  border-radius: 12px;
  padding: 24px;
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.2);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  transition: border-color 0.2s ease, transform 0.2s ease;
}

.device-card:hover {
  border-color: #475569;
  transform: translateY(-2px);
}

.device-card-content {
  text-decoration: none;
  color: #e2e8f0 !important;
  display: block;
  flex-grow: 1;
}

.device-card-content p, .device-card p {
  color: #94a3b8;
  margin: 10px 0;
  font-size: 15px;
}

.device-card strong, .device-card b {
  color: #e2e8f0;
}

.device-card-name {
  margin: 8px 0 16px 0;
  line-height: 1.4;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 8px;
}

.device-label {
  color: #94a3b8;
  font-size: 14px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.device-value {
  color: #f8fafc;
  font-size: 26px;
  font-weight: 600;
  align-items: baseline;
  text-align: center;
  display: block;
}

.device-actions {
  margin-top: 20px;
  padding-top: 15px;
  border-top: 1px solid #334155;
  display: flex;
  align-items: baseline;
  justify-content: space-between; 
  gap: 12px;
}

.device-actions form, 
.device-actions .button-to-form {
  display: inline;
  margin: 0;
  padding: 0;
}


/* ==========================================================================
   8. DEVICE SHOW VIEW
   ========================================================================== */

.device-details-card {
  background-color: #1e293b;
  border: 1px solid #334155;
  border-radius: 12px;
  padding: 32px;
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.2);
  max-width: 800px;
  margin: 0 auto;
}

.device-show-actions {
  margin-top: 30px;
  padding-top: 20px;
  border-top: 1px solid #334155;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.api-key-box {
  margin-top: 20px;
  padding: 16px;
  background-color: #0f172a;
  border: 1px solid #334155;
  border-radius: 8px;
}

.api-key-box code {
  color: #34d399;
  font-family: monospace;
  font-size: 14px;
}


/* ==========================================================================
   9. LAST MEASUREMENTS SUMMARY CARDS
   ========================================================================== */

.last-measurements-container {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 20px;
  margin-bottom: 30px;
}

.last-measurements-card {
  background-color: #1e293b;
  border: 1px solid #334155;
  border-radius: 12px;
  padding: 24px;
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.2);
  text-align: center;
  transition: transform 0.2s ease, border-color 0.2s ease;
}

.last-measurements-card:hover {
  border-color: #475569;
  transform: translateY(-2px);
}

.last-measurements-title {
  color: #94a3b8;
  font-size: 14px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin: 0 0 12px 0;
}

.last-measurements-number {
  font-size: 42px;
  font-weight: 700;
  line-height: 1;
}

.last-measurements-number.temperature {
  color: #f59e0b; 
}

.last-measurements-number.humidity {
  color: #38bdf8; 
}


/* ==========================================================================
   10. MEASUREMENTS TABLES
   ========================================================================== */

.measurement-card {
  background-color: #1e293b;
  border: 1px solid #334155;
  border-radius: 12px;
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.2);
  margin-bottom: 30px;
}

.table-container {
  max-height: 400px;
  overflow-y: auto;
  overflow-x: hidden; 
  border-radius: 12px;
  position: relative; 
}

.measurements-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
}

.measurements-table th {
  position: sticky;
  top: 0;
  background-color: #334155;
  color: #f8fafc;           
  padding: 14px 16px;
  font-weight: 600;
  font-size: 16px;
  z-index: 1;
  border-bottom: 2px solid #475569;
}

.measurements-table td {
  padding: 12px 16px;
  border-bottom: 1px solid #334155;
  color: #e2e8f0;
  font-size: 14px;
}

.measurements-table tr:hover td {
  background-color: #1e293b;
  filter: brightness(1.2);
}

.row-link, .row-link:visited {
  color: inherit;
  text-decoration: none;
  display: block; 
}

.row-link:hover {
  color: #f59e0b;
}


/* ==========================================================================
   11. CHARTS & FILTERS
   ========================================================================== */

.day-filters {
  display: flex;
  gap: 12px;
  margin-bottom: 24px;
  flex-wrap: wrap; 
}

.day-btn, .day-btn:visited {
  background-color: #1e293b;
  color: #94a3b8;
  border: 1px solid #334155;
  padding: 8px 16px;
  border-radius: 8px;
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
  transition: all 0.2s;
}

.day-btn:hover {
  border-color: #475569;
  color: #e2e8f0;
}

.day-btn.active {
  background-color: #f59e0b;
  color: #0f172a;
  border-color: #f59e0b;
  font-weight: 600;
}

.charts-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(450px, 1fr));
  gap: 24px;
}

.chart-card {
  background-color: #1e293b;
  border: 1px solid #334155;
  border-radius: 12px;
  padding: 24px;
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.2);
}

.chart-title {
  color: #e2e8f0;
  margin-top: 0;
  margin-bottom: 20px;
  font-size: 16px;
  font-weight: 600;
  border-bottom: 1px solid #334155;
  padding-bottom: 10px;
}