:root {
    --bg: #ffffff;
    --header-bg: #1a73e8;
    --text-dark: #1e2a54;
    --text-body: #000000;
    --accent: #1a73e8;
    --input-bg: #f7f9ff;
    --input-border: #d1d7e3;
    --input-text: #5f698c;
    --white: #ffffff;
    --light-gray: #f5f5f5;
    --footer-border: #d1d7e3;
    --shadow: rgba(21, 40, 88, 0.2);
}

* { box-sizing: border-box; }
body {
    background-color: var(--bg);
    background-image: linear-gradient(var(--header-bg) 200px, var(--bg) 200px);
    background-repeat: no-repeat;
    font-family: Arial, sans-serif;
    font-size: 14px;
    margin: 0;
    line-height: 1.6;
    color: var(--text-body);
}
#header {
    display: flex; justify-content: center; max-width: 600px; margin: 0 auto; padding-top: 20px; flex-wrap: wrap;
}
#header a { color: #ecf1fc; text-decoration: none; margin-right: 20px; font-size: 14px; transition: opacity 0.2s; }
#header a:last-of-type { margin-right: 0; }
#header a:hover { opacity: 0.8; }

#logo { text-align: center; max-width: 600px; margin: 30px auto; }
.logo-container { display: inline-flex; align-items: center; justify-content: center; text-decoration: none; gap: 12px; }
.logo-container img { height: 51px; width: 51px; border-radius: 50%; object-fit: cover; border: 2px solid var(--accent); transition: transform 0.2s; }
.logo-container:hover img { transform: scale(1.05); }
.logo-text { font-size: 30px; font-weight: 700; color: #ffffff; letter-spacing: 1px; line-height: 1; }
.logo-container:hover .logo-text { opacity: 0.9; }

.search-form {
    color: var(--text-dark); background-color: var(--white); max-width: 560px; border-radius: 8px;
    box-shadow: 0px 8px 8px var(--shadow); margin: 0 auto; padding: 20px;
}
.search-form label { display: block; text-overflow: ellipsis; white-space: nowrap; overflow: hidden; font-weight: 600; font-size: 15px; margin-bottom: 4px; text-align: center; }
.search-form .form-row { margin-top: 20px; display: flex; gap: 8px; }
.search-form input { font-family: Arial, sans-serif; font-size: 16px; height: 48px; border-radius: 4px; }
.search-form .input-wrapper { position: relative; flex: 1; min-width: 0; }
.search-form input[type="text"] { width: 100%; color: var(--input-text); background-color: var(--input-bg); border: 1px solid var(--input-border); padding: 0 14px; outline: none; box-sizing: border-box; transition: border-color 0.2s; }
.search-form input[type="text"]:focus { border-color: #8b95b5; box-shadow: 0 0 0 3px rgba(30, 42, 84, 0.06); }
.search-form input[type="submit"] {
    color: var(--white); background-color: var(--accent); font-weight: 600; border: none; padding: 0 20px;
    cursor: pointer; white-space: nowrap; letter-spacing: 0.3px; transition: background-color 0.2s, transform 0.1s;
}
.search-form input[type="submit"]:hover { background-color: #1669d0; }
.search-form input[type="submit"]:active { transform: scale(0.97); }

.suggest-results { position: absolute; z-index: 100; top: 100%; left: 0; width: 100%; max-height: 184px; margin: 4px 0 0 0; padding: 5px 0; overflow: auto; list-style: none; background: #fff; box-shadow: 0 10px 15px rgba(0,0,0,0.12); border-radius: 4px; border: 1px solid #e8e8e8; }
.suggest-results.hidden { display: none; }
.suggest-results li { margin: 0; padding: 10px 15px; cursor: pointer; font-size: 14px; color: #333; transition: background 0.15s; }
.suggest-results li:hover, .suggest-results li.active { background: #f0f3fa; color: #1e2a54; }

/* Progress bar styles */
.progress-container {
    width: 100%;
    background: #e9ecef;
    border-radius: 20px;
    overflow: hidden;
    margin: 20px 0;
    height: 20px;
    box-shadow: inset 0 2px 4px rgba(0,0,0,0.1);
}
.progress-bar {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, #1a73e8, #4fc3f7);
    border-radius: 20px;
    transition: width 0.3s ease;
    position: relative;
}
.progress-bar::after {
    content: attr(data-percent) '%';
    position: absolute;
    right: 10px;
    color: white;
    font-size: 12px;
    font-weight: bold;
    top: 50%;
    transform: translateY(-50%);
}
.progress-text {
    text-align: center;
    font-size: 15px;
    color: #1e2a54;
    font-weight: 500;
    margin-top: 8px;
}

#main-content { max-width: 600px; margin: 40px auto; }
.page { display: block; }

.convert-section { padding: 1rem; background: #f9f9f9; border-radius: 8px; border: 1px solid #e8e8e8; margin-bottom: 20px; display: none; }
.convert-section.active { display: block; }
.convert-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; flex-wrap: wrap; gap: 8px; }
.convert-header span { font-weight: 600; color: #1e2a54; font-size: 15px; }
.btn-new-search { display: inline-flex; align-items: center; padding: 6px 14px; height: 32px; cursor: pointer; background: #f0f0f0; border: 1px solid #ddd; color: #333; border-radius: 4px; font-size: 13px; text-decoration: none; transition: background 0.2s; }
.btn-new-search:hover { background: #e4e4e4; }

.result-card {
    background: white; border-radius: 12px; padding: 1.5rem; margin: 1rem 0;
    border: 1px solid #e0e0e0; display: flex; flex-direction: column; gap: 1.5rem;
}
.result-row {
    display: flex; align-items: center; gap: 1.5rem; flex-wrap: wrap;
}
.result-card img {
    width: 160px; height: 90px; border-radius: 6px; object-fit: cover; background: #eee;
}
.result-info { flex: 1; min-width: 200px; }
.result-info .video-title {
    font-weight: 600; color: #1e2a54; font-size: 15px; line-height: 1.4;
    display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.result-info .meta { font-size: 13px; color: #666; margin-top: 6px; }
.download-btn {
    background: #16a34a; color: white; border: none; padding: 14px 28px; border-radius: 6px;
    font-weight: 600; cursor: pointer; font-size: 16px; transition: background 0.2s;
    white-space: nowrap; text-decoration: none; display: inline-flex; align-items: center; justify-content: center;
    gap: 8px; width: 100%; max-width: 280px; margin: 0 auto;
}
.download-btn:hover { background: #15803d; }

.static-page { padding: 30px 0; }
#main-content { max-width: 600px; margin: 60px auto; min-height: 400px; }
.static-page h1 { color: #1e2a54; font-size: 24px; font-weight: 700; text-align: center; margin: 0 0 20px 0; }
.static-page h2 { color: #1e2a54; font-size: 20px; font-weight: 600; margin: 24px 0 12px 0; }
.static-page h3 { color: #1e2a54; font-size: 16px; font-weight: 600; margin: 18px 0 8px 0; }
.static-page p, .static-page li { color: #000; font-size: 14px; line-height: 24px; text-align: justify; margin: 12px 0; }
.static-page ul, .static-page ol { padding-left: 20px; margin: 10px 0; }
.static-page a { color: #1e2a54; text-decoration: underline; }

#footer { display: flex; justify-content: center; flex-wrap: wrap; max-width: 600px; border-top: 1px solid var(--footer-border); margin: 0 auto; padding: 20px 10px; gap: 6px; }
#footer a { color: #1e2a54; text-decoration: none; margin-right: 16px; font-size: 15px; transition: color 0.2s; }
#footer a:last-of-type { margin-right: 0; }
#footer a:hover { color: #000; text-decoration: underline; }
.copyright { text-align: center; padding: 10px 10px 30px; font-size: 15px; color: #666; line-height: 1.6; }
.copyright a { color: #1e2a54; text-decoration: none; }
.copyright a:hover { text-decoration: underline; }

@media only screen and (max-width: 600px) {
    .search-form .form-row { flex-direction: column; gap: 10px; }
    .search-form input[type="submit"] { width: 100%; height: 46px; }
    .static-page, .convert-section { width: 92%; margin-left: auto; margin-right: auto; }
    #footer { font-size: 12px; gap: 4px; }
    #footer a { margin-right: 10px; font-size: 11px; }
    .logo-container img { height: 38px; width: 38px; }
    .logo-text { font-size: 24px; }
    .result-row { flex-direction: column; align-items: flex-start; }
    .result-card img { width: 100%; height: auto; max-height: 200px; }
    .download-btn { max-width: 100%; }
}


/* Dark Theme */
body.dark-theme{
 --bg:#0f172a;
 --text-body:#e5e7eb;
 --text-dark:#f3f4f6;
 --white:#111827;
 --input-bg:#1f2937;
 --input-border:#374151;
 --input-text:#e5e7eb;
 --light-gray:#1f2937;
 --footer-border:#374151;
 --shadow:rgba(0,0,0,.5);
}
.theme-toggle{
  position:fixed;right:20px;bottom:20px;z-index:9999;border:none;border-radius:50%;
  width:52px;height:52px;cursor:pointer;
  background:rgba(255,255,255,0.95);color:#1e2a54;
  box-shadow:0 4px 12px rgba(0,0,0,.15);
  display:flex;align-items:center;justify-content:center;
  transition:all 0.3s ease;
}
.theme-toggle:hover{
  transform:scale(1.1);
  box-shadow:0 6px 16px rgba(0,0,0,.2);
}
.theme-toggle svg{
  width:24px;height:24px;
  transition:transform 0.3s ease;
}
.theme-toggle:hover svg{
  transform:rotate(15deg);
}
body.dark-theme .search-form,
body.dark-theme .result-card,
body.dark-theme .convert-section,
body.dark-theme #ytjarWidgetContainer{background:#111827 !important;color:#e5e7eb;}
body.dark-theme .static-page p,
body.dark-theme .static-page li,
body.dark-theme .result-info .meta,
body.dark-theme .copyright,
body.dark-theme #footer a{color:#d1d5db;}
body.dark-theme .btn-new-search{background:#374151;color:#fff;border-color:#4b5563;}


/* Mobile + Improved Dark Theme Fix */
.theme-toggle{
  top:14px !important;
  right:14px !important;
  bottom:auto !important;
  width:44px !important;
  height:44px !important;
}
body.dark-theme .theme-toggle{
  background:rgba(30,42,84,0.95);color:#f3f4f6;
  box-shadow:0 4px 12px rgba(0,0,0,.4);
}

body.dark-theme,
body.dark-theme .static-page,
body.dark-theme .seo-content,
body.dark-theme p,
body.dark-theme li,
body.dark-theme span,
body.dark-theme div{
 color:#e5e7eb;
}

body.dark-theme h1,
body.dark-theme h2,
body.dark-theme h3,
body.dark-theme h4,
body.dark-theme label,
body.dark-theme .static-page h1,
body.dark-theme .static-page h2,
body.dark-theme .static-page h3,
body.dark-theme #footer a,
body.dark-theme a{
 color:#ffffff;
}

body.dark-theme input,
body.dark-theme textarea{
 color:#ffffff !important;
}

@media(max-width:600px){
  #header{
    justify-content:flex-start;
    padding:15px 70px 0 12px;
  }
  .theme-toggle{
    top:10px !important;
    right:10px !important;
    width:40px !important;
    height:40px !important;
  }
  .theme-toggle svg{
    width:20px;height:20px;
  }
}

/* Language Selector */
.lang-selector-wrap{
  position:relative;
  display:inline-block;
  margin:10px auto;
  text-align:center;
}
.lang-btn{
  background:var(--white);
  color:var(--text-dark);
  border:1px solid var(--input-border);
  border-radius:6px;
  padding:8px 32px 8px 14px;
  font-size:14px;
  cursor:pointer;
  display:inline-flex;
  align-items:center;
  gap:6px;
  position:relative;
  transition:border-color .2s;
}
.lang-btn:hover{border-color:var(--accent);}
.lang-btn::after{
  content:'';
  position:absolute;
  right:12px;
  top:50%;
  transform:translateY(-50%);
  border-left:5px solid transparent;
  border-right:5px solid transparent;
  border-top:5px solid var(--text-dark);
}
.lang-dropdown{
  display:none;
  position:absolute;
  top:100%;
  left:50%;
  transform:translateX(-50%);
  background:var(--white);
  border:1px solid var(--input-border);
  border-radius:8px;
  box-shadow:0 8px 24px rgba(0,0,0,.15);
  z-index:1000;
  min-width:180px;
  max-height:320px;
  overflow-y:auto;
  padding:6px 0;
  margin-top:4px;
}
.lang-dropdown.open{display:block;}
.lang-dropdown a{
  display:block;
  padding:8px 16px;
  color:#1e2a54 !important;
  text-decoration:none;
  font-size:14px;
  transition:background .15s;
  white-space:nowrap;
}
.lang-dropdown a:hover,
.lang-dropdown a.active{
  background:var(--input-bg);
  color:var(--accent) !important;
}
.lang-dropdown a.active{font-weight:600;}

/* RTL support */
html[dir="rtl"] body{direction:rtl;text-align:right;}
html[dir="rtl"] .search-form .form-row{flex-direction:row-reverse;}
html[dir="rtl"] #header{flex-direction:row-reverse;}
html[dir="rtl"] #footer{flex-direction:row-reverse;}
html[dir="rtl"] .convert-header{flex-direction:row-reverse;}
html[dir="rtl"] .result-row{flex-direction:row-reverse;}
html[dir="rtl"] .btn-new-search{flex-direction:row-reverse;}

/* Language selector in header area */
#header .lang-selector-wrap{margin:0 10px;}
#header .lang-btn{
  padding:4px 28px 4px 10px;
  font-size:13px;
  background:rgba(255,255,255,.15);
  color:#fff;
  border-color:rgba(255,255,255,.3);
}
#header .lang-btn::after{border-top-color:#fff;}
#header .lang-dropdown{
  left:auto;
  right:0;
  transform:none;
}
