@import url('https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@400;500;600;700&display=swap');
@import url('https://fonts.googleapis.com/css2?family=Manrope:wght@400;600;700;800&family=Inter:wght@300;400;500;600&display=swap');

:root {
  /* Internal Premium Theme Vars */
  --bg-color: #f4f4f5;
  --sidebar-bg: #ffffff;
  --content-bg: #ffffff;
  --text-main: #18181b;
  --text-muted: #71717a;
  --primary: #4f46e5;
  --primary-hover: #4338ca;
  --border-color: #e4e4e7;
  --input-bg: #ffffff;
  --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
  --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);

  /* ArchitectDB Login Vars */
  --adb-surface: #f8f9ff;
  --adb-lowest: #ffffff;
  --adb-primary: #4648d4;
  --adb-primary-container: #6063ee;
  --adb-tertiary: #6b38d4;
  --adb-on-surface: #0b1c30;
  --adb-on-surface-variant: #464554;
  --adb-surface-low: #eff4ff;
  --adb-on-primary: #ffffff;
}

body {
  font-family: 'Plus Jakarta Sans', sans-serif;
  background-color: var(--bg-color);
  color: var(--text-main);
  margin: 0;
  min-height: 100vh;
}

/* ===================================================================== */
/* 1. INNER APPLICATION UI (When #menu is present)                       */
/* ===================================================================== */

body:has(#menu) {
  display: flex;
}

body:has(#menu) #menu {
  background-color: var(--sidebar-bg);
  border-right: 1px solid var(--border-color);
  width: 260px;
  position: fixed;
  top: 0;
  bottom: 0;
  left: 0;
  padding: 1.5rem;
  box-shadow: 1px 0 10px rgba(0,0,0,0.02);
  overflow-y: auto;
  z-index: 10;
}

