/* Import Google Font for a modern touch */
@import url('https://fonts.googleapis.com/css2?family=Poppins:wght@300;400;600;700&display=swap');

/* --- CSS Variables for easy theme customization --- */
:root {
    --primary-bg: #1A1A2E; /* Dark background */
    --secondary-bg: #16213E; /* Slightly lighter for sections */
    --card-bg: #0F3460; /* Card background */
    --text-color: #E0E0E0; /* Light text */
    --accent-color: #E94560; /* Vibrant accent for highlights */
    --border-color: #0F3460; /* Subtle border color */
    --button-primary: #533483; /* Primary button color */
    --button-hover: #E94560; /* Button hover color */
    --shadow-light: rgba(0, 0, 0, 0.4);
    --shadow-dark: rgba(0, 0, 0, 0.7);
    --player-bg: #0C0C1E; /* Very dark for player */
    --success-color: #28a745;
    --error-color: #dc3545;
}

/* Global box-sizing for consistent sizing */
*, *::before, *::after {
    box-sizing: border-box;
}

/* --- Base Body Styling --- */
body {
    font-family: 'Poppins', sans-serif;
    margin: 0;
    padding-bottom: 90px; /* Space for the sticky player */
    background-color: var(--primary-bg);
    color: var(--text-color);
    line-height: 1.6;
    scroll-behavior: smooth;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}
/* Admin Panel Pages Section */
.admin-tabs button {
    background: #007bff;
    color: white;
    padding: 10px 20px;
    border: none;
    margin: 5px;
    cursor: pointer;
}

.admin-tabs button:hover {
    background: #0056b3;
}

#page-form-container {
    margin-top: 20px;
    background: #222;
    padding: 20px;
    border-radius: 8px;
}

#page-form label {
    display: block;
    margin-bottom: 8px;
}

#page-form input, #page-form textarea {
    width: 100%;
    padding: 8px;
    margin: 5px 0;
    background: #333;
    color: white;
    border: 1px solid #555;
}

#page-form select {
    padding: 6px;
    background: #333;
    color: white;
    border: 1px solid #555;
}
/* --- Global Links & Headings --- */
a {
    color: var(--accent-color);
    text-decoration: none;
    transition: color 0.3s ease;
}

a:hover {
    color: var(--button-hover);
}

h1, h2, h3, h4, h5, h6 {
    color: var(--text-color);
    margin-top: 0.5em;
    margin-bottom: 0.5em;
    font-weight: 600;
}

/* --- Header & Navigation --- */
header {
    background-color: var(--secondary-bg);
    padding: 1rem 2rem;
    box-shadow: 0 4px 15px var(--shadow-dark);
    position: sticky;
    top: 0;
    z-index: 1001; /* Above sticky player */
    display: flex;
    justify-content: space-between;
    align-items: center;
}

#main-nav {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    flex-wrap: wrap; /* Allow navigation to wrap on smaller screens */
}

#main-nav h1 {
    font-size: 1.8rem;
    font-weight: 700;
    margin: 0;
    color: var(--accent-color);
    flex-shrink: 0; /* Prevent it from shrinking */
}

#main-nav ul {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    gap: 25px;
    flex-wrap: wrap; /* Allow nav items to wrap */
    justify-content: flex-end; /* Align right on larger screens */
}

#main-nav ul li a {
    color: var(--text-color);
    font-weight: 400;
    font-size: 1rem;
    position: relative;
    padding: 5px 0;
}

#main-nav ul li a::after {
    content: '';
    position: absolute;
    left: 0;
    bottom: 0;
    width: 0;
    height: 2px;
    background-color: var(--accent-color);
    transition: width 0.3s ease-out;
}

#main-nav ul li a:hover::after {
    width: 100%;
}

/* --- Main Content Area --- */
main {
    padding: 30px 20px;
    max-width: 1300px;
    margin: 30px auto;
}

/* --- Radio Grid --- */
#radio-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 25px;
}

.radio-card {
    background-color: var(--card-bg);
    border-radius: 12px;
    overflow: hidden;
    cursor: pointer;
    text-align: center;
    padding: 20px;
    box-shadow: 0 6px 20px var(--shadow-light);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    position: relative;
}

