/*

Reasonable System for CSS (RSCSS) - A set of ideas to guide your process of building maintainable CSS
https://rstacruz.github.io/rscss/index.html

* Components - Each piece of UI is an individual component
  Naming: At least two words seperated by a dash (.search-form)
  Avoid including positioin properites in components - should be included in layouts

   ** Elements - the things inside of a component
       Naming: Only one word (.field) - if two or more words, concatenate them without dashes or underscores
       Prefer to use the `>` child selector when possible
       Use classnames whenever possible.
       ```
	.search-form {
	  > .field { }
	  > .action { }
	}
       ```

  ** Variants - components may have variants (elements to)
       Naming: classnames will be prefixed with a `-`

  ** Nested Components - It's necessary at times to next components.
       Avoid modifying the nested component by reacing into it from the containing component.  Prefer to add a variant to the nested component and apply it from the containing component.

* Layouts
  Naming: Two words seperated by a `-`
  Contain the position of one or more components
*/


/* Warm & Friendly */
:root {
    --color-background: #FFFDF7;
    --color-surface: #FFFFFF;
    --color-accent: #F59E0B;
    --color-text: #2D2D2D;
    --color-muted: #B0A99A;
    --color-warn: #E03B2F;
      --color-positive: #2E8F5B;
}

/* Dark Mode */
:root[data-theme="dark"] {
    --color-background: #2E2E2E;
    --color-surface: #3A3A3A;
    --color-accent: #4CAF8C;
    --color-text: #F2F2F7;
    --color-muted: #848484;
    --color-warn: #FF5F52;
    --color-positive: #3A9E6F;
}


@font-face {
    font-family: 'IBMPlexMono';
    src: url('/static/vendor/fonts/IBMPlexMono-Regular.ttf') format('truetype');
    font-weight: 400;
    font-style: normal;
}

@font-face {
    font-family: 'IBMPlexMono';
    src: url('/static/vendor/fonts/IBMPlexMono-Italic.ttf') format('truetype');
    font-weight: 400;
    font-style: italic;
}

@font-face {
    font-family: 'IBMPlexMono';
    src: url('/static/vendor/fonts/IBMPlexMono-Medium.ttf') format('truetype');
    font-weight: 500;
    font-style: normal;
}

@font-face {
    font-family: 'IBMPlexMono';
    src: url('/static/vendor/fonts/IBMPlexMono-MediumItalic.ttf') format('truetype');
    font-weight: 500;
    font-style: italic;
}

@font-face {
    font-family: 'IBMPlexMono';
    src: url('/static/vendor/fonts/IBMPlexMono-Bold.ttf') format('truetype');
    font-weight: 700;
    font-style: normal;
}

@font-face {
    font-family: 'IBMPlexMono';
    src: url('/static/vendor/fonts/IBMPlexMono-BoldItalic.ttf') format('truetype');
    font-weight: 700;
    font-style: italic;
}

html, body {
    height: 100%;
}

body {
    font-family: 'IBMPlexMono', sans-serif;
    background-color: var(--color-background);
    color: var(--color-text);
    display: flex;
    flex-direction: column;
}

a {
    color: var(--color-text);
}

a:hover {
    color: var(--color-accent);
}

textarea, input {
    font-family: 'IBMPlexMono', monospace;
    background-color: var(--color-surface);
    color: var(--color-text);
    border-color: var(--color-muted);
}

dialog {
    background-color: var(--color-surface);
    color: var(--color-text);
    border-color: var(--color-muted);
}

main {
    width: 70%;
    margin-left: 10%;
    margin-right: 10%;
    margin-top: 0%;
    flex: 1;
    display: flex;
    flex-direction: column;
    align-self: center;
}


/* COMPONENETS */

.link {
    text-decoration: underline;
    cursor: pointer;
}

.hr-column {
    width: 100%;
    height: 2px;
    border: none;
    background-color: var(--color-muted);
}

.msg-box {
    border: solid;
    background-color: var(--color-accent);
    border-radius: 8px;
    padding-left: .5rem;
    display: inline-block;
    min-height: 1.5rem;

    &.-warn {
	background-color: var(--color-warn);
    }

    &.-hidden {
	border: none;
	background-color: transparent;
    }
}

.nav-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 1.5rem;
    height: 60px;

    > .links {
	display: flex;
	gap: 1rem;
	list-style: none;
	width: 100%;
    }

    > .right {
	justify-content: end;
	align-items:center;
	padding-right: 40px;
	padding-left: 0px;
    }
}


