/* Reset and Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    line-height: 1.6;
    color: #333;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    transition: all 0.3s ease;
}

/* Layout Grid */
.container {
    display: grid;
    grid-template-areas:
        "header header"
        "sidebar main"
        "footer footer";
    grid-template-columns: 280px 1fr;
    grid-template-rows: auto 1fr auto;
    min-height: 100vh;
    max-width: 1400px;
    margin: 0 auto;
    background: rgba(255, 255, 255, 0.95);
    /* backdrop-filter: blur(10px); */
    border-radius: 20px;
    overflow: hidden;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.1);
}

/* Header */
header {
    grid-area: header;
    background: linear-gradient(135deg, #4a90e2 0%, #357abd 100%);
    color: white;
    padding: 1.5rem 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: sticky;
    top: 0;
    z-index: 1000;
    box-shadow: 0 2px 20px rgba(0, 0, 0, 0.1);
}

header h1 {
    font-size: 1.8rem;
    font-weight: 700;
    letter-spacing: -0.5px;
}

/* Dark Mode Toggle */
#darkModeToggle {
    background: rgba(255, 255, 255, 0.2);
    border: 2px solid rgba(255, 255, 255, 0.3);
    color: white;
    padding: 0.6rem 1.2rem;
    border-radius: 25px;
    cursor: pointer;
    font-weight: 500;
    transition: all 0.3s ease;
    /* backdrop-filter: blur(10px); */
}

#darkModeToggle:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.2);
}

/* Sidebar */
aside {
    grid-area: sidebar;
    background: #f8f9fa;
    padding: 2rem 0;
    border-right: 1px solid #e9ecef;
}

nav ul {
    list-style: none;
}

nav ul li {
    margin-bottom: 0.5rem;
}

nav ul li a {
    display: block;
    padding: 1rem 2rem;
    color: #495057;
    text-decoration: none;
    font-weight: 500;
    transition: all 0.3s ease;
    border-left: 4px solid transparent;
    position: relative;
}

nav ul li a:hover,
nav ul li a.active {
    background: linear-gradient(135deg, #4a90e2 0%, #357abd 100%);
    color: white;
    border-left-color: #fff;
    transform: translateX(5px);
}

nav ul li a::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    height: 100%;
    width: 0;
    background: linear-gradient(135deg, #4a90e2 0%, #357abd 100%);
    transition: width 0.3s ease;
    z-index: -1;
}

nav ul li a:hover::before,
nav ul li a.active::before {
    width: 100%;
}

/* Main Content */
main {
    grid-area: main;
    padding: 2rem;
    background: #fff;
}

/* Tool Cards */
.tool-card {
    display: none;
    background: #fff;
    padding: 2.5rem;
    border-radius: 15px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
    border: 1px solid #e9ecef;
    animation: fadeIn 0.5s ease;
}

.tool-card.active {
    display: block;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.tool-card h2 {
    color: #2c3e50;
    margin-bottom: 1.5rem;
    font-size: 1.5rem;
    font-weight: 600;
    position: relative;
    padding-bottom: 0.5rem;
}

.tool-card h2::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    width: 50px;
    height: 3px;
    background: linear-gradient(135deg, #4a90e2 0%, #357abd 100%);
    border-radius: 2px;
}

/* Form Elements */
textarea, input[type="text"] {
    width: 100%;
    padding: 1rem;
    border: 2px solid #e9ecef;
    border-radius: 10px;
    font-size: 1rem;
    font-family: inherit;
    transition: all 0.3s ease;
    background: #f8f9fa;
    resize: vertical;
    min-height: 120px;
}

textarea:focus, input[type="text"]:focus {
    outline: none;
    border-color: #4a90e2;
    background: #fff;
    box-shadow: 0 0 0 3px rgba(74, 144, 226, 0.1);
    transform: translateY(-2px);
}

input[type="text"] {
    min-height: auto;
    height: 45px;
}

/* Buttons */
button {
    background: linear-gradient(135deg, #4a90e2 0%, #357abd 100%);
    color: white;
    border: none;
    padding: 0.8rem 1.5rem;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 500;
    font-size: 0.95rem;
    transition: all 0.3s ease;
    margin: 0.25rem;
    position: relative;
    overflow: hidden;
}

button::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent);
    transition: left 0.5s;
}

button:hover::before {
    left: 100%;
}

button:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(74, 144, 226, 0.4);
}