.radio-card:hover {
    transform: translateY(-8px);
    box-shadow: 0 12px 30px var(--shadow-dark);
}

.radio-card img {
    max-width: 100%;
    height: 150px; /* Fixed height for consistency */
    object-fit: cover;
    border-radius: 8px;
    margin-bottom: 15px;
    border: 2px solid var(--border-color);
}

.radio-card h3 {
    margin: 0;
    font-size: 1.2rem;
    font-weight: 600;
    color: var(--text-color);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* --- Pagination Controls --- */
.pagination-controls {
    text-align: center;
    margin-top: 40px;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 15px;
    flex-wrap: wrap; /* Allow buttons to wrap */
}

.pagination-controls button {
    padding: 10px 20px;
    background-color: var(--button-primary);
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 1rem;
    font-weight: 600;
    transition: background-color 0.3s ease, transform 0.2s ease;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.3);
}

.pagination-controls button:hover:not(:disabled) {
    background-color: var(--button-hover);
    transform: translateY(-2px);
}

.pagination-controls button:disabled {
    background-color: #444;
    cursor: not-allowed;
    opacity: 0.6;
    box-shadow: none;
}

#page-info {
    font-size: 1.1rem;
    font-weight: 400;
    color: var(--text-color);
}

/* --- Sticky Player --- */
#sticky-player {
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    background-color: var(--player-bg);
    color: white;
    padding: 15px 30px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    box-shadow: 0 -5px 20px var(--shadow-dark);
    z-index: 1000;
    gap: 20px;
}

#sticky-player .player-content {
    display: flex;
    align-items: center;
    gap: 18px;
    flex-grow: 1;
    min-width: 0; /* Allow content to shrink */
}

#player-logo {
    width: 60px;
    height: 60px;
    object-fit: cover;
    border-radius: 50%; /* Make it round */
    border: 3px solid var(--accent-color);
    flex-shrink: 0; /* Ensures logo doesn't shrink smaller than its size */
}

.player-info {
    display: flex;
    flex-direction: column;
    min-width: 0; /* Allow text to truncate */
}

#player-name {
    font-weight: 700;
    font-size: 1.2rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    color: var(--text-color);
}

#player-metadata {
    font-size: 0.9rem;
    color: #AAA;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

audio#audio-player {
    width: 300px;
    flex-shrink: 0;
    /* Customizing audio controls */
    -webkit-appearance: none;
    appearance: none;
    background: transparent;
}

audio#audio-player::-webkit-media-controls-panel {
    background-color: var(--secondary-bg);
    border-radius: 50px;
    padding: 5px 15px;
    box-shadow: 0 2px 5px var(--shadow-dark);
}

/* --- Forms & Buttons --- */
.form-container {
    max-width: 600px;
    margin: 40px auto;
    background-color: var(--secondary-bg);
    padding: 30px;
    border-radius: 15px;
    box-shadow: 0 8px 25px var(--shadow-dark);
}

.form-container h2 {
    text-align: center;
    margin-bottom: 25px;
    color: var(--accent-color);
    font-size: 2rem;
}

.form-container label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    color: var(--text-color);
    font-size: 0.95rem;
}

.form-container input[type="text"],
.form-container input[type="password"],
.form-container input[type="email"],
.form-container input[type="url"],
.form-container textarea {
    width: 100%; /* Changed from calc(100% - 20px) due to box-sizing */
    padding: 12px;
    margin-bottom: 20px;
    border-radius: 8px;
    border: 1px solid var(--border-color);
    background-color: var(--primary-bg);
    color: var(--text-color);
    font-size: 1rem;
    transition: border-color 0.3s ease, box-shadow 0.3s ease;
}

.form-container input:focus,
.form-container textarea:focus {
    border-color: var(--accent-color);
    outline: none;
    box-shadow: 0 0 0 3px rgba(233, 69, 96, 0.3); /* Soft focus glow */
}

.form-container textarea {
    resize: vertical;
    min-height: 80px;
}