.search-form {
    display: flex;
    align-items: center;
    width: min(380px, 100%);   /* caps width but stays fluid */
    padding: 0.75rem 1.125rem; /* scales with user font prefs */
    border-radius: 0.875rem;
    font-size: 0.9375rem;
    border: solid;
    background-color: var(--color-surface);
    color: var(--color-text);
    

    /* TODO: Icon will float if resized to thin */
    > .icon {
	display: flex;
	align-items: center;
	flex-shrink: 0;
	height: 1.5em;
	width: 1.5em;
	/* position: absolute; */
	/* left: 10px; */
	pointer-events: none;
    }
    > .field {
	flex: 1;
	border: none;
	outline: none;
	background-color: inherit;
	color: inherit;
    }
}

.search-result {
    padding: 8px;
}

.note-links {
    text-align: center;
    > .links {
	list-style: none;
	padding-left: 0;
    }
}


.svg-button {
    cursor: pointer;
    width: 2.25rem;
    height: 2.25rem;
    flex-shrink: 0;
    box-sizing: border-box;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 3px;
    padding: 3px;
    background: transparent;
    border: 3px solid transparent;
    color: var(--color-text);
    
    &:hover {
	border: solid;
	border-color: var(--color-muted);
	border-radius: 8px;
    }
    
    > svg {
	max-width: 100%;
	max-height: 100%;
    }

    &.-active {
	border: solid;
	border-color: var(--color-muted);
	border-radius: 8px;
	background-color: var(--color-accent);
    }
}

.text-button {
    cursor: pointer;
    margin: .15rem;
    border-radius: 8px;
    width: 5rem;
    
    &.-warn {
	background-color: var(--color-warn);
    }
    &.-alt {
	background-color: var(--color-accent);
    }
    &.-positive {
	background-color: var(--color-positive);
    }
    &.-width75 {
	width: 75%;
    }
}

.text-input {
    border-radius: 4px;

    &.-bold {
	font-weight: bold;
    }
    &.-readonly {
	background-color: var(--color-muted);
    }
}

.select-dropdown {
    font-family: 'IBMPlexMono', monospace;
    background-color: var(--color-surface);
    color: var(--color-text);
    border-color: var(--color-muted);
    border-radius: 8px;
}

.search-dropdown {
    background-color: var(--color-surface);
    border: 1px solid var(--color-muted);
    border-radius: 4px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    max-height: 300px;
    overflow-y: auto;

    &:empty {
	display: none;
    }
}

.list-of-links {
    list-style: none;
    padding-left: 0;

    &.-center {
	text-align: center;
    }
}

.note-details {
    border-bottom: solid;

    > .details {
	margin-left: 1rem;
	&.-compact {
	    display: grid;
	    grid-template-columns: max-content auto;


	    > dt {
		grid-column-start: 1;
	    }

	    > dd {
		grid-column-start: 2;
	    }
	}
    }
}


.checkbox-list {
    display: grid;
    grid-template-columns: auto 1fr;
    align-items: center;
    align-content: start;
    gap: .5em 0;
    overflow-y: auto;
    padding: 10px;
    border-color: transparent;
    height: 11.5em;
    max-width: 100%;

    > .readonly {
	opacity: 0;
    }
}

.delete-list {
    list-style-type: none;
    padding-left: 0;
    
    > .item {
	padding-bottom: .25rem;
	display: flex;
	justify-content: space-evenly;

	> .text {
	    flex: .95;
	}
    }
}


.tag-selector {
    > .search{
	border-color: transparent;
    }
    
    > .list {
	display: grid;
	grid-template-columns: auto 1fr;
	align-items: center;
	align-content: start;
	gap: .5em 0;
	overflow-y: auto;
	padding: 10px;
	border-color: transparent;
	height: 11.5em;
	max-width: 100%;
    }
}

.summary-close-button {
    list-style: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 2rem;
    height: 2rem;
    margin-left: auto;

    > .icon {
	width: 1.25rem;
	height: 1.25rem;
    }
    
}

.rendered-markdown {
    font-size: larger;
    > pre {
	background-color: var(--color-surface) !important;
    }
}
/* COMPONENTS */

/* LAYOUTS */
.home-page {
    align-items: center;
    justify-content: center;
    flex: .75;

    > .quick-links {
	display: flex;
	flex-direction: row;
	gap: 4rem;
    }
}

.search-page {
    align-items: center;
    
    > .search-form {
	margin-bottom: 16px;
    }
    
    > .search-results {
	width: 75%;
    }
}

.login-page {
    align-items: center;
    justify-content: center;
    flex: .6;

    > form {
	display: flex;
	flex-direction: column;
	gap: .5rem;
	width: 25%;

	> .text-input {
	    height: 2rem;
	}

	> .text-button {
	    width: 100%;
	    height: 2rem;
	}
    }
}

