/* 
 * ROG CSS Styles
 * Modern, dark-themed, premium UI 
 */

:root {
	--rog-bg: #131A2A;
	--rog-surface: #0B1120;
	--rog-card: #111827;
	--rog-surface-hover: #1F2937;
	--rog-primary: #7C3AED;
	--rog-primary-dark: #5B21B6;
	--rog-gradient: linear-gradient(135deg, #7C3AED, #A855F7);
	--rog-gradient-hover: linear-gradient(135deg, #6D28D9, #9333EA);
	--rog-text: #E5E7EB;
	--rog-text-secondary: #9CA3AF;
	--rog-text-muted: #6B7280;
	--rog-border: #1F2937;
	--rog-input-border: #374151;
	--rog-accent: #22C55E;
	--rog-radius: 12px;
	--rog-transition: all 0.3s ease;
}

/* Container */
.rog-container {
	background-color: var(--rog-bg);
	color: var(--rog-text);
	font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
	padding: 30px;
	border-radius: var(--rog-radius);
	box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
	max-width: 1200px;
	margin: 0 auto;
	box-sizing: border-box;
}

.rog-container * {
	box-sizing: border-box;
}

/* Mode Toggle */
.rog-mode-toggle-wrapper {
	display: flex;
	justify-content: center;
	background-color: var(--rog-surface);
	padding: 5px;
	border-radius: 6px;
	width: max-content;
	margin: 0 auto 30px auto;
	border: 1px solid var(--rog-border);
}

.rog-mode-btn {
	background: transparent;
	color: var(--rog-text-muted);
	border: none;
	padding: 10px 20px;
	border-radius: 6px;
	font-weight: 600;
	font-size: 14px;
	cursor: pointer;
	transition: var(--rog-transition);
}

.rog-mode-btn.active {
	background: var(--rog-gradient);
	color: #fff;
	box-shadow: 0 4px 15px rgba(124, 58, 237, 0.4);
}

/* Controls Area */
.rog-controls-area {
	background-color: var(--rog-surface);
	padding: 25px;
	border-radius: var(--rog-radius);
	margin-bottom: 30px;
	border: 1px solid var(--rog-border);
}

.rog-control-group {
	margin-bottom: 20px;
}

.rog-control-group label {
	display: block;
	margin-bottom: 8px;
	font-weight: 500;
	font-size: 14px;
	color: var(--rog-text);
}

.rog-control-group input[type="number"],
.rog-control-group input[type="text"] {
	width: 100%;
	padding: 12px 15px;
	background-color: var(--rog-bg);
	border: 1px solid var(--rog-input-border);
	color: var(--rog-text);
	border-radius: 8px;
	font-size: 16px;
	transition: var(--rog-transition);
}

.rog-control-group input:focus {
	outline: none;
	border-color: var(--rog-primary);
	box-shadow: 0 0 0 3px rgba(124, 58, 237, 0.2);
}

.rog-checkbox-wrapper {
	display: flex;
	align-items: center;
	gap: 8px;
	height: 44px; /* Matches input field exact height */
}

.rog-checkbox-wrapper input[type="checkbox"] {
	width: 18px;
	height: 18px;
	border-radius: 4px;
	accent-color: var(--rog-accent);
	cursor: pointer;
}

.rog-checkbox-wrapper label {
	margin-bottom: 0;
	cursor: pointer;
}

/* Layout Improvements */
.rog-top-controls {
	display: flex;
	align-items: flex-end;
	gap: 20px;
	margin-bottom: 25px;
}

.rog-top-controls .rog-control-group {
	margin-bottom: 0;
}

.rog-limit-field {
	flex: 0 0 50%;
	max-width: 50%;
}

.rog-checkbox-group {
	display: flex;
	align-items: center;
	gap: 12px;
	flex: 1; /* allow it to take up remainder of space */
}

/* Removed the .rog-switch styles entirely as per new Checkbox requirement. */

/* Difficulty Dropdown */
.rog-difficulty-wrapper {
	display: flex;
	align-items: center;
	height: 100%;
}

.rog-difficulty-select {
	background-color: var(--rog-bg);
	border: 1px solid var(--rog-input-border);
	color: var(--rog-text);
	border-radius: 6px;
	padding: 8px 16px;
	font-size: 14px;
	outline: none;
	cursor: pointer;
	min-height: 40px;
	transition: all 0.2s ease;
	font-family: inherit;
}

.rog-difficulty-select:hover,
.rog-difficulty-select:focus {
	border-color: var(--rog-primary);
	box-shadow: 0 0 0 3px rgba(124, 58, 237, 0.2);
}

/* Category Filters */
.rog-category-buttons {
	display: flex;
	flex-wrap: wrap;
	gap: 12px;
}

.rog-cat-btn {
	background-color: var(--rog-bg);
	color: var(--rog-text);
	border: 1px solid var(--rog-border);
	padding: 10px 16px;
	border-radius: 20px;
	font-size: 15px;
	cursor: pointer;
	transition: var(--rog-transition);
}

.rog-cat-btn:hover {
	background-color: var(--rog-surface-hover);
}

.rog-cat-btn.active {
	background-color: var(--rog-primary);
	border-color: var(--rog-primary);
	color: #fff;
}

/* Word Filters Header */
.rog-word-filters-header {
	font-size: 16px;
	font-weight: 600;
	color: var(--rog-text);
	background-color: rgba(255, 255, 255, 0.03);
	border: 1px dashed var(--rog-input-border);
	padding: 14px 20px;
	border-radius: 8px;
	margin-top: 25px;
	margin-bottom: 20px;
	cursor: pointer;
	display: flex;
	align-items: center;
	gap: 10px;
	user-select: none;
	transition: var(--rog-transition);
}

.rog-word-filters-header:hover {
	color: #fff;
	background-color: rgba(255, 255, 255, 0.06);
	border-color: var(--rog-primary);
	border-style: solid;
}

.rog-word-filters-header small {
	font-size: 12px;
	font-weight: 400;
	color: var(--rog-text-muted);
	margin-left: auto;
	background-color: var(--rog-bg);
	padding: 4px 10px;
	border-radius: 12px;
	border: 1px solid var(--rog-primary);
}

.rog-word-filters-wrapper {
	overflow: hidden;
	transition: max-height 0.4s ease, opacity 0.3s ease;
}

.rog-word-filters-wrapper.collapsed {
	max-height: 0;
	opacity: 0;
}

.rog-word-filters-wrapper.expanded {
	max-height: 1200px; /* Increased to prevent cutting off on mobile */
	opacity: 1;
}

.rog-word-filters {
	display: grid;
	grid-template-columns: repeat(2, 1fr);
	gap: 15px;
}

/* Generate Button */
.rog-generate-btn {
	width: 100%;
	padding: 15px;
	background: var(--rog-gradient);
	color: #fff;
	border: none;
	border-radius: 8px;
	font-size: 16px;
	font-weight: bold;
	cursor: pointer;
	transition: var(--rog-transition);
	display: flex;
	justify-content: center;
	align-items: center;
	gap: 10px;
}

.rog-generate-btn:hover {
	background: var(--rog-gradient-hover);
	box-shadow: 0 6px 20px rgba(124, 58, 237, 0.4);
	transform: translateY(-2px);
}

.rog-generate-btn:disabled {
	opacity: 0.7;
	cursor: not-allowed;
	transform: none;
}

/* Loader */
.rog-loader {
	width: 20px;
	height: 20px;
	border: 3px solid rgba(255, 255, 255, 0.3);
	border-top-color: #fff;
	border-radius: 50%;
	animation: rog-spin 1s linear infinite;
}

@keyframes rog-spin {
	to {
		transform: rotate(360deg);
	}
}

.rog-error-msg {
	color: #ff5252;
	margin-top: 15px;
	font-size: 14px;
	text-align: center;
}

/* Results Grid */
.rog-results-wrapper {
	margin-bottom: 40px;
}

.rog-results-grid {
	display: grid;
	grid-template-columns: repeat(4, 1fr);
	gap: 20px;
	margin-bottom: 20px;
}

.rog-empty-state {
	grid-column: 1 / -1;
	text-align: center;
	padding: 50px 20px;
	color: var(--rog-text-secondary);
	font-size: 15px;
	background-color: transparent;
	border: 2px dashed var(--rog-input-border);
	border-radius: var(--rog-radius);
	margin: 10px 0;
	box-shadow: inset 0 0 25px rgba(124, 58, 237, 0.05);
}

.rog-card {
	background-color: var(--rog-card);
	border: 1px solid var(--rog-border);
	border-radius: var(--rog-radius);
	padding: 15px 20px;
	display: flex;
	flex-direction: row;
	justify-content: space-between;
	align-items: center;
	transition: var(--rog-transition);
}

.rog-card:hover {
	transform: translateY(-3px);
	box-shadow: 0 8px 25px rgba(124, 58, 237, 0.15), 0 4px 10px rgba(0,0,0,0.3);
	border-color: var(--rog-primary);
}

.rog-card-image {
	/* Placeholder for future image support */
	width: 100%;
	height: 120px;
	background-color: var(--rog-bg);
	border-radius: 8px;
	display: none;
	/* hidden intentionally for now based on requirements */
}

.rog-card-name {
	font-size: 18px;
	font-weight: 500;
	color: #fff;
	text-transform: capitalize;
	letter-spacing: 0.3px;
	margin: 0;
	flex: 1;
	text-align: left;
}

.rog-card-divider {
	width: 1px;
	height: 18px;
	background: rgba(255,255,255,0.15);
	margin: 0 10px;
}

.rog-card-actions {
	display: flex;
	align-items: center;
	gap: 8px;
}

.rog-action-btn {
	background-color: transparent;
	color: var(--rog-text-muted);
	border: 1px solid transparent;
	width: 32px;
	height: 32px;
	padding: 0;
	border-radius: 4px;
	font-size: 16px; /* Increased icon size */
	cursor: pointer;
	flex: 0 0 32px; /* Prevent layout shift */
	transition: var(--rog-transition);
	display: flex;
	justify-content: center;
	align-items: center;
}

.rog-action-btn:hover {
	background-color: rgba(255, 255, 255, 0.08);
	color: var(--rog-text);
	border-color: transparent;
}

.rog-action-btn.success {
	background-color: rgba(34, 197, 94, 0.15);
	color: var(--rog-accent) !important;
	border: 1px solid rgba(34, 197, 94, 0.4);
	transform: scale(1.1);
	transition: all 0.2s ease;
}

/* Share Button & Sentence Button */
.rog-actions-row {
	display: flex;
	justify-content: center;
	align-items: center;
	gap: 15px;
	margin-top: 20px;
}

.rog-share-btn {
	background-color: transparent;
	color: var(--rog-primary);
	border: 2px solid var(--rog-primary);
	padding: 10px 30px;
	border-radius: 25px;
	font-weight: bold;
	cursor: pointer;
	transition: var(--rog-transition);
}

.rog-share-btn:hover {
	background-color: var(--rog-primary);
	color: #fff;
}

.rog-sentence-btn {
	background: var(--rog-gradient);
	color: #fff;
	border: none;
	padding: 12px 30px;
	border-radius: 25px;
	font-weight: bold;
	font-size: 15px;
	cursor: pointer;
	transition: var(--rog-transition);
	display: flex;
	align-items: center;
	gap: 8px;
}

.rog-sentence-btn:hover {
	background: var(--rog-gradient-hover);
	box-shadow: 0 4px 15px rgba(124, 58, 237, 0.4);
	transform: translateY(-2px);
}

/* Sentence Output */
.rog-sentence-output {
	margin-top: 25px;
	padding: 20px;
	background-color: var(--rog-surface);
	border: 1px solid var(--rog-primary);
	border-radius: var(--rog-radius);
	color: var(--rog-text);
	font-size: 16px;
	line-height: 1.6;
	text-align: center;
	animation: slideUp 0.4s ease forwards;
}

/* AI Thinking Flow Animations */
.rog-ai-dots {
	display: flex;
	justify-content: center;
	gap: 8px;
	margin-bottom: 15px;
}

.rog-ai-dots div {
	width: 14px;
	height: 14px;
	background-color: var(--rog-primary);
	border-radius: 50%;
	animation: bounce 1.4s infinite ease-in-out both;
}

.rog-ai-dots div:nth-child(1) { animation-delay: -0.32s; }
.rog-ai-dots div:nth-child(2) { animation-delay: -0.16s; }

@keyframes bounce {
	0%, 80%, 100% { transform: scale(0); opacity: 0.5; }
	40% { transform: scale(1); opacity: 1; }
}

@keyframes pulse-text {
	0%, 100% { opacity: 0.7; }
	50% { opacity: 1; }
}

@keyframes slideUp {
	from { opacity: 0; transform: translateY(10px); }
	to { opacity: 1; transform: translateY(0); }
}

/* Clear Filters Button */
.rog-clear-filters-wrapper {
	grid-column: 1 / -1;
	display: flex;
	justify-content: flex-end;
	margin-top: 5px;
	margin-bottom: 20px;
}
.rog-clear-btn {
	background: transparent !important;
	color: var(--rog-text-muted) !important;
	border: 1px solid var(--rog-border) !important;
	padding: 8px 16px !important;
	border-radius: 6px !important;
	cursor: pointer !important;
	font-size: 13px !important;
	font-weight: 500 !important;
	transition: var(--rog-transition) !important;
    outline: none !important;
    box-shadow: none !important;
}

.rog-clear-btn.active {
	background: rgba(124, 58, 237, 0.1) !important;
	color: var(--rog-primary) !important;
	border-color: var(--rog-primary) !important;
}

.rog-clear-btn.active:hover {
	background: rgba(124, 58, 237, 0.2) !important;
}

/* History */
.rog-history-area {
	border-top: 1px solid var(--rog-border);
	padding-top: 25px;
}

.rog-history-header {
	display: flex;
	justify-content: space-between;
	align-items: center;
	margin-bottom: 15px;
}

.rog-history-title {
	font-size: 16px;
	color: var(--rog-text-muted);
	cursor: pointer;
	user-select: none;
	display: flex;
	align-items: center;
	gap: 8px;
	font-weight: 500;
	transition: var(--rog-transition);
}

.rog-history-title:hover {
	color: var(--rog-text);
}

.rog-history-delete {
	cursor: pointer;
	font-size: 16px;
	color: var(--rog-text-muted);
	transition: var(--rog-transition);
}

.rog-history-delete:hover {
	color: #ff5252;
}

.rog-history-wrapper {
	overflow: hidden;
	transition: max-height 0.4s ease;
}

.rog-history-wrapper.collapsed {
	max-height: 28px;
	/* Approx height of one history item line */
}

/* Default expanded state if we add JS to toggle */
.rog-history-wrapper.expanded {
	max-height: 600px;
}

.rog-history-list {
	list-style: none;
	padding: 0;
	margin: 0;
	display: flex;
	flex-direction: column;
	gap: 8px;
}

.rog-history-item {
	background-color: transparent;
	border: 1px solid transparent;
	padding: 4px 0;
	border-radius: 0;
	font-size: 14px;
	color: var(--rog-text-muted);
	cursor: pointer;
	transition: var(--rog-transition);
}

.rog-history-item:hover {
	color: var(--rog-text);
}

/* Responsive */

/* Universal Layout & Touch Adjustments */
.rog-history-item {
	word-break: break-word;
	white-space: normal;
	line-height: 1.4;
	padding: 8px 0; /* Touch friendly spacing */
}

.rog-card-name {
	word-break: break-word;
	white-space: normal;
	line-height: 1.3;
}

.rog-card-actions {
	flex-shrink: 0; /* Prevent overlap with names */
}

/* Tablet (768px - 1023px) */
@media (max-width: 1023px) {
	.rog-results-grid {
		grid-template-columns: repeat(3, 1fr);
	}
	
	.rog-top-controls {
		flex-direction: column;
		align-items: stretch;
		gap: 20px;
	}
	
	.rog-limit-field {
		flex: 0 0 100%;
		max-width: 100%;
	}
	
	.rog-checkbox-group {
		flex-direction: row;
		flex-wrap: wrap;
		align-items: center;
		gap: 15px;
	}
}

/* Mobile (below 768px) */
@media (max-width: 767px) {
	.rog-container {
		padding: 20px;
	}

	.rog-results-grid {
		grid-template-columns: repeat(2, 1fr);
	}

	/* Mode Toggle Full Width */
	.rog-mode-toggle-wrapper {
		width: 100%;
		display: flex;
	}
	
	.rog-mode-btn {
		flex: 1;
		min-height: 48px; /* Tappable height */
		padding: 10px 5px;
		font-size: 13px; /* Slightly smaller for fitting */
	}

	/* Stack Top Controls */
	.rog-checkbox-group {
		flex-direction: column;
		align-items: stretch;
		gap: 12px;
	}

	.rog-checkbox-wrapper {
		height: auto;
		min-height: 44px; /* Ensure checkmark row is thick enough */
	}

	.rog-difficulty-wrapper {
		width: 100%;
	}
	
	.rog-difficulty-select {
		width: 100%;
		min-height: 44px;
	}

	/* Category Buttons Wrapping */
	.rog-category-buttons {
		gap: 10px;
	}
	
	.rog-cat-btn {
		min-height: 40px;
		flex: 1 1 auto;
		text-align: center;
	}

	/* Word Filters */
	.rog-word-filters {
		grid-template-columns: 1fr;
	}

	.rog-clear-filters-wrapper {
		justify-content: center;
		margin-top: 5px;
		margin-bottom: 25px;
	}

	/* Generate Button */
	.rog-generate-btn {
		min-height: 48px;
		font-size: 16px;
	}

	/* Touch Targets */
	.rog-action-btn {
		width: 44px;
		height: 44px;
		flex: 0 0 44px;
		font-size: 20px;
	}

	.rog-sentence-btn, .rog-share-btn {
		min-height: 44px;
	}
}

/* Small Mobile (below 480px) */
@media (max-width: 479px) {
	.rog-container {
		padding: 14px;
	}

	.rog-results-grid {
		grid-template-columns: 1fr;
	}

	.rog-card {
		padding: 12px 14px;
	}

	.rog-actions-row {
		flex-direction: column;
		gap: 10px;
		width: 100%;
	}

	.rog-actions-row button {
		width: 100%;
		justify-content: center;
	}
}

/* Share Modal Styling */
.rog-modal-backdrop {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(8px);
    z-index: 10000;
    justify-content: center;
    align-items: center;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.rog-modal-backdrop.show {
    display: flex;
    opacity: 1;
}

.rog-modal-content {
    background: rgba(19, 26, 42, 0.95);
    border: 1px solid rgba(124, 58, 237, 0.3);
    border-radius: 16px;
    width: 90%;
    max-width: 450px;
    padding: 24px;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.4);
    transform: translateY(20px);
    transition: transform 0.3s ease;
}

.rog-modal-backdrop.show .rog-modal-content {
    transform: translateY(0);
}

.rog-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
}

.rog-modal-header .rog-modal-title {
    margin: 0;
    font-size: 20px;
    color: #fff;
    font-weight: 600;
}

.rog-modal-close {
    background: transparent;
    border: none;
    color: var(--rog-text-muted);
    font-size: 28px;
    cursor: pointer;
    line-height: 1;
    transition: color 0.2s;
}

.rog-modal-close:hover {
    color: #fff;
}

.rog-share-platforms {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 15px;
    margin-bottom: 25px;
}

.rog-share-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    text-decoration: none;
    color: var(--rog-text-muted);
    font-size: 12px;
    transition: var(--rog-transition);
}