button:active {
    transform: translateY(0);
}

/* Button Groups */
.buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin: 1rem 0;
}

/* Stats Display */
.stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
    margin: 1.5rem 0;
}

.stats p {
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
    padding: 1rem;
    border-radius: 10px;
    font-weight: 500;
    border-left: 4px solid #4a90e2;
    transition: all 0.3s ease;
}

.stats p:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
}

.stats span {
    color: #4a90e2;
    font-weight: 700;
    font-size: 1.1rem;
}

/* Controls */
.controls {
    display: flex;
    gap: 1rem;
    margin: 1rem 0;
    flex-wrap: wrap;
}

.controls input[type="text"] {
    flex: 1;
    min-width: 200px;
}

/* Options */
.options {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    margin: 1rem 0;
}

.options label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
    font-weight: 500;
    transition: all 0.3s ease;
}

.options label:hover {
    color: #4a90e2;
}

.options input[type="checkbox"] {
    width: 18px;
    height: 18px;
    accent-color: #4a90e2;
}

/* Footer */
footer {
    grid-area: footer;
    background: #2c3e50;
    color: white;
    padding: 1.5rem 2rem;
    text-align: center;
    font-weight: 500;
}

.site-footer {
  background-color: #f1f1f1;
  padding: 40px 20px;
  color: #333;
  font-family: Arial, sans-serif;
  font-size: 14px;
  margin-top: 50px;
}

.footer-container {
  max-width: 1000px;
  margin: auto;
  display: flex;
  flex-wrap: wrap;
  gap: 30px;
  justify-content: space-between;
}

.footer-section {
  flex: 1;
  min-width: 250px;
}

.footer-section h3 {
  margin-bottom: 10px;
  color: #000;
}

.footer-section a {
  color: #007BFF;
  text-decoration: none;
}

.footer-section a:hover {
  text-decoration: underline;
}

.footer-bottom {
  text-align: center;
  margin-top: 30px;
  color: #777;
}