.form-container button[type="submit"],
.form-container button:not([type="submit"]) { /* General button style */
    padding: 12px 25px;
    background-color: var(--button-primary);
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 1rem;
    font-weight: 600;
    transition: background-color 0.3s ease, transform 0.2s ease, box-shadow 0.3s ease;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.4);
    margin-right: 10px; /* For multiple buttons */
}

.form-container button[type="submit"]:hover,
.form-container button:not([type="submit"]):hover {
    background-color: var(--button-hover);
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.6);
}

.form-container button#cancel-edit-btn {
    background-color: #6C757D; /* Grey for cancel */
}

.form-container button#cancel-edit-btn:hover {
    background-color: #5A6268;
}

/* Form messages */
.text-center { text-align: center; margin-top: 15px;}
.error-message { color: var(--error-color); margin-top: 15px; font-weight: bold; text-align: center;}
.success-message { color: var(--success-color); margin-top: 15px; font-weight: bold; text-align: center;}


/* --- Admin Panel Specifics --- */
.admin-section {
    background-color: var(--secondary-bg);
    padding: 25px;
    margin-bottom: 25px;
    border-radius: 15px;
    box-shadow: 0 6px 20px var(--shadow-dark);
}

.admin-section h3 {
    color: var(--accent-color);
    font-size: 1.5rem;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 10px;
    margin-bottom: 20px;
}

.admin-list-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    font-size: 1rem;
    flex-wrap: wrap; /* Allow items to wrap */
}

.admin-list-item:last-child {
    border-bottom: none;
}

.admin-list-item span {
    flex-grow: 1;
    margin-right: 15px;
    min-width: 150px; /* Ensure text doesn't collapse too much */
}

.admin-list-item div { /* For buttons */
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 5px; /* Add some space if wrapping */
}

.admin-list-item button {
    margin-left: 0; /* Remove default margin */
    padding: 8px 15px;
    border-radius: 6px;
    font-size: 0.9rem;
    font-weight: 600;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.admin-list-item button.delete {
    background-color: var(--error-color); /* Red */
}
.admin-list-item button.delete:hover {
    background-color: #C82333;
    transform: translateY(-1px);
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.4);
}

.admin-list-item button.approve {
    background-color: var(--success-color); /* Green */
}
.admin-list-item button.approve:hover {
    background-color: #218838;
    transform: translateY(-1px);
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.4);
}

.admin-list-item button.edit {
    background-color: #FFC107; /* Yellow */
    color: #333;
}
.admin-list-item button.edit:hover {
    background-color: #E0A800;
    transform: translateY(-1px);
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.4);
}
/* Admin Panel Styling */
.admin-container {
    max-width: 1200px;
    margin: 20px auto;
    padding: 20px;
}

.admin-tabs button {
    background: #007bff;
    color: white;
    padding: 10px 20px;
    margin: 5px;
    border: none;
    cursor: pointer;
}

.admin-tabs button:hover {
    background: #0056b3;
}

.admin-section {
    display: none;
    margin: 20px 0;
    padding: 20px;
    background: #222;
    border-radius: 8px;
}

.admin-list-item {
    margin: 10px 0;
    padding: 10px;
    background: #1a1a1a;
}

.admin-list-item button {
    background: #007bff;
    color: white;
    padding: 8px 12px;
    margin: 5px;
    border: none;
}

/* Settings Section */
#settings-form {
    margin-top: 20px;
}

#settings-form textarea {
    width: 100%;
    padding: 8px;
    background: #333;
    color: white;
    border: 1px solid #555;
}

#settings-form button {
    background: #007bff;
    color: white;
    padding: 10px 20px;
    margin-top: 10px;
}
/* --- Ad Containers --- */
.ad-container {
    margin: 30px auto;
    padding: 20px;
    background-color: var(--secondary-bg);
    border-radius: 12px;
    text-align: center;
    box-shadow: 0 4px 15px var(--shadow-dark);
    font-size: 0.9rem;
    color: #999;
}