.setup-page {
    align-items: center;
    justify-content: center;
    flex: .6;

    > form {
	display: flex;
	flex-direction: column;
	gap: .5rem;
	width: 25%;

	> .text-input {
	    height: 2rem;
	}

	> .text-button {
	    width: 100%;
	    height: 2rem;
	}
    }
}

.section-list-page {

    > .list-of-links > .header-edit-form {
	margin-top: .5rem;
    }
}

.note-view-page {
    /* align-self: center; */
}

.header-with-buttons {
        display: flex;
	align-items: center;
	justify-content: space-between;
	margin: .67em;
	height: 2rem;
	> .title {
	    padding-right: 10px;
	}

	> .buttons {
	    display: flex;
	    align-items: center;
	}
}

.dialog-modal {
    > .header {
	display: flex;
	justify-content: space-between;
	align-items: center;
	border-bottom: solid;
    }

    > .header > .svg-button {
	align-self: flex-start;
    }

    > .content {
	padding: 10px;

	> output {
	    min-height: 3rem;
	}
    }

    > .footer {
	display: flex;
	justify-content: flex-end;
	align-items: center;
    }
}

.rendered-note {
    > .title-row {
	display: flex;
	justify-content: space-between;
	align-items: center;

	> .buttons {
	    display: flex;
	}
    }
}


.note-editor {
    display: flex;
    flex-direction: column;
    flex: 1;

    > .titlebar {
	display: flex;
	margin-bottom: 16px;

	> .text-input {
	    flex: 4;
	    margin-right: .5rem;
	}
	> .buttons {
	    flex: 1;
	    display: flex;
	    justify-content: flex-end;
	}
    }

    > .tag-selector {
	flex: 0 0 100%;
	margin-bottom: 16px;
    }
    
    > .editor-row {
	display: flex;
	flex: 1;

	> .editor {
	    flex: 1;
	    display: flex;
	    flex-direction: column;
	    
	    > .toolbar {
		flex: 0 0 auto;
		display: flex;
		justify-content: space-around;
		margin-bottom: 8px;
		border-bottom: thin solid var(--color-muted);
	    }

	    > .textarea {
		flex: 1;
		border: none;
		outline: none;
		overflow-y: auto;
		resize: none;
		background: transparent;
		height: auto;
		box-sizing: border-box;
		font-size: larger;
	    }
	}

	> .sidebar {
	    flex: .3;
	    display: flex;
	    flex-direction: column;
	    row-gap: 1rem;
	    transition: width 0.3s ease, padding 0.3s ease, opacity 0.3s ease;
	    border-left: thin solid var(--color-muted);
	    padding-left: 1em;
	    
	    > .title {
		align-self: center;
		margin-top: 0;
	    }

	    > .section-selector {
		display: flex;
		flex-direction: column;

		> label {
		    padding-bottom: .25em;
		    font-size: large;
		}
	    }

	    > .tag-selector {
		> label {
		    padding-bottom: .25em;
		    font-size: large;
		}

		> .search {
		    display: flex;
		    flex-direction: column;
		    margin-bottom: .25em;

		    > input {
			margin-top: .5em;
			margin-bottom: .5em;
		    }

		    > button {
			width: 100%;
		    }
		}
	    }

	    > .references {
		display: flex;
		flex-direction: column;
		position: relative;
		
		> label {
		    padding-bottom: .25em;
		    font-size: large;
		}

		> .search-dropdown {
		    position: absolute;
		    top: 100%;
		    left: 0;
		    width: 100%;
		    z-index: 50;
		}

		> .selected-notes {
		    list-style
		}
	    }
	    
	    &.-closed {
		display: none;
	    }
	}
    }
}

.header-edit-form {
    display: flex;
    
    > .text-input {
	margin-right: .25rem;
    }

}

.users-table {
    table-layout: fixed;
    width: 90%;
    margin: 10px auto;
    text-align: left;
    border-top: solid;
    border-bottom: solid;

    > thead > tr > .id {
	width: 5%;
    }
    
    > thead > tr > .date {
	width: 20%;
    }

    > tbody > tr > td > .text-input {
	width: 100%;
	box-sizing: border-box;
    }

    > thead > tr > .buttons {
	width: 15%;
    }
}

.table-form {
    display: flex;
    flex-direction: column;

    > label {
	flex: .25;
    }

    > input {
	flex: .75;
	height: 2rem;
	width: 25rem;
	margin: .25rem;
	padding: .25rem;
    }
    
}

/* LAYOUTS */