.rog-share-item:hover {
    color: #fff;
    transform: translateY(-3px);
}

.rog-share-icon {
    width: 50px;
    height: 50px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.05);
    transition: all 0.3s ease;
}

.rog-share-icon svg {
    width: 24px;
    height: 24px;
}

.rog-share-icon.whatsapp:hover { background: #25D366; color: #fff; box-shadow: 0 0 15px rgba(37, 211, 102, 0.4); }
.rog-share-icon.facebook:hover { background: #1877F2; color: #fff; box-shadow: 0 0 15px rgba(24, 119, 242, 0.4); }
.rog-share-icon.x-twitter:hover { background: #000; color: #fff; box-shadow: 0 0 15px rgba(255, 255, 255, 0.1); }
.rog-share-icon.email:hover { background: var(--rog-primary); color: #fff; box-shadow: 0 0 15px rgba(124, 58, 237, 0.4); }

.rog-modal-divider {
    display: flex;
    align-items: center;
    margin: 20px 0;
    color: var(--rog-text-muted);
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 1px;
}

.rog-modal-divider::before, 
.rog-modal-divider::after {
    content: "";
    flex: 1;
    height: 1px;
    background: var(--rog-border);
}

.rog-modal-divider span {
    padding: 0 15px;
}

.rog-copy-link-wrapper {
    display: flex;
    gap: 10px;
    background: rgba(0, 0, 0, 0.2);
    padding: 6px;
    border-radius: 10px;
    border: 1px solid var(--rog-border);
}

.rog-copy-link-wrapper input {
    flex: 1;
    background: transparent;
    border: none;
    color: var(--rog-text);
    font-size: 13px;
    padding: 8px;
    outline: none;
}

.rog-copy-link-wrapper button {
    background: var(--rog-primary);
    color: #fff;
    border: none;
    padding: 8px 16px;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: var(--rog-transition);
}

.rog-copy-link-wrapper button:hover {
    background: var(--rog-primary-hover);
    transform: scale(1.05);
}

@media (max-width: 480px) {
    .rog-modal-content {
        width: 100%;
        position: fixed;
        bottom: 0;
        border-radius: 20px 20px 0 0;
        transform: translateY(100%);
    }

    .rog-modal-backdrop.show .rog-modal-content {
        transform: translateY(0);
    }
}