/* Dark Mode */
body.dark-mode {
    background: linear-gradient(135deg, #2c3e50 0%, #34495e 100%);
}

body.dark-mode .container {
    background: rgba(44, 62, 80, 0.95);
}

body.dark-mode aside {
    background: #34495e;
    border-right-color: #4a6741;
}

body.dark-mode nav ul li a {
    color: #ecf0f1;
}

body.dark-mode main {
    background: #2c3e50;
}

body.dark-mode .tool-card {
    background: #34495e;
    border-color: #4a6741;
    color: #ecf0f1;
}

body.dark-mode .tool-card h2 {
    color: #ecf0f1;
}

body.dark-mode textarea,
body.dark-mode input[type="text"] {
    background: #2c3e50;
    border-color: #4a6741;
    color: #ecf0f1;
}

body.dark-mode textarea:focus,
body.dark-mode input[type="text"]:focus {
    background: #34495e;
    border-color: #4a90e2;
}

body.dark-mode .stats p {
    background: linear-gradient(135deg, #2c3e50 0%, #34495e 100%);
    color: #ecf0f1;
}

/* Responsive Design */
@media (max-width: 768px) {
    .container {
        grid-template-areas:
            "header"
            "main"
            "footer";
        grid-template-columns: 1fr;
        border-radius: 0;
    }
    
    aside {
        display: none;
    }
    
    header {
        padding: 1rem;
    }
    
    header h1 {
        font-size: 1.4rem;
    }
    
    main {
        padding: 1rem;
    }
    
    .tool-card {
        padding: 1.5rem;
    }
    
    .controls {
        flex-direction: column;
    }
    
    .controls input[type="text"] {
        min-width: auto;
    }
    
    .stats {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 480px) {
    .buttons {
        flex-direction: column;
    }
    
    button {
        width: 100%;
    }
}


/* Additional styles for enhanced features */

/* Keyword tags */
.keyword-list {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-top: 0.5rem;
}

.keyword-tag {
    background: linear-gradient(135deg, #4a90e2 0%, #357abd 100%);
    color: white;
    padding: 0.25rem 0.5rem;
    border-radius: 15px;
    font-size: 0.8rem;
    font-weight: 500;
}

/* Export/Import buttons */
.export-btn, .import-btn {
    background: linear-gradient(135deg, #28a745 0%, #20c997 100%);
    box-shadow: 0 4px 15px rgba(40, 167, 69, 0.3);
}

.export-btn:hover, .import-btn:hover {
    background: linear-gradient(135deg, #218838 0%, #1ea085 100%);
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(40, 167, 69, 0.4);
}

/* Floating action buttons */
button[style*="position: fixed"] {
    /* backdrop-filter: blur(10px); */
    border: none;
    font-weight: 600;
    transition: all 0.3s ease;
}

/* Enhanced animations */
@keyframes slideInRight {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

@keyframes pulse {
    0% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.05);
    }
    100% {
        transform: scale(1);
    }
}

.tool-card.active {
    animation: fadeIn 0.5s ease, slideInRight 0.5s ease;
}

/* Hover effects for stats */
.stats p:hover {
    animation: pulse 0.5s ease;
}

/* Enhanced button hover effects */
button:hover {
    animation: pulse 0.3s ease;
}

/* Improved focus states */
textarea:focus, input:focus {
    animation: pulse 0.3s ease;
}

/* Loading animation for processing */
@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.processing::after {
    content: '';
    display: inline-block;
    width: 16px;
    height: 16px;
    border: 2px solid #f3f3f3;
    border-top: 2px solid #4a90e2;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-left: 8px;
}

/* Enhanced mobile responsiveness */
@media (max-width: 768px) {
    .export-btn, .import-btn {
        bottom: 10px;
        right: 10px;
        padding: 0.6rem 1rem;
        font-size: 0.8rem;
    }
    
    .keyword-list {
        justify-content: center;
    }
    
    .stats {
        grid-template-columns: 1fr;
        gap: 0.5rem;
    }
    
    .stats p {
        padding: 0.75rem;
        font-size: 0.9rem;
    }
}

/* Print styles */
@media print {
    header, aside, footer, 
    button, .export-btn, .import-btn {
        display: none !important;
    }
    
    .container {
        grid-template-areas: "main";
        grid-template-columns: 1fr;
    }
    
    .tool-card {
        box-shadow: none;
        border: 1px solid #ccc;
        page-break-inside: avoid;
    }
    
    textarea {
        border: 1px solid #ccc;
        background: white !important;
        color: black !important;
    }
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .tool-card {
        border: 2px solid #000;
    }
    
    button {
        border: 2px solid #000;
    }
    
    textarea, input {
        border: 2px solid #000;
    }
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* Custom scrollbar */
::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 4px;
}

::-webkit-scrollbar-thumb {
    background: linear-gradient(135deg, #4a90e2 0%, #357abd 100%);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: linear-gradient(135deg, #357abd 0%, #2c5f8a 100%);
}

/* Dark mode scrollbar */
body.dark-mode ::-webkit-scrollbar-track {
    background: #2c3e50;
}

body.dark-mode ::-webkit-scrollbar-thumb {
    background: linear-gradient(135deg, #4a90e2 0%, #357abd 100%);
}

/* Selection colors */
::selection {
    background: rgba(74, 144, 226, 0.3);
    color: #2c3e50;
}

body.dark-mode ::selection {
    background: rgba(74, 144, 226, 0.5);
    color: #ecf0f1;
}

/* Focus indicators for accessibility */
button:focus-visible,
input:focus-visible,
textarea:focus-visible,
a:focus-visible {
    outline: 3px solid #4a90e2;
    outline-offset: 2px;
}

/* Enhanced gradient backgrounds */
body {
    background-attachment: fixed;
}

body.dark-mode {
    background-attachment: fixed;
}

/* Smooth transitions for all interactive elements */
* {
    transition: all 0.3s ease;
}

/* Enhanced card shadows */
.tool-card {
    box-shadow: 
        0 10px 30px rgba(0, 0, 0, 0.1),
        0 1px 8px rgba(0, 0, 0, 0.05);
}

.tool-card:hover {
    box-shadow: 
        0 15px 40px rgba(0, 0, 0, 0.15),
        0 5px 15px rgba(0, 0, 0, 0.1);
    transform: translateY(-2px);
}

/* Enhanced button styles */
button {
    position: relative;
    overflow: hidden;
    transform-style: preserve-3d;
}

button:active {
    transform: translateY(1px) translateZ(0);
}

/* Improved typography */
h1, h2, h3 {
    text-rendering: optimizeLegibility;
    font-feature-settings: "kern" 1;
}

/* Better spacing */
.tool-card > * + * {
    margin-top: 1rem;
}

.buttons > * + * {
    margin-left: 0.5rem;
}

/* Enhanced form styling */
input, textarea {
    font-feature-settings: "kern" 1;
    text-rendering: optimizeSpeed;
}

/* Improved accessibility */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* Loading states */
.loading {
    opacity: 0.7;
    pointer-events: none;
}

.loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 20px;
    height: 20px;
    margin: -10px 0 0 -10px;
    border: 2px solid #f3f3f3;
    border-top: 2px solid #4a90e2;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}


/* Enhanced Responsive Design and Dark Mode Improvements */

/* Mobile Navigation */
@media (max-width: 768px) {
    .container {
        grid-template-areas:
            "header"
            "nav"
            "main"
            "footer";
        grid-template-columns: 1fr;
        grid-template-rows: auto auto 1fr auto;
    }
    
    aside {
        grid-area: nav;
        background: #f8f9fa;
        padding: 1rem;
        border-right: none;
        border-bottom: 1px solid #e9ecef;
        overflow-x: auto;
    }
    
    nav ul {
        display: flex;
        gap: 0.5rem;
        white-space: nowrap;
        padding-bottom: 0.5rem;
    }
    
    nav ul li {
        margin-bottom: 0;
        flex-shrink: 0;
    }
    
    nav ul li a {
        padding: 0.75rem 1rem;
        border-radius: 20px;
        border-left: none;
        font-size: 0.9rem;
        display: inline-block;
        min-width: max-content;
    }
    
    nav ul li a:hover,
    nav ul li a.active {
        transform: translateX(0);
        transform: translateY(-2px);
    }
    
    /* Mobile-specific button positioning */
    button[style*="position: fixed"] {
        bottom: 20px;
        right: 20px;
        padding: 0.75rem;
        font-size: 0.9rem;
        border-radius: 50px;
    }
    
    .export-btn {
        bottom: 80px;
    }
    
    .import-btn {
        bottom: 140px;
    }
    
    /* Mobile keyboard shortcuts button */
    button[style*="bottom: 120px"] {
        bottom: 200px;
    }
}

/* Tablet specific adjustments */
@media (min-width: 769px) and (max-width: 1024px) {
    .container {
        grid-template-columns: 240px 1fr;
    }
    
    header h1 {
        font-size: 1.6rem;
    }
    
    .tool-card {
        padding: 2rem;
    }
    
    .stats {
        grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    }
}

/* Large screen optimizations */
@media (min-width: 1400px) {
    .container {
        grid-template-columns: 320px 1fr;
    }
    
    .tool-card {
        padding: 3rem;
        max-width: 1000px;
    }
    
    .stats {
        grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    }
}

/* Enhanced Dark Mode */
body.dark-mode {
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 50%, #0f3460 100%);
}

body.dark-mode .container {
    background: rgba(26, 26, 46, 0.95);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

body.dark-mode header {
    background: linear-gradient(135deg, #2c5f8a 0%, #1e4a6b 100%);
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

body.dark-mode aside {
    background: #1e1e2e;
    border-right: 1px solid rgba(255, 255, 255, 0.1);
}

body.dark-mode nav ul li a {
    color: #b8c5d1;
    border-left-color: transparent;
}

body.dark-mode nav ul li a:hover,
body.dark-mode nav ul li a.active {
    background: linear-gradient(135deg, #2c5f8a 0%, #1e4a6b 100%);
    color: #ffffff;
    border-left-color: #4a90e2;
}

body.dark-mode main {
    background: #1a1a2e;
}

body.dark-mode .tool-card {
    background: #1e1e2e;
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: #e0e6ed;
}

body.dark-mode .tool-card h2 {
    color: #ffffff;
}

body.dark-mode .tool-card h2::after {
    background: linear-gradient(135deg, #4a90e2 0%, #357abd 100%);
}

body.dark-mode textarea,
body.dark-mode input[type="text"] {
    background: #2a2a3e;
    border: 2px solid rgba(255, 255, 255, 0.1);
    color: #e0e6ed;
}

body.dark-mode textarea:focus,
body.dark-mode input[type="text"]:focus {
    background: #323248;
    border-color: #4a90e2;
    box-shadow: 0 0 0 3px rgba(74, 144, 226, 0.2);
}

body.dark-mode .stats p {
    background: linear-gradient(135deg, #2a2a3e 0%, #323248 100%);
    color: #e0e6ed;
    border-left-color: #4a90e2;
}

body.dark-mode .keyword-tag {
    background: linear-gradient(135deg, #4a90e2 0%, #357abd 100%);
}

body.dark-mode footer {
    background: #1e1e2e;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    color: #b8c5d1;
}

/* System theme detection */
@media (prefers-color-scheme: dark) {
    body:not(.light-mode) {
        background: linear-gradient(135deg, #1a1a2e 0%, #16213e 50%, #0f3460 100%);
    }
    
    body:not(.light-mode) .container {
        background: rgba(26, 26, 46, 0.95);
        border: 1px solid rgba(255, 255, 255, 0.1);
    }
    
    /* Apply all dark mode styles when system prefers dark */
    body:not(.light-mode) header {
        background: linear-gradient(135deg, #2c5f8a 0%, #1e4a6b 100%);
        border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    }
    
    body:not(.light-mode) aside {
        background: #1e1e2e;
        border-right: 1px solid rgba(255, 255, 255, 0.1);
    }
    
    body:not(.light-mode) nav ul li a {
        color: #b8c5d1;
    }
    
    body:not(.light-mode) nav ul li a:hover,
    body:not(.light-mode) nav ul li a.active {
        background: linear-gradient(135deg, #2c5f8a 0%, #1e4a6b 100%);
        color: #ffffff;
        border-left-color: #4a90e2;
    }
    
    body:not(.light-mode) main {
        background: #1a1a2e;
    }
    
    body:not(.light-mode) .tool-card {
        background: #1e1e2e;
        border: 1px solid rgba(255, 255, 255, 0.1);
        color: #e0e6ed;
    }
    
    body:not(.light-mode) .tool-card h2 {
        color: #ffffff;
    }
    
    body:not(.light-mode) textarea,
    body:not(.light-mode) input[type="text"] {
        background: #2a2a3e;
        border: 2px solid rgba(255, 255, 255, 0.1);
        color: #e0e6ed;
    }
    
    body:not(.light-mode) textarea:focus,
    body:not(.light-mode) input[type="text"]:focus {
        background: #323248;
        border-color: #4a90e2;
        box-shadow: 0 0 0 3px rgba(74, 144, 226, 0.2);
    }
    
    body:not(.light-mode) .stats p {
        background: linear-gradient(135deg, #2a2a3e 0%, #323248 100%);
        color: #e0e6ed;
        border-left-color: #4a90e2;
    }
    
    body:not(.light-mode) footer {
        background: #1e1e2e;
        border-top: 1px solid rgba(255, 255, 255, 0.1);
        color: #b8c5d1;
    }
}

/* Touch device optimizations */
@media (hover: none) and (pointer: coarse) {
    button {
        min-height: 44px;
        min-width: 44px;
        padding: 0.75rem 1.5rem;
    }
    
    nav ul li a {
        min-height: 44px;
        padding: 1rem 1.5rem;
    }
    
    textarea, input[type="text"] {
        min-height: 44px;
        font-size: 16px; /* Prevents zoom on iOS */
    }
    
    .stats p {
        padding: 1.25rem;
    }
}

/* Landscape phone adjustments */
@media (max-width: 768px) and (orientation: landscape) {
    .container {
        grid-template-rows: auto auto 1fr auto;
    }
    
    header {
        padding: 0.75rem 1rem;
    }
    
    header h1 {
        font-size: 1.3rem;
    }
    
    aside {
        padding: 0.5rem;
    }
    
    nav ul {
        gap: 0.25rem;
    }
    
    nav ul li a {
        padding: 0.5rem 0.75rem;
        font-size: 0.8rem;
    }
    
    main {
        padding: 1rem;
    }
    
    .tool-card {
        padding: 1rem;
    }
}

/* High DPI display optimizations */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
    .tool-card {
        box-shadow: 
            0 5px 15px rgba(0, 0, 0, 0.1),
            0 1px 4px rgba(0, 0, 0, 0.05);
    }
    
    button {
        box-shadow: 0 2px 8px rgba(74, 144, 226, 0.3);
    }
}

/* Improved animations for mobile */
@media (max-width: 768px) {
    .tool-card.active {
        animation: fadeIn 0.3s ease;
    }
    
    button:hover {
        animation: none;
        transform: none;
    }
    
    button:active {
        transform: scale(0.95);
    }
    
    .stats p:hover {
        animation: none;
        transform: none;
    }
}

/* Container queries support (future-proofing) */
@container (max-width: 600px) {
    .stats {
        grid-template-columns: 1fr;
    }
    
    .buttons {
        flex-direction: column;
    }
    
    .controls {
        flex-direction: column;
    }
}

/* Focus management for mobile */
@media (max-width: 768px) {
    button:focus-visible,
    input:focus-visible,
    textarea:focus-visible,
    a:focus-visible {
        outline: 2px solid #4a90e2;
        outline-offset: 1px;
    }
}

/* Improved contrast ratios */
@media (prefers-contrast: high) {
    body {
        background: #ffffff;
        color: #000000;
    }
    
    .container {
        background: #ffffff;
        border: 2px solid #000000;
    }
    
    header {
        background: #000000;
        color: #ffffff;
        border-bottom: 2px solid #000000;
    }
    
    aside {
        background: #f0f0f0;
        border-right: 2px solid #000000;
    }
    
    nav ul li a {
        color: #000000;
        border: 1px solid #000000;
    }
    
    nav ul li a:hover,
    nav ul li a.active {
        background: #000000;
        color: #ffffff;
    }
    
    .tool-card {
        background: #ffffff;
        border: 2px solid #000000;
        color: #000000;
    }
    
    button {
        background: #000000;
        color: #ffffff;
        border: 2px solid #000000;
    }
    
    textarea, input[type="text"] {
        background: #ffffff;
        border: 2px solid #000000;
        color: #000000;
    }
    
    .stats p {
        background: #f0f0f0;
        border: 1px solid #000000;
        color: #000000;
    }
}

/* Smooth scrolling */
html {
    scroll-behavior: smooth;
}

/* Enhanced focus indicators */
@media (prefers-reduced-motion: no-preference) {
    *:focus-visible {
        transition: outline 0.2s ease;
    }
}

/* Print optimizations */
@media print {
    body {
        background: white !important;
        color: black !important;
    }
    
    .container {
        background: white !important;
        box-shadow: none !important;
        border: none !important;
    }
    
    .tool-card {
        background: white !important;
        color: black !important;
        border: 1px solid black !important;
        box-shadow: none !important;
        page-break-inside: avoid;
        margin-bottom: 1rem;
    }
    
    textarea {
        background: white !important;
        color: black !important;
        border: 1px solid black !important;
        min-height: 200px;
    }
    
    .stats p {
        background: #f9f9f9 !important;
        color: black !important;
        border: 1px solid black !important;
    }
}

/* Accessibility improvements */
.visually-hidden {
    position: absolute !important;
    width: 1px !important;
    height: 1px !important;
    padding: 0 !important;
    margin: -1px !important;
    overflow: hidden !important;
    clip: rect(0, 0, 0, 0) !important;
    white-space: nowrap !important;
    border: 0 !important;
}

/* Skip link */
.skip-link {
    position: absolute;
    top: -40px;
    left: 6px;
    background: #4a90e2;
    color: white;
    padding: 8px;
    text-decoration: none;
    border-radius: 4px;
    z-index: 10000;
}

.skip-link:focus {
    top: 6px;
}

/* Enhanced mobile menu */
@media (max-width: 768px) {
    .mobile-menu-toggle {
        display: block;
        z-index: 11;
        background: none;
        border: 2px solid rgba(255, 255, 255, 0.3);
        color: white;
        padding: 0.5rem;
        border-radius: 4px;
        cursor: pointer;
    }
    
    .nav-hidden {
        display: none;
    }
    
    .nav-visible {
        display: block;
        animation: slideDown 0.3s ease;
    }
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}
/* تعديل لإظهار القائمة داخل الهيدر على الموبايل */
@media (max-width: 768px) {
  header {
      flex-direction: column;
      align-items: flex-start;
  }

  aside {
      grid-area: auto;
      display: block;
      width: 100%;
      padding: 0.5rem 1rem;
      background: transparent;
      border: none;
  }

  nav ul {
      display: flex;
      flex-wrap: wrap;
      gap: 0.5rem;
      padding: 0;
      margin-top: 0.5rem;
  }

  nav ul li {
      margin: 0;
  }

  nav ul li a {
      padding: 0.5rem 1rem;
      border-radius: 20px;
      font-size: 0.9rem;
      border-left: none;
      background: rgba(255, 255, 255, 0.2);
      color: #fff;
  }

  nav ul li a:hover,
  nav ul li a.active {
      background: rgba(255, 255, 255, 0.3);
      color: #fff;
  }
}