body:has(#menu) #menu h1 {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text-main);
  margin: 0 0 2rem 0;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

body:has(#menu) #menu h1 a { color: var(--text-main); text-decoration: none; }
body:has(#menu) #menu a {
  color: var(--text-muted);
  text-decoration: none;
  display: block;
  padding: 0.6rem 1rem;
  border-radius: 0.5rem;
  transition: all 0.2s ease;
  font-size: 0.9rem;
  font-weight: 500;
  margin-bottom: 0.25rem;
}
body:has(#menu) #menu a:hover, body:has(#menu) #menu a.active {
  background-color: #f4f4f5;
  color: var(--text-main);
}

body:has(#menu) #content {
  margin-left: 260px;
  padding: 2.5rem 3rem;
  width: calc(100% - 260px);
  box-sizing: border-box;
  background-color: var(--bg-color);
}

body:has(#menu) h2 { font-size: 1.8rem; font-weight: 700; margin: 0 0 2rem 0; letter-spacing: -0.02em; }
body:has(#menu) h3 { font-size: 1.25rem; font-weight: 600; margin: 2rem 0 1rem 0; }

body:has(#menu) table { border-collapse: separate; border-spacing: 0; width: 100%; background: var(--content-bg); border-radius: 0.75rem; box-shadow: var(--shadow-sm); margin-bottom: 2rem; border: 1px solid var(--border-color); overflow: hidden; }
body:has(#menu) th, body:has(#menu) td { padding: 1rem 1.25rem; border-bottom: 1px solid var(--border-color); text-align: left; vertical-align: middle; }
body:has(#menu) th { background-color: #fafafa; font-weight: 600; color: var(--text-muted); font-size: 0.85rem; text-transform: uppercase; letter-spacing: 0.05em; }
body:has(#menu) tr:last-child th, body:has(#menu) tr:last-child td { border-bottom: none; }
body:has(#menu) tbody tr:hover { background-color: #fafafa; }

body:has(#menu) input[type="text"], body:has(#menu) input[type="password"], body:has(#menu) input[type="number"], body:has(#menu) input[type="search"], body:has(#menu) select, body:has(#menu) textarea {
  width: 100%; padding: 0.6rem 0.875rem; border: 1px solid var(--border-color); border-radius: 0.5rem; background-color: var(--input-bg); font-family: inherit; font-size: 0.95rem; box-sizing: border-box; outline: none;
}
body:has(#menu) input:focus, body:has(#menu) select:focus, body:has(#menu) textarea:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.15); }

body:has(#menu) input[type="submit"], body:has(#menu) button {
  padding: 0.6rem 1.25rem; background-color: var(--primary); color: white; border: none; border-radius: 0.5rem; font-weight: 600; font-size: 0.95rem; cursor: pointer; transition: all 0.2s ease;
}
body:has(#menu) input[type="submit"]:hover, body:has(#menu) button:hover { background-color: var(--primary-hover); transform: translateY(-1px); }
body:has(#menu) input[type="checkbox"] { accent-color: var(--primary); width: 1.1rem; height: 1.1rem; margin-right: 0.5rem; cursor: pointer; }

/* Sidebar Search Configuration */
#search { display: block !important; margin: 1.5rem 0; position: relative; }
#search::before { content: "⌕"; position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--text-muted); font-size: 1.2rem; pointer-events: none; }
#search input[name="q"] { padding: 0.6rem 0.875rem 0.6rem 2.2rem; border-radius: 9999px; background-color: #f4f4f5; border: 1px solid transparent; }
#search input[name="q"]:focus { background-color: #fff; border-color: var(--primary); }
body:has(#menu) #breadcrumb { margin-bottom: 2rem; font-size: 0.9rem; color: var(--text-muted); display: flex; gap: 0.5rem; }
body:has(#menu) #breadcrumb a { color: var(--primary); font-weight: 600; text-decoration: none; }


/* ===================================================================== */
/* 2. ARCHITECT DB LOGIN UI (When #menu is NOT present)                  */
/* ===================================================================== */

body:not(:has(#menu)) {
    background-color: var(--adb-surface);
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: hidden;
    position: relative;
    padding: 1rem;
    box-sizing: border-box;
}

/* Simulated Background Blurs */
body:not(:has(#menu))::before,
body:not(:has(#menu))::after {
    content: "";
    position: absolute;
    width: 40vw;
    height: 60vh;
    border-radius: 50%;
    filter: blur(120px);
    z-index: 0;
}
body:not(:has(#menu))::before {
    top: -10%; left: -5%;
    background-color: rgba(96, 99, 238, 0.05); /* primary-container/5 */
}
body:not(:has(#menu))::after {
    bottom: -10%; right: -5%;
    background-color: rgba(107, 56, 212, 0.05); /* tertiary/5 */
}

/* The Main Box Container */
body:not(:has(#menu)) #content {
    position: relative;
    z-index: 10;
    width: 100%;
    max-width: 1024px;
    min-height: 550px;
    background-color: var(--adb-lowest);
    border-radius: 12px;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
    /* 41.6% space on the left for the pseudo-element 'split' panel */
    padding: 4rem 4rem 4rem calc(41.666% + 4rem);
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

/* Left Panel (Visual/Branding) created with pseudo element of #content */
body:not(:has(#menu)) #content::before {
    content: "ArchitectDB \A\A Redefining Data Management \A\A The Analytical Architect provides a sophisticated environment for database curation, moving beyond utility into a high-performance workspace. \A\A\A\A 🛡️  Secure Protocol \A       TLS 1.3 Encryption Enabled \A\A ⚡️  Optimized Engine \A       v4.2.0 Analytical Core";
    white-space: pre-wrap;
    position: absolute;
    left: 0;
    top: 0;
    width: 41.666%; /* 5/12 columns */
    height: 100%;
    background: linear-gradient(135deg, var(--adb-primary), var(--adb-primary-container), var(--adb-tertiary));
    border-radius: 12px 0 0 12px;
    padding: 4rem 3rem;
    color: var(--adb-on-primary);
    font-family: 'Manrope', sans-serif;
    box-sizing: border-box;
    font-size: 1.1rem;
    line-height: 1.6;
}

@media (max-width: 1024px) {
    body:not(:has(#menu)) #content {
        padding: 3rem;
    }
    body:not(:has(#menu)) #content::before {
        display: none; /* Hide left panel on small screens */
    }
}

body:not(:has(#menu)) h2 {
    font-family: 'Manrope', sans-serif;
    font-size: 1.875rem;
    font-weight: 800;
    color: var(--adb-on-surface);
    margin-bottom: 0.5rem;
    border: none;
    padding: 0;
}

body:not(:has(#menu)) h2::after {
    content: "\A Workspace Login \A Please provide your database credentials to establish a secure connection.";
    white-space: pre-wrap;
    font-family: 'Inter', sans-serif;
    font-size: 0.875rem;
    font-weight: 400;
    color: var(--adb-on-surface-variant);
    display: block;
    margin-top: 0.5rem;
    margin-bottom: 2rem;
}

/* Turn the table into a responsive grid for inputs */
body:not(:has(#menu)) table.layout {
    display: block;
    width: 100%;
    box-shadow: none;
    border: none;
    background: transparent;
    border-radius: 0;
    margin-bottom: 1.25rem;
}
body:not(:has(#menu)) table.layout tbody {
    display: flex;
    flex-wrap: wrap;
    gap: 1.25rem;
}
body:not(:has(#menu)) table.layout tr {
    display: flex;
    flex-direction: column;
    /* Make System and Server span half, everything else full */
    flex: 1 1 100%;
}
body:not(:has(#menu)) table.layout tr:nth-child(1),
body:not(:has(#menu)) table.layout tr:nth-child(2) {
    flex: 1 1 calc(50% - (1.25rem / 2));
}

body:not(:has(#menu)) table.layout th {
    display: block;
    width: 100%;
    text-align: left;
    font-family: 'Inter', sans-serif;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--adb-on-surface-variant);
    padding: 0 0 6px 4px;
    background: transparent;
    border: none;
}
body:not(:has(#menu)) table.layout td {
    display: block;
    width: 100%;
    padding: 0;
    border: none;
}

body:not(:has(#menu)) table.layout input[type="text"],
body:not(:has(#menu)) table.layout input[type="password"],
body:not(:has(#menu)) table.layout select {
    width: 100%;
    background-color: var(--adb-surface-low);
    border: none;
    border-radius: 8px;
    padding: 12px 16px;
    font-family: 'Inter', sans-serif;
    font-size: 14px;
    color: var(--adb-on-surface);
    transition: all 0.2s;
    box-sizing: border-box;
    outline: none;
}

body:not(:has(#menu)) table.layout input:focus,
body:not(:has(#menu)) table.layout select:focus {
    box-shadow: 0 0 0 2px rgba(70, 72, 212, 0.2);
    background-color: #ffffff;
}

body:not(:has(#menu)) form > p {
    display: flex;
    flex-direction: column-reverse; /* Button at bottom, checkbox above it */
    gap: 1.25rem;
}

body:not(:has(#menu)) input[type="submit"] {
    width: 100%;
    background: linear-gradient(to right, var(--adb-primary), var(--adb-primary-container));
    color: var(--adb-on-primary);
    padding: 1rem;
    border-radius: 8px;
    font-weight: 700;
    font-family: 'Inter', sans-serif;
    font-size: 14px;
    letter-spacing: 0.05em;
    border: none;
    cursor: pointer;
    box-shadow: 0 10px 15px -3px rgba(70, 72, 212, 0.2);
    transition: transform 0.1s;
    text-transform: uppercase;
}
body:not(:has(#menu)) input[type="submit"]:active {
    transform: scale(0.98);
}

body:not(:has(#menu)) label {
    font-family: 'Inter', sans-serif;
    font-size: 14px;
    color: var(--adb-on-surface-variant);
    display: flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
}
body:not(:has(#menu)) input[type="checkbox"] {
    appearance: none;
    width: 20px;
    height: 20px;
    border-radius: 4px;
    background-color: var(--adb-surface-low);
    border: none;
    cursor: pointer;
    position: relative;
    transition: background-color 0.2s;
}
body:not(:has(#menu)) input[type="checkbox"]:checked {
    background-color: var(--adb-primary);
}
body:not(:has(#menu)) input[type="checkbox"]:checked::after {
    content: "✓";
    position: absolute;
    color: white;
    font-size: 14px;
    font-weight: bold;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
}

body:not(:has(#menu)) #lang { display: none; }