.ad-container ins {
    display: block !important; /* Ensure AdSense block displays */
    background-color: var(--primary-bg); /* Match ad background */
    min-height: 100px; /* Give some space for the ad */
}

/* --- Horizontal Rule --- */
hr {
    border: none;
    border-top: 1px solid var(--border-color);
    margin: 30px 0;
}

/* --- User Radio Items --- */
.radio-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 0;
    border-bottom: 1px dashed rgba(255, 255, 255, 0.1);
    margin-bottom: 10px;
    flex-wrap: wrap; /* Allow items to wrap */
}

.radio-item:last-child {
    border-bottom: none;
}

.radio-item span {
    flex-grow: 1;
    margin-right: 15px;
    font-size: 1.05rem;
    min-width: 150px;
}

.radio-item button {
    margin-left: 0;
    padding: 7px 12px;
    font-size: 0.9rem;
    border-radius: 6px;
    background-color: var(--button-primary);
    color: white;
    border: none;
    cursor: pointer;
    transition: background-color 0.3s ease;
    margin-top: 5px; /* Add some space if wrapping */
}

.radio-item button:hover {
    background-color: var(--accent-color);
}

/* ======================================= */
/* --- RESPONSIVE MEDIA QUERIES --- */
/* ======================================= */

/* Extra large devices (large desktops, 1200px and up) */
@media (min-width: 1200px) {
    main {
        max-width: 1140px;
    }
}

/* Large devices (desktops, 992px and up) */
@media (min-width: 992px) and (max-width: 1199.98px) {
    main {
        max-width: 960px;
    }
    #radio-grid {
        grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
        gap: 20px;
    }
}

/* Medium devices (tablets, 768px and up) */
@media (min-width: 768px) and (max-width: 991.98px) {
    header {
        padding: 1rem 1.5rem;
    }
    #main-nav h1 {
        font-size: 1.6rem;
    }
    #main-nav ul {
        gap: 15px;
    }
    main {
        padding: 25px 15px;
        max-width: 720px;
    }
    #radio-grid {
        grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
        gap: 18px;
    }
    .radio-card img {
        height: 120px;
    }
    #sticky-player {
        padding: 12px 20px;
        gap: 15px;
    }
    #player-logo {
        width: 50px;
        height: 50px;
    }
    #player-name {
        font-size: 1.1rem;
    }
    #player-metadata {
        font-size: 0.85rem;
    }
    audio#audio-player {
        width: 100%; /* Make it flexible */
        min-width: unset; /* Remove min-width to allow shrinking */
        max-width: 250px; /* Cap its max size */
    }
    .form-container {
        max-width: 550px;
        padding: 25px;
    }
}

/* Small devices (landscape phones, 576px and up) */
@media (min-width: 576px) and (max-width: 767.98px) {
    header {
        flex-direction: column;
        align-items: flex-start;
        padding: 0.8rem 1rem;
    }
    #main-nav h1 {
        font-size: 1.5rem;
        margin-bottom: 10px;
        width: 100%; /* Take full width */
    }
    #main-nav ul {
        justify-content: center;
        gap: 12px;
        width: 100%; /* Take full width */
    }
    #main-nav ul li a {
        font-size: 0.95rem;
    }
    main {
        padding: 20px 15px;
    }
    #radio-grid {
        grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
        gap: 15px;
    }
    .radio-card {
        padding: 15px;
    }
    .radio-card img {
        height: 100px;
    }
    .radio-card h3 {
        font-size: 1rem;
    }
    .pagination-controls {
        gap: 10px;
    }
    .pagination-controls button {
        padding: 8px 15px;
        font-size: 0.9rem;
    }
    #page-info {
        font-size: 1rem;
    }
    #sticky-player {
        flex-direction: column;
        align-items: center;
        padding: 10px 15px;
        gap: 10px;
    }
    #sticky-player .player-content {
        width: 100%;
        justify-content: center;
        gap: 10px;
    }
    #player-logo {
        width: 45px;
        height: 45px;
    }
    .player-info {
        text-align: center;
    }
    #player-name {
        font-size: 1rem;
    }
    #player-metadata {
        font-size: 0.8rem;
    }
    audio#audio-player {
        width: 100%; /* Changed from 90% to 100% to fill available space */
        min-width: unset; /* Ensure no minimum width is forcing overflow */
        max-width: 280px; /* Give it a max width to prevent it from getting too big */
        margin-top: 5px;
    }
    .form-container, .admin-section {
        padding: 20px;
        margin: 20px auto;
    }
    .form-container h2 {
        font-size: 1.8rem;
    }
    .admin-list-item, .radio-item {
        flex-direction: column;
        align-items: flex-start;
        padding: 10px 0;
    }
    .admin-list-item span, .radio-item span {
        margin-right: 0;
        margin-bottom: 5px;
        width: 100%;
        word-wrap: break-word; /* Allow long names to wrap */
        white-space: normal;
        min-width: unset;
    }
    .admin-list-item div {
        justify-content: center;
        width: 100%;
    }
    .admin-list-item button, .radio-item button {
        margin: 5px 5px 0 0; /* Adjust button margins */
    }
}

/* Extra small devices (portrait phones, less than 576px) */
@media (max-width: 575.98px) {
    header {
        flex-direction: column;
        align-items: flex-start;
        padding: 0.8rem 1rem;
    }
    #main-nav h1 {
        font-size: 1.3rem;
        margin-bottom: 10px;
        width: 100%;
        text-align: center; /* Center on very small screens */
    }
    #main-nav ul {
        flex-direction: column;
        align-items: center;
        gap: 8px;
        width: 100%;
    }
    #main-nav ul li a {
        font-size: 0.9rem;
    }
    main {
        padding: 15px 10px;
    }
    #radio-grid {
        grid-template-columns: 1fr; /* Single column */
        gap: 15px;
    }
    .radio-card {
        padding: 12px;
    }
    .radio-card img {
        height: 80px;
    }
    .radio-card h3 {
        font-size: 0.95rem;
    }
    .pagination-controls {
        flex-direction: column;
        gap: 8px;
    }
    .pagination-controls button {
        padding: 6px 12px;
        font-size: 0.85rem;
        width: 80%; /* Make buttons wider */
    }
    #page-info {
        font-size: 0.9rem;
    }
    #sticky-player {
        flex-direction: column;
        align-items: center;
        padding: 5px; /* Reduced padding further */
        gap: 5px; /* Reduced gap */
    }
    #sticky-player .player-content {
        flex-direction: column;
        width: 100%;
        text-align: center;
        gap: 5px; /* Reduced gap */
    }
    #player-logo {
        width: 40px;
        height: 40px;
        border-width: 2px;
        flex-shrink: 0; /* Ensure it doesn't shrink smaller than its size */
    }
    .player-info {
        text-align: center;
    }
    #player-name {
        font-size: 0.95rem;
    }
    #player-metadata {
        font-size: 0.75rem;
        display: -webkit-box;
        -webkit-line-clamp: 2; /* Limit to 2 lines */
        -webkit-box-orient: vertical;
        overflow: hidden;
        white-space: normal;
        text-overflow: ellipsis;
    }
    audio#audio-player {
        width: 100%;
        min-width: unset; /* Ensure no minimum width is inherited or set */
        max-width: 100%; /* Explicitly cap it */
        margin-top: 5px;
    }
    audio#audio-player::-webkit-media-controls-panel {
        width: 100%; /* Ensure controls panel takes full width */
    }
    .form-container, .admin-section {
        padding: 15px;
        margin: 15px auto;
    }
    .form-container h2 {
        font-size: 1.5rem;
    }
    .admin-list-item, .radio-item {
        flex-direction: column;
        align-items: flex-start;
        padding: 8px 0;
    }
    .admin-list-item span, .radio-item span {
        margin-bottom: 5px;
        width: 100%;
        word-wrap: break-word;
        white-space: normal;
        min-width: unset;
    }
    .admin-list-item div {
        flex-direction: column;
        width: 100%;
        gap: 5px;
        margin-top: 5px;
    }
    .admin-list-item button, .radio-item button {
        width: 100%;
        margin: 0;
    }
}